Externalize the proximity code (renamed intersection).

This commit is contained in:
Crozet Sébastien
2020-12-17 13:23:00 +01:00
parent e231bacec6
commit 29717c2887
22 changed files with 144 additions and 1051 deletions

View File

@@ -1,6 +1,6 @@
use na::Point3;
use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
use rapier3d::geometry::{ColliderBuilder, ColliderSet, Proximity};
use rapier3d::geometry::{ColliderBuilder, ColliderSet};
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -74,10 +74,11 @@ pub fn init_world(testbed: &mut Testbed) {
// Callback that will be executed on the main loop to handle proximities.
testbed.add_callback(move |_, physics, events, graphics, _| {
while let Ok(prox) = events.proximity_events.try_recv() {
let color = match prox.new_status {
Proximity::WithinMargin | Proximity::Intersecting => Point3::new(1.0, 1.0, 0.0),
Proximity::Disjoint => Point3::new(0.5, 0.5, 1.0),
while let Ok(prox) = events.intersection_events.try_recv() {
let color = if prox.intersecting {
Point3::new(1.0, 1.0, 0.0)
} else {
Point3::new(0.5, 0.5, 1.0)
};
let parent_handle1 = physics.colliders.get(prox.collider1).unwrap().parent();