diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-03-19 17:52:56 +0100 |
|---|---|---|
| committer | Sébastien Crozet <sebastien@crozet.re> | 2022-03-20 21:49:16 +0100 |
| commit | 063c638ec5906747e3ca85ee0c5f112c7775f797 (patch) | |
| tree | 498090f01c8cf8d69a35d03e123a1dfe006c54bf /examples3d | |
| parent | a9e3441ecd64d50b478ab5370fabe187ec9a5c39 (diff) | |
| download | rapier-063c638ec5906747e3ca85ee0c5f112c7775f797.tar.gz rapier-063c638ec5906747e3ca85ee0c5f112c7775f797.tar.bz2 rapier-063c638ec5906747e3ca85ee0c5f112c7775f797.zip | |
Combine contact events and intersection events into a single event type and flags
Diffstat (limited to 'examples3d')
| -rw-r--r-- | examples3d/ccd3.rs | 10 | ||||
| -rw-r--r-- | examples3d/sensor3.rs | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/examples3d/ccd3.rs b/examples3d/ccd3.rs index 635b0e0..8bcbd6e 100644 --- a/examples3d/ccd3.rs +++ b/examples3d/ccd3.rs @@ -92,7 +92,7 @@ pub fn init_world(testbed: &mut Testbed) { let collider = ColliderBuilder::ball(1.0) .density(10.0) .sensor(true) - .active_events(ActiveEvents::INTERSECTION_EVENTS); + .active_events(ActiveEvents::COLLISION_EVENTS); let rigid_body = RigidBodyBuilder::dynamic() .linvel(vector![1000.0, 0.0, 0.0]) .translation(vector![-20.0, shift_y + 2.0, 0.0]) @@ -112,8 +112,8 @@ pub fn init_world(testbed: &mut Testbed) { // Callback that will be executed on the main loop to handle proximities. testbed.add_callback(move |mut graphics, physics, events, _| { - while let Ok(prox) = events.intersection_events.try_recv() { - let color = if prox.intersecting { + while let Ok(prox) = events.events.try_recv() { + let color = if prox.started() { [1.0, 1.0, 0.0] } else { [0.5, 0.5, 1.0] @@ -121,13 +121,13 @@ pub fn init_world(testbed: &mut Testbed) { let parent_handle1 = physics .colliders - .get(prox.collider1) + .get(prox.collider1()) .unwrap() .parent() .unwrap(); let parent_handle2 = physics .colliders - .get(prox.collider2) + .get(prox.collider2()) .unwrap() .parent() .unwrap(); diff --git a/examples3d/sensor3.rs b/examples3d/sensor3.rs index 3c92460..9fae737 100644 --- a/examples3d/sensor3.rs +++ b/examples3d/sensor3.rs @@ -65,22 +65,22 @@ pub fn init_world(testbed: &mut Testbed) { let sensor_collider = ColliderBuilder::ball(rad * 5.0) .density(0.0) .sensor(true) - .active_events(ActiveEvents::INTERSECTION_EVENTS); + .active_events(ActiveEvents::COLLISION_EVENTS); colliders.insert_with_parent(sensor_collider, sensor_handle, &mut bodies); testbed.set_initial_body_color(sensor_handle, [0.5, 1.0, 1.0]); // Callback that will be executed on the main loop to handle proximities. testbed.add_callback(move |mut graphics, physics, events, _| { - while let Ok(prox) = events.intersection_events.try_recv() { - let color = if prox.intersecting { + while let Ok(prox) = events.events.try_recv() { + let color = if prox.started() { [1.0, 1.0, 0.0] } else { [0.5, 0.5, 1.0] }; - let parent_handle1 = physics.colliders[prox.collider1].parent().unwrap(); - let parent_handle2 = physics.colliders[prox.collider2].parent().unwrap(); + let parent_handle1 = physics.colliders[prox.collider1()].parent().unwrap(); + let parent_handle2 = physics.colliders[prox.collider2()].parent().unwrap(); if let Some(graphics) = &mut graphics { if parent_handle1 != ground_handle && parent_handle1 != sensor_handle { |
