diff options
Diffstat (limited to 'src_testbed')
| -rw-r--r-- | src_testbed/box2d_backend.rs | 4 | ||||
| -rw-r--r-- | src_testbed/harness/mod.rs | 15 | ||||
| -rw-r--r-- | src_testbed/physics/mod.rs | 6 | ||||
| -rw-r--r-- | src_testbed/physx_backend.rs | 6 | ||||
| -rw-r--r-- | src_testbed/testbed.rs | 15 |
5 files changed, 28 insertions, 18 deletions
diff --git a/src_testbed/box2d_backend.rs b/src_testbed/box2d_backend.rs index df31c95..db0f846 100644 --- a/src_testbed/box2d_backend.rs +++ b/src_testbed/box2d_backend.rs @@ -158,8 +158,8 @@ impl Box2dWorld { let center = na_vec_to_b2_vec(collider.position_wrt_parent().translation.vector); let mut fixture_def = b2::FixtureDef::new(); - fixture_def.restitution = collider.restitution; - fixture_def.friction = collider.friction; + fixture_def.restitution = collider.material().restitution; + fixture_def.friction = collider.material().friction; fixture_def.density = collider.density().unwrap_or(1.0); fixture_def.is_sensor = collider.is_sensor(); fixture_def.filter = b2::Filter::new(); diff --git a/src_testbed/harness/mod.rs b/src_testbed/harness/mod.rs index 5fcc45c..e37e63d 100644 --- a/src_testbed/harness/mod.rs +++ b/src_testbed/harness/mod.rs @@ -4,7 +4,7 @@ use crate::{ }; use kiss3d::window::Window; use plugin::HarnessPlugin; -use rapier::dynamics::{CCDSolver, IntegrationParameters, JointSet, RigidBodySet}; +use rapier::dynamics::{CCDSolver, IntegrationParameters, IslandManager, JointSet, RigidBodySet}; use rapier::geometry::{BroadPhase, ColliderSet, NarrowPhase}; use rapier::math::Vector; use rapier::pipeline::{ChannelEventCollector, PhysicsHooks, PhysicsPipeline, QueryPipeline}; @@ -120,7 +120,7 @@ impl Harness { colliders: ColliderSet, joints: JointSet, gravity: Vector<f32>, - hooks: impl PhysicsHooks + 'static, + hooks: impl PhysicsHooks<RigidBodySet, ColliderSet> + 'static, ) { // println!("Num bodies: {}", bodies.len()); // println!("Num joints: {}", joints.len()); @@ -130,6 +130,7 @@ impl Harness { self.physics.joints = joints; self.physics.hooks = Box::new(hooks); + self.physics.islands = IslandManager::new(); self.physics.broad_phase = BroadPhase::new(); self.physics.narrow_phase = NarrowPhase::new(); self.state.timestep_id = 0; @@ -175,6 +176,7 @@ impl Harness { physics.pipeline.step( &physics.gravity, &physics.integration_parameters, + &mut physics.islands, &mut physics.broad_phase, &mut physics.narrow_phase, &mut physics.bodies, @@ -191,6 +193,7 @@ impl Harness { self.physics.pipeline.step( &self.physics.gravity, &self.physics.integration_parameters, + &mut self.physics.islands, &mut self.physics.broad_phase, &mut self.physics.narrow_phase, &mut self.physics.bodies, @@ -201,9 +204,11 @@ impl Harness { &self.event_handler, ); - self.physics - .query_pipeline - .update(&self.physics.bodies, &self.physics.colliders); + self.physics.query_pipeline.update( + &self.physics.islands, + &self.physics.bodies, + &self.physics.colliders, + ); for plugin in &mut self.plugins { plugin.step(&mut self.physics, &self.state) diff --git a/src_testbed/physics/mod.rs b/src_testbed/physics/mod.rs index b89f9c8..29e9a46 100644 --- a/src_testbed/physics/mod.rs +++ b/src_testbed/physics/mod.rs @@ -1,5 +1,5 @@ use crossbeam::channel::Receiver; -use rapier::dynamics::{CCDSolver, IntegrationParameters, JointSet, RigidBodySet}; +use rapier::dynamics::{CCDSolver, IntegrationParameters, IslandManager, JointSet, RigidBodySet}; use rapier::geometry::{BroadPhase, ColliderSet, ContactEvent, IntersectionEvent, NarrowPhase}; use rapier::math::Vector; use rapier::pipeline::{PhysicsHooks, PhysicsPipeline, QueryPipeline}; @@ -68,6 +68,7 @@ impl PhysicsSnapshot { } pub struct PhysicsState { + pub islands: IslandManager, pub broad_phase: BroadPhase, pub narrow_phase: NarrowPhase, pub bodies: RigidBodySet, @@ -78,12 +79,13 @@ pub struct PhysicsState { pub query_pipeline: QueryPipeline, pub integration_parameters: IntegrationParameters, pub gravity: Vector<f32>, - pub hooks: Box<dyn PhysicsHooks>, + pub hooks: Box<dyn PhysicsHooks<RigidBodySet, ColliderSet>>, } impl PhysicsState { pub fn new() -> Self { Self { + islands: IslandManager::new(), broad_phase: BroadPhase::new(), narrow_phase: NarrowPhase::new(), bodies: RigidBodySet::new(), diff --git a/src_testbed/physx_backend.rs b/src_testbed/physx_backend.rs index 8a3b155..4c41e2c 100644 --- a/src_testbed/physx_backend.rs +++ b/src_testbed/physx_backend.rs @@ -520,9 +520,9 @@ fn physx_collider_from_rapier_collider( }; let mut material = physics .create_material( - collider.friction, - collider.friction, - collider.restitution, + collider.material().friction, + collider.material().friction, + collider.material().restitution, (), ) .unwrap(); diff --git a/src_testbed/testbed.rs b/src_testbed/testbed.rs index 0e04de6..d885c8a 100644 --- a/src_testbed/testbed.rs +++ b/src_testbed/testbed.rs @@ -19,7 +19,7 @@ use kiss3d::text::Font; use kiss3d::window::{State, Window}; use na::{self, Point2, Point3, Vector3}; use rapier::dynamics::{ - ActivationStatus, IntegrationParameters, JointSet, RigidBodyHandle, RigidBodySet, + IntegrationParameters, JointSet, RigidBodyActivation, RigidBodyHandle, RigidBodySet, }; use rapier::geometry::{ColliderHandle, ColliderSet, NarrowPhase}; #[cfg(feature = "dim3")] @@ -245,7 +245,7 @@ impl Testbed { colliders: ColliderSet, joints: JointSet, gravity: Vector<f32>, - hooks: impl PhysicsHooks + 'static, + hooks: impl PhysicsHooks<RigidBodySet, ColliderSet> + 'static, ) { self.harness .set_world_with_params(bodies, colliders, joints, gravity, hooks); @@ -586,6 +586,7 @@ impl Testbed { for to_delete in &colliders[..num_to_delete] { self.harness.physics.colliders.remove( to_delete[0], + &mut self.harness.physics.islands, &mut self.harness.physics.bodies, true, ); @@ -605,6 +606,7 @@ impl Testbed { for to_delete in &dynamic_bodies[..num_to_delete] { self.harness.physics.bodies.remove( *to_delete, + &mut self.harness.physics.islands, &mut self.harness.physics.colliders, &mut self.harness.physics.joints, ); @@ -617,6 +619,7 @@ impl Testbed { for to_delete in &joints[..num_to_delete] { self.harness.physics.joints.remove( *to_delete, + &mut self.harness.physics.islands, &mut self.harness.physics.bodies, true, ); @@ -1205,13 +1208,13 @@ impl State for Testbed { != self.state.flags.contains(TestbedStateFlags::SLEEP) { if self.state.flags.contains(TestbedStateFlags::SLEEP) { - for (_, mut body) in self.harness.physics.bodies.iter_mut() { - body.activation.threshold = ActivationStatus::default_threshold(); + for (_, body) in self.harness.physics.bodies.iter_mut() { + body.activation_mut().threshold = RigidBodyActivation::default_threshold(); } } else { - for (_, mut body) in self.harness.physics.bodies.iter_mut() { + for (_, body) in self.harness.physics.bodies.iter_mut() { body.wake_up(true); - body.activation.threshold = -1.0; + body.activation_mut().threshold = -1.0; } } } |
