diff --git a/src/systems/sync_bodies_from_physics.rs b/src/systems/sync_bodies_from_physics.rs index e73f199..74d535b 100644 --- a/src/systems/sync_bodies_from_physics.rs +++ b/src/systems/sync_bodies_from_physics.rs @@ -4,7 +4,7 @@ use amethyst::core::{GlobalTransform, Transform}; use amethyst::ecs::{Join, ReadStorage, System, Write, ReadExpect, WriteStorage}; use amethyst::shrev::EventChannel; use nalgebra::Vector3; -use ncollide3d::events::ContactEvent; +use ncollide3d::events::{ContactEvent, ProximityEvent}; use nphysics3d::object::Body; #[derive(Default)] @@ -20,6 +20,7 @@ impl<'a> System<'a> for SyncBodiesFromPhysicsSystem { type SystemData = ( ReadExpect<'a, PhysicsWorld>, Write<'a, EventChannel>, + Write<'a, EventChannel>, WriteStorage<'a, GlobalTransform>, WriteStorage<'a, DynamicBody>, ReadStorage<'a, Transform>, @@ -28,7 +29,8 @@ impl<'a> System<'a> for SyncBodiesFromPhysicsSystem { fn run(&mut self, data: Self::SystemData) { let ( physical_world, - _contact_events, + mut contact_events, + mut proximity_events, mut global_transforms, mut physics_bodies, local_transforms, @@ -85,6 +87,11 @@ impl<'a> System<'a> for SyncBodiesFromPhysicsSystem { }; } + let collision_world = physical_world.collision_world(); + + contact_events.iter_write(collision_world.contact_events().iter().cloned()); + proximity_events.iter_write(collision_world.proximity_events().iter().cloned()); + // TODO: reader id from other system? // Now that we changed them all, let's remove all those pesky events that were generated. // global_transforms