feat: switch to the new Bvh from parry for the broad-phase (#853)

* feat: switch to the new Bvh from parry for the broad-phase

* chore: cargo fmt + update testbed

* chore: remove the multi-grid SAP broad-phase

* fix soft-ccd handling in broad-phase

* Fix contact cleanup in broad-phase after collider removal

* chore: clippy fixes

* fix CCD regression

* chore: update changelog

* fix build with the parallel feature enabled

* chore: remove the now useless broad-phase proxy index from colliders

* fix tests
This commit is contained in:
Sébastien Crozet
2025-07-11 22:36:40 +02:00
committed by GitHub
parent 86a257d4f1
commit 95bd6fcfeb
212 changed files with 2140 additions and 3953 deletions

View File

@@ -1,5 +1,5 @@
use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
use rapier3d::prelude::*;
#[derive(serde::Deserialize)]
struct PhysicsState {
@@ -15,38 +15,52 @@ struct PhysicsState {
}
pub fn init_world(testbed: &mut Testbed) {
/*
* Set up the testbed.
*/
let path = "state.bin";
let bytes = match std::fs::read(path) {
// Deserialize
let setting = testbed.example_settings_mut();
let frame_id = setting.get_or_set_u32("frame", 0, 0..=1400);
let frame_dirs = "/Users/sebcrozet/work/hytopia/sdk/examples/bug-demo";
let path = format!("{frame_dirs}/snapshot{frame_id}.bincode");
let bytes = match std::fs::read(&path) {
Ok(bytes) => bytes,
Err(err) => {
println!(
"Failed to open the serialzed scene file {:?}: {}",
path, err
);
println!("Failed to open the serialized scene file {path:?}: {err}");
return;
}
};
match bincode::deserialize(&bytes) {
Ok(state) => {
let state: PhysicsState = state;
println!("World state deserialized successfully:");
println!("\tgravity: {:?}", state.gravity);
println!(
"\tintegration parameters: {:?}",
state.integration_parameters
);
println!("\tbodies: {:?}", state.bodies.len());
println!("\tcolliders: {:?}", state.colliders.len());
println!("\timpulse_joints: {:?}", state.impulse_joints.len());
for (_, rb) in state.bodies.iter() {
if rb.linvel().norm() != 0.0 {
println!("\tlinvel: {:?}", rb.linvel());
}
}
testbed.set_world(
state.bodies,
state.colliders,
state.impulse_joints,
state.multibody_joints,
);
testbed.harness_mut().physics.islands = state.islands;
testbed.harness_mut().physics.broad_phase = state.broad_phase;
testbed.harness_mut().physics.broad_phase = Box::new(state.broad_phase);
testbed.harness_mut().physics.narrow_phase = state.narrow_phase;
testbed.harness_mut().physics.integration_parameters = state.integration_parameters;
testbed.harness_mut().physics.gravity = state.gravity;
testbed.set_graphics_shift(vector![-541.0, -6377257.0, -61.0]);
testbed.look_at(point![10.0, 10.0, 10.0], point![0.0, 0.0, 0.0]);
}
Err(err) => println!("Failed to deserialize the world state: {}", err),
Err(err) => println!("Failed to deserialize the world state: {err}"),
}
}