Add prelude + use vectors for setting linvel/translation in builders
This commit is contained in:
@@ -220,23 +220,28 @@ impl PhysxWorld {
|
||||
if let Some((mut px_shape, px_material, collider_pos)) =
|
||||
physx_collider_from_rapier_collider(&mut *physics, &mut cooking, &collider)
|
||||
{
|
||||
let parent_body = &bodies[collider.parent()];
|
||||
if let Some(parent_handle) = collider.parent() {
|
||||
let parent_body = &bodies[parent_handle];
|
||||
|
||||
if !parent_body.is_dynamic() {
|
||||
let actor = rapier2static.get_mut(&collider.parent()).unwrap();
|
||||
actor.attach_shape(&mut px_shape);
|
||||
} else {
|
||||
let actor = rapier2dynamic.get_mut(&collider.parent()).unwrap();
|
||||
actor.attach_shape(&mut px_shape);
|
||||
if !parent_body.is_dynamic() {
|
||||
let actor = rapier2static.get_mut(&parent_handle).unwrap();
|
||||
actor.attach_shape(&mut px_shape);
|
||||
} else {
|
||||
let actor = rapier2dynamic.get_mut(&parent_handle).unwrap();
|
||||
actor.attach_shape(&mut px_shape);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
let pose = collider_pos.into_physx();
|
||||
physx_sys::PxShape_setLocalPose_mut(
|
||||
px_shape.as_mut_ptr(),
|
||||
&pose.into(),
|
||||
);
|
||||
}
|
||||
|
||||
shapes.push(px_shape);
|
||||
materials.push(px_material);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
let pose = collider_pos.into_physx();
|
||||
physx_sys::PxShape_setLocalPose_mut(px_shape.as_mut_ptr(), &pose.into());
|
||||
}
|
||||
|
||||
shapes.push(px_shape);
|
||||
materials.push(px_material);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,8 +459,8 @@ impl PhysxWorld {
|
||||
}
|
||||
}
|
||||
JointParams::FixedJoint(params) => {
|
||||
let frame1 = params.local_anchor1.into_physx().into();
|
||||
let frame2 = params.local_anchor2.into_physx().into();
|
||||
let frame1 = params.local_frame1.into_physx().into();
|
||||
let frame2 = params.local_frame2.into_physx().into();
|
||||
|
||||
physx_sys::phys_PxFixedJointCreate(
|
||||
physics.as_mut_ptr(),
|
||||
@@ -500,7 +505,9 @@ impl PhysxWorld {
|
||||
|
||||
for coll_handle in rb.colliders() {
|
||||
let collider = &mut colliders[*coll_handle];
|
||||
collider.set_position_debug(pos * collider.position_wrt_parent());
|
||||
collider.set_position(
|
||||
pos * collider.position_wrt_parent().copied().unwrap_or(na::one()),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -511,7 +518,7 @@ fn physx_collider_from_rapier_collider(
|
||||
cooking: &PxCooking,
|
||||
collider: &Collider,
|
||||
) -> Option<(Owner<PxShape>, Owner<PxMaterial>, Isometry3<f32>)> {
|
||||
let mut local_pose = *collider.position_wrt_parent();
|
||||
let mut local_pose = collider.position_wrt_parent().copied().unwrap_or(na::one());
|
||||
let shape = collider.shape();
|
||||
let shape_flags = if collider.is_sensor() {
|
||||
ShapeFlag::TriggerShape.into()
|
||||
|
||||
Reference in New Issue
Block a user