From e16b7722be23f7b6627bd54e174d7782d33c53fe Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Mon, 14 Sep 2020 22:22:55 +0200 Subject: Fix crash caused by the removal of a kinematic body. --- examples3d/platform3.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'examples3d') diff --git a/examples3d/platform3.rs b/examples3d/platform3.rs index 3836baf..bb71b76 100644 --- a/examples3d/platform3.rs +++ b/examples3d/platform3.rs @@ -65,21 +65,22 @@ pub fn init_world(testbed: &mut Testbed) { * Setup a callback to control the platform. */ testbed.add_callback(move |_, physics, _, _, time| { - let mut platform = physics.bodies.get_mut(platform_handle).unwrap(); - let mut next_pos = platform.position; + if let Some(mut platform) = physics.bodies.get_mut(platform_handle) { + let mut next_pos = platform.position; - let dt = 0.016; - next_pos.translation.vector.y += (time * 5.0).sin() * dt; - next_pos.translation.vector.z += time.sin() * 5.0 * dt; + let dt = 0.016; + next_pos.translation.vector.y += (time * 5.0).sin() * dt; + next_pos.translation.vector.z += time.sin() * 5.0 * dt; - if next_pos.translation.vector.z >= rad * 10.0 { - next_pos.translation.vector.z -= dt; - } - if next_pos.translation.vector.z <= -rad * 10.0 { - next_pos.translation.vector.z += dt; - } + if next_pos.translation.vector.z >= rad * 10.0 { + next_pos.translation.vector.z -= dt; + } + if next_pos.translation.vector.z <= -rad * 10.0 { + next_pos.translation.vector.z += dt; + } - platform.set_next_kinematic_position(next_pos); + platform.set_next_kinematic_position(next_pos); + } }); /* -- cgit From 7b8e322446ffa36e3f47078e23eb61ef423175dc Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Mon, 21 Sep 2020 10:43:20 +0200 Subject: Make kinematic bodies properly wake up dynamic bodies. --- examples3d/platform3.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'examples3d') diff --git a/examples3d/platform3.rs b/examples3d/platform3.rs index bb71b76..6c3483e 100644 --- a/examples3d/platform3.rs +++ b/examples3d/platform3.rs @@ -64,7 +64,13 @@ pub fn init_world(testbed: &mut Testbed) { /* * Setup a callback to control the platform. */ + let mut count = 0; testbed.add_callback(move |_, physics, _, _, time| { + count += 1; + if count % 100 > 50 { + return; + } + if let Some(mut platform) = physics.bodies.get_mut(platform_handle) { let mut next_pos = platform.position; -- cgit From 93aa7b6e1e8cbfd73542ed10ad5c26ae0a8b9848 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Mon, 5 Oct 2020 19:04:18 +0200 Subject: Use the publish-subscribe mechanism to handle collider removals across pipelines. --- examples3d/add_remove3.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'examples3d') diff --git a/examples3d/add_remove3.rs b/examples3d/add_remove3.rs index 17aad44..6b58adf 100644 --- a/examples3d/add_remove3.rs +++ b/examples3d/add_remove3.rs @@ -28,14 +28,9 @@ pub fn init_world(testbed: &mut Testbed) { .map(|e| e.0) .collect(); for handle in to_remove { - physics.pipeline.remove_rigid_body( - handle, - &mut physics.broad_phase, - &mut physics.narrow_phase, - &mut physics.bodies, - &mut physics.colliders, - &mut physics.joints, - ); + physics + .bodies + .remove(handle, &mut physics.colliders, &mut physics.joints); graphics.remove_body_nodes(window, handle); } }); -- cgit