aboutsummaryrefslogtreecommitdiff
path: root/src_testbed/box2d_backend.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2021-04-01 11:00:27 +0200
committerGitHub <noreply@github.com>2021-04-01 11:00:27 +0200
commitf8536e73fc092da5ded5c793d513c59296949aff (patch)
tree50af9e4312b22ea2c1cabc0e6d80dc73e59b3104 /src_testbed/box2d_backend.rs
parent4b637c66ca40695f97f1ebdc38965e0d83ac5934 (diff)
parentcc3f16eb85f23a86ddd9d182d967cb12acc32354 (diff)
downloadrapier-f8536e73fc092da5ded5c793d513c59296949aff.tar.gz
rapier-f8536e73fc092da5ded5c793d513c59296949aff.tar.bz2
rapier-f8536e73fc092da5ded5c793d513c59296949aff.zip
Merge pull request #157 from dimforge/ccd
Implement Continuous Collision Detection
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,