going to make entity spawning a little easier

This commit is contained in:
2021-02-18 19:54:06 -08:00
parent 722bf45a7a
commit e3c1ce7789
8 changed files with 195 additions and 170 deletions

View File

@@ -7,7 +7,7 @@ use legion::*;
use nalgebra::Quaternion as naQuaternion;
use rapier3d::dynamics::{IntegrationParameters, JointSet, RigidBodySet};
use rapier3d::geometry::{BroadPhase, ColliderSet, NarrowPhase};
use rapier3d::pipeline::PhysicsPipeline;
use rapier3d::pipeline::{PhysicsPipeline, ChannelEventCollector};
use crate::camera::{Camera, CameraController};
use crate::components::{Collider, LoopState, Mesh, Physics, Position};
@@ -45,8 +45,12 @@ pub fn run_physics(
}
}
let (contact_send, contact_recv) = crossbeam::channel::unbounded();
let (intersection_send, intersection_recv) = crossbeam::channel::unbounded();
let event_handler = ChannelEventCollector::new(intersection_send, contact_send);
// run the physics step
let event_handler = ();
physics_pipeline.step(
&physics_state.gravity,
&physics_state.integration_parameters,
@@ -59,6 +63,14 @@ pub fn run_physics(
None,
&event_handler,
);
while let Ok(intersection_event) = intersection_recv.try_recv() {
println!("{:?}", intersection_event)
}
while let Ok(contact_event) = contact_recv.try_recv() {
println!("{:?}", contact_event)
}
}