aboutsummaryrefslogtreecommitdiff
path: root/src_testbed/box2d_backend.rs
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-03-26 18:16:27 +0100
committerCrozet Sébastien <developer@crozet.re>2021-03-26 18:16:27 +0100
commit97157c9423f3360c5e941b4065377689221014ae (patch)
tree707adf6e1feab0a9b7752d292baa161de790a8a1 /src_testbed/box2d_backend.rs
parent326469a1df9d8502903d88fe8e47a67e9e7c9edd (diff)
downloadrapier-97157c9423f3360c5e941b4065377689221014ae.tar.gz
rapier-97157c9423f3360c5e941b4065377689221014ae.tar.bz2
rapier-97157c9423f3360c5e941b4065377689221014ae.zip
First working version of non-linear CCD based on single-substep motion-clamping.
Diffstat (limited to 'src_testbed/box2d_backend.rs')
-rw-r--r--src_testbed/box2d_backend.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/src_testbed/box2d_backend.rs b/src_testbed/box2d_backend.rs
index 29fd4fa..df31c95 100644
--- a/src_testbed/box2d_backend.rs
+++ b/src_testbed/box2d_backend.rs
@@ -37,7 +37,7 @@ impl Box2dWorld {
joints: &JointSet,
) -> Self {
let mut world = b2::World::new(&na_vec_to_b2_vec(gravity));
- world.set_continuous_physics(false);
+ world.set_continuous_physics(bodies.iter().any(|b| b.1.is_ccd_enabled()));
let mut res = Box2dWorld {
world,
@@ -77,14 +77,11 @@ impl Box2dWorld {
angular_velocity: body.angvel(),
linear_damping,
angular_damping,
+ bullet: body.is_ccd_enabled(),
..b2::BodyDef::new()
};
let b2_handle = self.world.create_body(&def);
self.rapier2box2d.insert(handle, b2_handle);
-
- // Collider.
- let mut b2_body = self.world.body_mut(b2_handle);
- b2_body.set_bullet(false /* collider.is_ccd_enabled() */);
}
}
@@ -163,7 +160,7 @@ impl Box2dWorld {
fixture_def.restitution = collider.restitution;
fixture_def.friction = collider.friction;
- fixture_def.density = collider.density();
+ fixture_def.density = collider.density().unwrap_or(1.0);
fixture_def.is_sensor = collider.is_sensor();
fixture_def.filter = b2::Filter::new();
@@ -215,8 +212,6 @@ impl Box2dWorld {
}
pub fn step(&mut self, counters: &mut Counters, params: &IntegrationParameters) {
- // self.world.set_continuous_physics(world.integration_parameters.max_ccd_substeps != 0);
-
counters.step_started();
self.world.step(
params.dt,