Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
members = ["bevy_rapier2d", "bevy_rapier3d", "bevy_rapier_benches3d", "ci"]
resolver = "2"

[workspace.dependencies]
rapier2d = "=0.33.0-alpha"
rapier3d = "=0.33.0-alpha"

[profile.dev]
# Use slightly better optimization by default, as examples otherwise seem laggy.
opt-level = 1
Expand Down
18 changes: 9 additions & 9 deletions bevy_rapier2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,22 @@ headless = []
picking-backend = ["bevy/bevy_picking", "bevy/bevy_render"]
async-collider = [
"bevy/bevy_asset",
"bevy/bevy_scene",
"bevy/bevy_world_serialization",
"bevy/bevy_render",
"bevy/bevy_image",
]
to-bevy-mesh = ["bevy/bevy_render", "bevy/bevy_asset"]

[dependencies]
bevy = { version = "0.18.1", default-features = false, features = ["std"] }
nalgebra = { version = "0.34.2", features = ["convert-glam030"] }
rapier2d = "0.32.0"
bevy = { version = "0.19.0", default-features = false, features = ["std"] }
nalgebra = { version = "0.34.2", features = ["convert-glam032"] }
rapier2d = { workspace = true }
bitflags = "2.10.0"
log = "0.4"
serde = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
bevy = { version = "0.18.1", default-features = false, features = [
bevy = { version = "0.19.0", default-features = false, features = [
"x11",
"bevy_state",
"bevy_window",
Expand All @@ -92,10 +92,10 @@ bevy = { version = "0.18.1", default-features = false, features = [
] }
oorandom = "11"
approx = "0.5.1"
glam = { version = "0.30.9", features = ["approx"] }
bevy-inspector-egui = "0.36.0"
bevy_egui = "0.39.1"
bevy_mod_debugdump = "0.15.0"
glam = { version = "0.32.1", features = ["approx"] }
bevy-inspector-egui = "0.37.0"
bevy_egui = "0.40.0"
bevy_mod_debugdump = "0.16.0"
serde_json = "1.0"

[package.metadata.docs.rs]
Expand Down
29 changes: 22 additions & 7 deletions bevy_rapier2d/examples/testbed2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ mod player_movement2;
mod rope_joint2;
mod voxels2;

use bevy::{camera::visibility::RenderLayers, ecs::world::error::EntityDespawnError, prelude::*};
use bevy::{
camera::visibility::RenderLayers,
ecs::{resource::IsResource, world::error::EntityDespawnError},
prelude::*,
};
use bevy_egui::{egui, EguiContexts, EguiPlugin, EguiPrimaryContextPass};
use bevy_inspector_egui::quick::WorldInspectorPlugin;
use bevy_rapier2d::prelude::*;
Expand Down Expand Up @@ -67,8 +71,13 @@ fn main() {
EguiPlugin::default(),
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(10.0),
RapierDebugRenderPlugin::default(),
WorldInspectorPlugin::new(),
))
// `bevy-inspector-egui` unconditionally registers an `InspectorEguiImpl` for
// `GizmoConfigStore`, which panics unless the type has already been registered.
// Bevy 0.19 no longer registers it automatically, so do it here before adding
// the inspector plugin.
.register_type::<GizmoConfigStore>()
.add_plugins(WorldInspectorPlugin::new())
.register_type::<Examples>()
.register_type::<ExamplesRes>()
.register_type::<ExampleSelected>()
Expand Down Expand Up @@ -261,24 +270,30 @@ fn main() {

fn init(world: &mut World) {
// save all entities that are in the world before setting up any example
// to be able to always return to this state when switching from one example to the other
// to be able to always return to this state when switching from one example to the other.
// Resource-backed entities (carrying `IsResource`) are excluded: in Bevy 0.19 resources are
// stored as entities, and despawning them in `cleanup` panics.
world.resource_mut::<ExamplesRes>().entities_before = world
.query::<EntityRef>()
.query_filtered::<Entity, Without<IsResource>>()
.iter(world)
.map(|e| e.id())
.collect::<Vec<_>>();
}

fn cleanup(world: &mut World) {
let keep_alive = world.resource::<ExamplesRes>().entities_before.clone();

let remove = world
.query::<EntityRef>()
.query_filtered::<Entity, Without<IsResource>>()
.iter(world)
.filter_map(|e| (!keep_alive.contains(&e.id())).then_some(e.id()))
.filter(|e| !keep_alive.contains(e))
.collect::<Vec<_>>();

for r in remove {
// The entity may already have been despawned as part of a parent's despawn cascade;
// skip it in that case to avoid a flood of spurious "invalid entity" warnings.
if !world.entities().contains(r) {
continue;
}
if let Err(error @ EntityDespawnError(_)) = world.try_despawn(r) {
warn!("Cleanup error: {error:?}");
}
Expand Down
18 changes: 9 additions & 9 deletions bevy_rapier3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@ headless = []
picking-backend = ["bevy/bevy_picking", "bevy/bevy_render"]
async-collider = [
"bevy/bevy_asset",
"bevy/bevy_scene",
"bevy/bevy_world_serialization",
"bevy/bevy_render",
"bevy/bevy_image",
]
to-bevy-mesh = ["bevy/bevy_render", "bevy/bevy_asset"]

[dependencies]
bevy = { version = "0.18.1", default-features = false, features = ["std"] }
nalgebra = { version = "0.34.2", features = ["convert-glam030"] }
rapier3d = "0.32.0"
bevy = { version = "0.19.0", default-features = false, features = ["std"] }
nalgebra = { version = "0.34.2", features = ["convert-glam032"] }
rapier3d = { workspace = true }
bitflags = "2.10.0"
log = "0.4"
serde = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
bevy = { version = "0.18.1", default-features = false, features = [
bevy = { version = "0.19.0", default-features = false, features = [
"bevy_window",
"x11",
"tonemapping_luts",
Expand All @@ -86,10 +86,10 @@ bevy = { version = "0.18.1", default-features = false, features = [
"bevy_gizmos_render",
] }
approx = "0.5.1"
glam = { version = "0.30.9", features = ["approx"] }
bevy-inspector-egui = "0.36.0"
bevy_egui = "0.39.1"
bevy_mod_debugdump = "0.15.0"
glam = { version = "0.32.1", features = ["approx"] }
bevy-inspector-egui = "0.37.0"
bevy_egui = "0.40.0"
bevy_mod_debugdump = "0.16.0"

[package.metadata.docs.rs]
# Enable all the features when building the docs on docs.rs
Expand Down
2 changes: 1 addition & 1 deletion bevy_rapier3d/examples/rapier_to_bevy_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn setup_physics(
// light
commands.spawn((
PointLight {
shadows_enabled: true,
shadow_maps_enabled: true,
..default()
},
Transform::from_xyz(4.0, 8.0, 8.0),
Expand Down
30 changes: 22 additions & 8 deletions bevy_rapier3d/examples/testbed3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ mod ray_casting3;
mod static_trimesh3;
mod voxels3;

use bevy::{camera::visibility::RenderLayers, ecs::world::error::EntityDespawnError, prelude::*};
use bevy::{
camera::visibility::RenderLayers,
ecs::{resource::IsResource, world::error::EntityDespawnError},
prelude::*,
};
use bevy_egui::{egui, EguiContexts, EguiPlugin, EguiPrimaryContextPass};
use bevy_inspector_egui::quick::WorldInspectorPlugin;
use bevy_rapier3d::prelude::*;
Expand Down Expand Up @@ -67,9 +71,13 @@ fn main() {
EguiPlugin::default(),
RapierPhysicsPlugin::<NoUserData>::default(),
RapierDebugRenderPlugin::default(),
WorldInspectorPlugin::new(),
RapierPickingPlugin,
))
// `bevy-inspector-egui` unconditionally registers an `InspectorEguiImpl` for
// `GizmoConfigStore`, which panics unless the type has already been registered.
// Bevy 0.19 no longer registers it automatically, so do it here before adding
// the inspector plugin.
.register_type::<GizmoConfigStore>()
.add_plugins((WorldInspectorPlugin::new(), RapierPickingPlugin))
.register_type::<Examples>()
.register_type::<ExamplesRes>()
.register_type::<ExampleSelected>()
Expand Down Expand Up @@ -253,23 +261,29 @@ fn main() {

fn init(world: &mut World) {
// save all entities that are in the world before setting up any example
// to be able to always return to this state when switching from one example to the other
// to be able to always return to this state when switching from one example to the other.
// Resource-backed entities (carrying `IsResource`) are excluded: in Bevy 0.19 resources are
// stored as entities, and despawning them in `cleanup` panics.
world.resource_mut::<ExamplesRes>().entities_before = world
.query::<EntityRef>()
.query_filtered::<Entity, Without<IsResource>>()
.iter(world)
.map(|e| e.id())
.collect::<Vec<_>>();
}

fn cleanup(world: &mut World) {
let keep_alive = world.resource::<ExamplesRes>().entities_before.clone();

let remove = world
.query::<EntityRef>()
.query_filtered::<Entity, Without<IsResource>>()
.iter(world)
.filter_map(|e| (!keep_alive.contains(&e.id())).then_some(e.id()))
.filter(|e| !keep_alive.contains(e))
.collect::<Vec<_>>();
for r in remove {
// The entity may already have been despawned as part of a parent's despawn cascade;
// skip it in that case to avoid a flood of spurious "invalid entity" warnings.
if !world.entities().contains(r) {
continue;
}
if let Err(error @ EntityDespawnError(_)) = world.try_despawn(r) {
warn!("Cleanup error: {error:?}");
}
Expand Down
4 changes: 2 additions & 2 deletions bevy_rapier_benches3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rapier3d = "0.32.0"
rapier3d = { workspace = true }
bevy_rapier3d = { version = "0.34", path = "../bevy_rapier3d" }
bevy = { version = "0.18.1", default-features = false }
bevy = { version = "0.19.0", default-features = false }

[dev-dependencies]
divan = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion ci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
bevy = "0.18.1"
bevy = "0.19.0"
bevy_rapier3d = { version = "0.34", path = "../bevy_rapier3d" }
bevy_rapier2d = { version = "0.34", path = "../bevy_rapier2d" }

Expand Down
10 changes: 10 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ ignore = [
# - https://github.com/bevyengine/bevy/pull/18209
# Bevy relies on this in multiple indirect ways, so ignoring it is the only feasible current solution
"RUSTSEC-2024-0436",
# quick-xml advisories: pulled in transitively via bevy -> wayland-scanner, which
# pins quick-xml 0.39 and has no compatible upgrade to the patched >=0.41.0 yet.
# See: https://rustsec.org/advisories/RUSTSEC-2026-0194
"RUSTSEC-2026-0194",
# See: https://rustsec.org/advisories/RUSTSEC-2026-0195
"RUSTSEC-2026-0195",
# ttf-parser is unmaintained with no safe upgrade available; pulled in transitively
# via bevy -> ab_glyph -> owned_ttf_parser.
# See: https://rustsec.org/advisories/RUSTSEC-2026-0192
"RUSTSEC-2026-0192",
]

[licenses]
Expand Down
2 changes: 2 additions & 0 deletions src/picking_backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub fn update_hits(
position: Some(bevy::math::Vec3::new(ray.origin.x, ray.origin.y, 0.0)),
normal: None,
depth: 0.0,
extra: None,
};
picks.push((entity, hit_data));
}
Expand All @@ -163,6 +164,7 @@ pub fn update_hits(
position: Some(intersection.point),
normal: Some(intersection.normal),
depth: intersection.time_of_impact,
extra: None,
};
picks.push((entity, hit_data));
}
Expand Down
8 changes: 5 additions & 3 deletions src/plugin/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,17 @@ where
fn finish(&self, _app: &mut App) {
#[cfg(all(feature = "dim3", feature = "async-collider"))]
{
use bevy::{asset::AssetPlugin, mesh::MeshPlugin, scene::ScenePlugin};
use bevy::{
asset::AssetPlugin, mesh::MeshPlugin, world_serialization::WorldSerializationPlugin,
};
if !_app.is_plugin_added::<AssetPlugin>() {
_app.add_plugins(AssetPlugin::default());
}
if !_app.is_plugin_added::<MeshPlugin>() {
_app.add_plugins(MeshPlugin);
}
if !_app.is_plugin_added::<ScenePlugin>() {
_app.add_plugins(ScenePlugin);
if !_app.is_plugin_added::<WorldSerializationPlugin>() {
_app.add_plugins(WorldSerializationPlugin);
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/plugin/systems/collider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use rapier::geometry::ColliderBuilder;
#[cfg(all(feature = "dim3", feature = "async-collider"))]
use {
crate::prelude::{AsyncCollider, AsyncSceneCollider},
bevy::scene::SceneInstance,
bevy::world_serialization::WorldInstance,
};

#[cfg(feature = "dim2")]
Expand Down Expand Up @@ -533,8 +533,8 @@ pub fn init_async_colliders(
pub fn init_async_scene_colliders(
mut commands: Commands,
meshes: Res<Assets<Mesh>>,
scene_spawner: Res<SceneSpawner>,
async_colliders: Query<(Entity, &SceneInstance, &AsyncSceneCollider)>,
scene_spawner: If<Res<WorldInstanceSpawner>>,
async_colliders: Query<(Entity, &WorldInstance, &AsyncSceneCollider)>,
children: Query<&Children>,
mesh_handles: Query<(&Name, &Mesh3d)>,
) {
Expand Down Expand Up @@ -600,10 +600,10 @@ pub mod test {
#[cfg(all(feature = "dim3", feature = "async-collider"))]
fn async_collider_initializes() {
use super::*;
use bevy::{mesh::MeshPlugin, scene::ScenePlugin};
use bevy::{mesh::MeshPlugin, world_serialization::WorldSerializationPlugin};

let mut app = App::new();
app.add_plugins((AssetPlugin::default(), MeshPlugin, ScenePlugin));
app.add_plugins((AssetPlugin::default(), MeshPlugin, WorldSerializationPlugin));
app.add_systems(Update, init_async_colliders);

app.finish();
Expand Down Expand Up @@ -633,10 +633,10 @@ pub mod test {
#[cfg(all(feature = "dim3", feature = "async-collider"))]
fn async_scene_collider_initializes() {
use super::*;
use bevy::{mesh::MeshPlugin, scene::ScenePlugin};
use bevy::{mesh::MeshPlugin, world_serialization::WorldSerializationPlugin};

let mut app = App::new();
app.add_plugins((AssetPlugin::default(), MeshPlugin, ScenePlugin));
app.add_plugins((AssetPlugin::default(), MeshPlugin, WorldSerializationPlugin));
app.add_systems(PostUpdate, init_async_scene_colliders);

let mut meshes = app.world_mut().resource_mut::<Assets<Mesh>>();
Expand All @@ -651,15 +651,15 @@ pub mod test {
.spawn((Name::new("Capsule"), Mesh3d(capsule_handle)))
.id();

let mut scenes = app.world_mut().resource_mut::<Assets<Scene>>();
let scene = scenes.add(Scene::new(World::new()));
let mut scenes = app.world_mut().resource_mut::<Assets<WorldAsset>>();
let scene = scenes.add(WorldAsset::new(World::new()));

let mut named_shapes = bevy::platform::collections::HashMap::default();
named_shapes.insert("Capsule".to_string(), None);
let parent = app
.world_mut()
.spawn((
SceneRoot(scene),
WorldAssetRoot(scene),
AsyncSceneCollider {
named_shapes,
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions src/plugin/systems/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::plugin::context::{
use crate::prelude::MassModifiedEvent;
use crate::prelude::RigidBodyDisabled;
use crate::prelude::Sensor;
use bevy::ecs::query::QueryData;
use bevy::ecs::query::IterQueryData;
use bevy::prelude::*;

/// System responsible for removing from Rapier the rigid-bodies/colliders/joints which had
Expand Down Expand Up @@ -242,7 +242,7 @@ pub fn sync_removals(
// TODO: what about removing forces?
}

fn find_context<'a, TReturn, TQueryParams: QueryData>(
fn find_context<'a, TReturn, TQueryParams: IterQueryData>(
context_writer: &'a mut Query<TQueryParams>,
item_finder: impl Fn(&mut TQueryParams::Item<'_, '_>) -> Option<TReturn>,
) -> Option<(TQueryParams::Item<'a, 'a>, TReturn)> {
Expand Down
Loading