Split rigid-bodies and colliders into multiple components
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
//! Physics pipeline structures.
|
||||
|
||||
use crate::dynamics::{JointSet, RigidBodySet};
|
||||
use crate::geometry::{BroadPhase, BroadPhasePairEvent, ColliderPair, ColliderSet, NarrowPhase};
|
||||
use crate::data::{ComponentSet, ComponentSetMut};
|
||||
use crate::dynamics::{
|
||||
IslandManager, JointSet, RigidBodyActivation, RigidBodyColliders, RigidBodyDominance,
|
||||
RigidBodyIds, RigidBodyType, RigidBodyVelocity,
|
||||
};
|
||||
use crate::geometry::{BroadPhase, BroadPhasePairEvent, ColliderPair, ColliderShape, NarrowPhase};
|
||||
use crate::math::Real;
|
||||
use crate::pipeline::{EventHandler, PhysicsHooks};
|
||||
|
||||
@@ -34,46 +38,25 @@ impl CollisionPipeline {
|
||||
}
|
||||
|
||||
/// Executes one step of the collision detection.
|
||||
pub fn step(
|
||||
pub fn step<Bodies, Colliders>(
|
||||
&mut self,
|
||||
prediction_distance: Real,
|
||||
broad_phase: &mut BroadPhase,
|
||||
narrow_phase: &mut NarrowPhase,
|
||||
bodies: &mut RigidBodySet,
|
||||
colliders: &mut ColliderSet,
|
||||
hooks: &dyn PhysicsHooks,
|
||||
events: &dyn EventHandler,
|
||||
) {
|
||||
colliders.handle_user_changes(bodies);
|
||||
bodies.handle_user_changes(colliders);
|
||||
self.broadphase_collider_pairs.clear();
|
||||
|
||||
self.broad_phase_events.clear();
|
||||
broad_phase.update(prediction_distance, colliders, &mut self.broad_phase_events);
|
||||
|
||||
narrow_phase.handle_user_changes(colliders, bodies, events);
|
||||
narrow_phase.register_pairs(colliders, bodies, &self.broad_phase_events, events);
|
||||
narrow_phase.compute_contacts(prediction_distance, bodies, colliders, hooks, events);
|
||||
narrow_phase.compute_intersections(bodies, colliders, hooks, events);
|
||||
|
||||
bodies.update_active_set_with_contacts(
|
||||
colliders,
|
||||
narrow_phase,
|
||||
self.empty_joints.joint_graph(),
|
||||
128,
|
||||
);
|
||||
|
||||
// Update colliders positions and kinematic bodies positions.
|
||||
bodies.foreach_active_body_mut_internal(|_, rb| {
|
||||
rb.position = rb.next_position;
|
||||
rb.update_colliders_positions(colliders);
|
||||
|
||||
for handle in &rb.colliders {
|
||||
let collider = colliders.get_mut_internal(*handle).unwrap();
|
||||
collider.position = rb.position * collider.delta;
|
||||
}
|
||||
});
|
||||
|
||||
bodies.modified_inactive_set.clear();
|
||||
_prediction_distance: Real,
|
||||
_broad_phase: &mut BroadPhase,
|
||||
_narrow_phase: &mut NarrowPhase,
|
||||
_islands: &mut IslandManager,
|
||||
_bodies: &mut Bodies,
|
||||
_colliders: &mut Colliders,
|
||||
_hooks: &dyn PhysicsHooks<Bodies, Colliders>,
|
||||
_events: &dyn EventHandler,
|
||||
) where
|
||||
Bodies: ComponentSetMut<RigidBodyIds>
|
||||
+ ComponentSetMut<RigidBodyActivation>
|
||||
+ ComponentSet<RigidBodyColliders>
|
||||
+ ComponentSetMut<RigidBodyVelocity>
|
||||
+ ComponentSet<RigidBodyDominance>
|
||||
+ ComponentSet<RigidBodyType>,
|
||||
Colliders: ComponentSetMut<ColliderShape>,
|
||||
{
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user