feat: implement new "small-steps" solver + joint improvements
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
//! Physics pipeline structures.
|
||||
|
||||
use crate::counters::Counters;
|
||||
#[cfg(not(feature = "parallel"))]
|
||||
// #[cfg(not(feature = "parallel"))]
|
||||
use crate::dynamics::IslandSolver;
|
||||
#[cfg(feature = "parallel")]
|
||||
use crate::dynamics::JointGraphEdge;
|
||||
use crate::dynamics::{
|
||||
CCDSolver, ImpulseJointSet, IntegrationParameters, IslandManager, MultibodyJointSet,
|
||||
RigidBodyChanges, RigidBodyHandle, RigidBodyPosition, RigidBodyType,
|
||||
};
|
||||
#[cfg(feature = "parallel")]
|
||||
use crate::dynamics::{JointGraphEdge, ParallelIslandSolver as IslandSolver};
|
||||
use crate::geometry::{
|
||||
BroadPhase, BroadPhasePairEvent, ColliderChanges, ColliderHandle, ColliderPair,
|
||||
ContactManifoldIndex, NarrowPhase, TemporaryInteractionIndex,
|
||||
@@ -206,19 +206,14 @@ impl PhysicsPipeline {
|
||||
|
||||
self.counters.stages.update_time.resume();
|
||||
for handle in islands.active_dynamic_bodies() {
|
||||
// TODO: should that be moved to the solver (just like we moved
|
||||
// the multibody dynamics update) since it depends on dt?
|
||||
let rb = bodies.index_mut_internal(*handle);
|
||||
rb.mprops.update_world_mass_properties(&rb.pos.position);
|
||||
let effective_mass = rb.mprops.effective_mass();
|
||||
rb.forces
|
||||
.compute_effective_force_and_torque(&gravity, &effective_mass);
|
||||
}
|
||||
|
||||
for multibody in &mut multibody_joints.multibodies {
|
||||
multibody
|
||||
.1
|
||||
.update_dynamics(integration_parameters.dt, bodies);
|
||||
multibody.1.update_acceleration(bodies);
|
||||
}
|
||||
self.counters.stages.update_time.pause();
|
||||
|
||||
self.counters.stages.solver_time.resume();
|
||||
@@ -263,6 +258,10 @@ impl PhysicsPipeline {
|
||||
let manifold_indices = &self.manifold_indices[..];
|
||||
let joint_constraint_indices = &self.joint_constraint_indices[..];
|
||||
|
||||
// PERF: right now, we are only doing islands-based parallelism.
|
||||
// Intra-island parallelism (that hasn’t been ported to the new
|
||||
// solver yet) will be supported in the future.
|
||||
self.counters.solver.velocity_resolution_time.resume();
|
||||
rayon::scope(|scope| {
|
||||
enable_flush_to_zero!();
|
||||
|
||||
@@ -280,20 +279,22 @@ impl PhysicsPipeline {
|
||||
std::mem::transmute(multibody_joints.load(Ordering::Relaxed))
|
||||
};
|
||||
|
||||
let mut counters = Counters::new(false);
|
||||
solver.init_and_solve(
|
||||
scope,
|
||||
island_id,
|
||||
islands,
|
||||
&mut counters,
|
||||
integration_parameters,
|
||||
islands,
|
||||
bodies,
|
||||
manifolds,
|
||||
&manifold_indices[island_id],
|
||||
&mut manifolds[..],
|
||||
&self.manifold_indices[island_id],
|
||||
impulse_joints,
|
||||
&joint_constraint_indices[island_id],
|
||||
&self.joint_constraint_indices[island_id],
|
||||
multibody_joints,
|
||||
)
|
||||
});
|
||||
});
|
||||
self.counters.solver.velocity_resolution_time.pause();
|
||||
}
|
||||
|
||||
// Generate contact force events if needed.
|
||||
|
||||
Reference in New Issue
Block a user