Skip to content

Commit

Permalink
Shoot events!
Browse files Browse the repository at this point in the history
  • Loading branch information
AnneKitsune committed Dec 19, 2018
1 parent 602981c commit 73374ae
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/systems/sync_bodies_from_physics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -20,6 +20,7 @@ impl<'a> System<'a> for SyncBodiesFromPhysicsSystem {
type SystemData = (
ReadExpect<'a, PhysicsWorld>,
Write<'a, EventChannel<ContactEvent>>,
Write<'a, EventChannel<ProximityEvent>>,
WriteStorage<'a, GlobalTransform>,
WriteStorage<'a, DynamicBody>,
ReadStorage<'a, Transform>,
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 73374ae

Please sign in to comment.