Add explicit wake_up parameter to method setting the position and velocity of a rigid-body.

This commit is contained in:
Crozet Sébastien
2020-11-19 18:09:55 +01:00
parent 49fd861083
commit 5ce3606582
14 changed files with 154 additions and 48 deletions

View File

@@ -71,10 +71,10 @@ impl Box2dWorld {
let def = b2::BodyDef {
body_type,
position: na_vec_to_b2_vec(body.position.translation.vector),
angle: body.position.rotation.angle(),
linear_velocity: na_vec_to_b2_vec(body.linvel),
angular_velocity: body.angvel,
position: na_vec_to_b2_vec(body.position().translation.vector),
angle: body.position().rotation.angle(),
linear_velocity: na_vec_to_b2_vec(*body.linvel()),
angular_velocity: body.angvel(),
linear_damping,
angular_damping,
..b2::BodyDef::new()
@@ -223,7 +223,7 @@ impl Box2dWorld {
if let Some(pb2_handle) = self.rapier2box2d.get(&handle) {
let b2_body = self.world.body(*pb2_handle);
let pos = b2_transform_to_na_isometry(b2_body.transform().clone());
body.set_position(pos);
body.set_position(pos, false);
for coll_handle in body.colliders() {
let collider = &mut colliders[*coll_handle];

View File

@@ -46,7 +46,7 @@ impl NPhysicsWorld {
for (rapier_handle, rb) in bodies.iter() {
// let material = physics.create_material(rb.collider.friction, rb.collider.friction, 0.0);
let nphysics_rb = RigidBodyDesc::new().position(rb.position).build();
let nphysics_rb = RigidBodyDesc::new().position(*rb.position()).build();
let nphysics_rb_handle = nphysics_bodies.insert(nphysics_rb);
rapier2nphysics.insert(rapier_handle, nphysics_rb_handle);
@@ -161,7 +161,7 @@ impl NPhysicsWorld {
let mut rb = bodies.get_mut(*rapier_handle).unwrap();
let ra = self.bodies.rigid_body(*nphysics_handle).unwrap();
let pos = *ra.position();
rb.set_position(pos);
rb.set_position(pos, false);
for coll_handle in rb.colliders() {
let collider = &mut colliders[*coll_handle];

View File

@@ -154,7 +154,7 @@ impl PhysxWorld {
use physx::rigid_static::RigidStatic;
use physx::transform;
let pos = transform::gl_to_px_tf(rb.position.to_homogeneous().into_glam());
let pos = transform::gl_to_px_tf(rb.position().to_homogeneous().into_glam());
if rb.is_dynamic() {
let actor = unsafe {
physx_sys::PxPhysics_createRigidDynamic_mut(physics.get_raw_mut(), &pos)
@@ -406,7 +406,7 @@ impl PhysxWorld {
let ra = self.scene.get_rigid_actor(*physx_handle).unwrap();
let pos = ra.get_global_pose().into_na();
let iso = na::convert_unchecked(pos);
rb.set_position(iso);
rb.set_position(iso, false);
if rb.is_kinematic() {}

View File

@@ -414,7 +414,7 @@ impl Testbed {
{
if self.state.selected_backend == BOX2D_BACKEND {
self.box2d = Some(Box2dWorld::from_rapier(
self.gravity,
self.physics.gravity,
&self.physics.bodies,
&self.physics.colliders,
&self.physics.joints,
@@ -647,7 +647,7 @@ impl Testbed {
if self.state.selected_backend == BOX2D_BACKEND {
self.box2d.as_mut().unwrap().step(
&mut self.physics.pipeline.counters,
&self.integration_parameters,
&self.physics.integration_parameters,
);
self.box2d.as_mut().unwrap().sync(
&mut self.physics.bodies,