chore: update testbed to bevy 0.12

This commit is contained in:
Sébastien Crozet
2023-12-10 12:11:20 +01:00
parent 6246bb3ff6
commit 55373b3fa6
6 changed files with 92 additions and 104 deletions

View File

@@ -40,20 +40,20 @@ bincode = "1"
Inflector = "0.11" Inflector = "0.11"
md5 = "0.7" md5 = "0.7"
bevy_egui = "0.22" bevy_egui = "0.23"
bevy_ecs = "0.11" bevy_ecs = "0.12"
bevy_core_pipeline = "0.11" bevy_core_pipeline = "0.12"
bevy_pbr = "0.11" bevy_pbr = "0.12"
bevy_sprite = "0.11" bevy_sprite = "0.12"
#bevy_prototype_debug_lines = "0.7" #bevy_prototype_debug_lines = "0.7"
# Dependencies for native only. # Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.11", default-features = false, features = ["bevy_asset", "bevy_winit", "x11", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]} bevy = {version = "0.12", default-features = false, features = ["bevy_asset", "bevy_winit", "x11", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}
# Dependencies for WASM only. # Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.11", default-features = false, features = ["bevy_asset", "bevy_winit", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]} bevy = {version = "0.12", default-features = false, features = ["bevy_asset", "bevy_winit", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}
#bevy_webgl2 = "0.5" #bevy_webgl2 = "0.5"
[dependencies.rapier] [dependencies.rapier]

View File

@@ -40,20 +40,20 @@ bincode = "1"
Inflector = "0.11" Inflector = "0.11"
md5 = "0.7" md5 = "0.7"
bevy_egui = "0.22" bevy_egui = "0.23"
bevy_ecs = "0.11" bevy_ecs = "0.12"
bevy_core_pipeline = "0.11" bevy_core_pipeline = "0.12"
bevy_pbr = "0.11" bevy_pbr = "0.12"
bevy_sprite = "0.11" bevy_sprite = "0.12"
#bevy_prototype_debug_lines = "0.7" #bevy_prototype_debug_lines = "0.7"
# Dependencies for native only. # Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.11", default-features = false, features = ["bevy_sprite", "bevy_winit", "x11", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]} bevy = {version = "0.12", default-features = false, features = ["bevy_sprite", "bevy_winit", "x11", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}
# Dependencies for WASM only. # Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.11", default-features = false, features = ["bevy_sprite", "bevy_winit", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]} bevy = {version = "0.12", default-features = false, features = ["bevy_sprite", "bevy_winit", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}
#bevy_webgl2 = "0.5" #bevy_webgl2 = "0.5"
[dependencies.rapier] [dependencies.rapier]

View File

@@ -39,20 +39,20 @@ md5 = "0.7"
Inflector = "0.11" Inflector = "0.11"
serde = { version = "1", features = [ "derive" ] } serde = { version = "1", features = [ "derive" ] }
bevy_egui = "0.22" bevy_egui = "0.23"
bevy_ecs = "0.11" bevy_ecs = "0.12"
bevy_core_pipeline = "0.11" bevy_core_pipeline = "0.12"
bevy_pbr = "0.11" bevy_pbr = "0.12"
bevy_sprite = "0.11" bevy_sprite = "0.12"
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] } #bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }
# Dependencies for native only. # Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.11", default-features = false, features = ["bevy_winit", "x11", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]} bevy = {version = "0.12", default-features = false, features = ["bevy_winit", "x11", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}
# Dependencies for WASM only. # Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.11", default-features = false, features = ["bevy_winit", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]} bevy = {version = "0.12", default-features = false, features = ["bevy_winit", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}
#bevy_webgl2 = "0.5" #bevy_webgl2 = "0.5"
[dependencies.rapier] [dependencies.rapier]

View File

@@ -43,20 +43,20 @@ md5 = "0.7"
Inflector = "0.11" Inflector = "0.11"
serde = { version = "1", features = [ "derive" ] } serde = { version = "1", features = [ "derive" ] }
bevy_egui = "0.22" bevy_egui = "0.23"
bevy_ecs = "0.11" bevy_ecs = "0.12"
bevy_core_pipeline = "0.11" bevy_core_pipeline = "0.12"
bevy_pbr = "0.11" bevy_pbr = "0.12"
bevy_sprite = "0.11" bevy_sprite = "0.12"
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] } #bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }
# Dependencies for native only. # Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = {version = "0.11", default-features = false, features = ["bevy_winit", "x11", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]} bevy = {version = "0.12", default-features = false, features = ["bevy_winit", "x11", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}
# Dependencies for WASM only. # Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = {version = "0.11", default-features = false, features = ["bevy_winit", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]} bevy = {version = "0.12", default-features = false, features = ["bevy_winit", "tonemapping_luts", "ktx2", "zstd", "bevy_render", "bevy_pbr", "bevy_gizmos"]}
#bevy_webgl2 = "0.5" #bevy_webgl2 = "0.5"
[dependencies.rapier] [dependencies.rapier]

View File

@@ -64,7 +64,7 @@ impl OrbitCameraPlugin {
mut query: Query<(&mut OrbitCamera, &mut Transform, &mut Camera)>, mut query: Query<(&mut OrbitCamera, &mut Transform, &mut Camera)>,
) { ) {
let mut delta = Vec2::ZERO; let mut delta = Vec2::ZERO;
for event in mouse_motion_events.iter() { for event in mouse_motion_events.read() {
delta += event.delta; delta += event.delta;
} }
for (mut camera, transform, _) in query.iter_mut() { for (mut camera, transform, _) in query.iter_mut() {
@@ -97,7 +97,7 @@ impl OrbitCameraPlugin {
mut query: Query<&mut OrbitCamera, With<Camera>>, mut query: Query<&mut OrbitCamera, With<Camera>>,
) { ) {
let mut total = 0.0; let mut total = 0.0;
for event in mouse_wheel_events.iter() { for event in mouse_wheel_events.read() {
total += event.y total += event.y
* match event.unit { * match event.unit {
Line => 1.0, Line => 1.0,

View File

@@ -1,19 +1,18 @@
#![allow(dead_code)] #![allow(dead_code)]
use na::{Isometry3, Matrix4, Point3, Quaternion, Translation3, Unit, UnitQuaternion, Vector3}; use na::{Isometry3, Matrix4, Point3, Quaternion, Translation3, Unit, UnitQuaternion, Vector3};
use physx::articulation_joint_base::JointMap;
use physx::cooking::{ use physx::cooking::{
ConvexMeshCookingResult, PxConvexMeshDesc, PxCooking, PxCookingParams, PxHeightFieldDesc, ConvexMeshCookingResult, PxConvexMeshDesc, PxCookingParams, PxHeightFieldDesc,
PxTriangleMeshDesc, TriangleMeshCookingResult, PxTriangleMeshDesc, TriangleMeshCookingResult,
}; };
use physx::foundation::DefaultAllocator; use physx::foundation::DefaultAllocator;
use physx::prelude::*; use physx::prelude::*;
use physx::scene::FrictionType; use physx::scene::{FrictionType, SceneFlags};
use physx::traits::Class; use physx::traits::Class;
use physx_sys::PxFilterFlags;
use physx_sys::{ use physx_sys::{
FilterShaderCallbackInfo, PxArticulationLink_getInboundJoint, PxBitAndByte, PxConvexFlags, FilterShaderCallbackInfo, PxBitAndByte, PxConvexFlags, PxConvexMeshGeometryFlags,
PxConvexMeshGeometryFlags, PxHeightFieldSample, PxMeshGeometryFlags, PxMeshScale_new, PxHeightFieldSample, PxMeshGeometryFlags, PxMeshScale_new, PxRigidActor,
PxRigidActor,
}; };
use rapier::counters::Counters; use rapier::counters::Counters;
use rapier::dynamics::{ use rapier::dynamics::{
@@ -134,7 +133,6 @@ pub static FOUNDATION: std::cell::RefCell<PxPhysicsFoundation> = std::cell::RefC
pub struct PhysxWorld { pub struct PhysxWorld {
// physics: Physics, // physics: Physics,
// cooking: Cooking,
materials: Vec<Owner<PxMaterial>>, materials: Vec<Owner<PxMaterial>>,
shapes: Vec<Owner<PxShape>>, shapes: Vec<Owner<PxShape>>,
scene: Option<Owner<PxScene>>, scene: Option<Owner<PxScene>>,
@@ -173,7 +171,7 @@ impl PhysxWorld {
let mut scene_desc = SceneDescriptor { let mut scene_desc = SceneDescriptor {
gravity: gravity.into_physx(), gravity: gravity.into_physx(),
thread_count: num_threads as u32, thread_count: num_threads as u32,
broad_phase_type: BroadPhaseType::AutomaticBoxPruning, broad_phase_type: BroadPhaseType::Abp,
solver_type: SolverType::Pgs, solver_type: SolverType::Pgs,
friction_type, friction_type,
ccd_max_passes: integration_parameters.max_ccd_substeps as u32, ccd_max_passes: integration_parameters.max_ccd_substeps as u32,
@@ -185,17 +183,13 @@ impl PhysxWorld {
if ccd_enabled { if ccd_enabled {
scene_desc.simulation_filter_shader = scene_desc.simulation_filter_shader =
FilterShaderDescriptor::CallDefaultFirst(ccd_filter_shader); FilterShaderDescriptor::CallDefaultFirst(ccd_filter_shader);
scene_desc.flags.insert(SceneFlag::EnableCcd); scene_desc.flags.insert(SceneFlags::EnableCcd);
} }
let mut scene: Owner<PxScene> = physics.create(scene_desc).unwrap(); let mut scene: Owner<PxScene> = physics.create(scene_desc).unwrap();
let mut rapier2dynamic = HashMap::new(); let mut rapier2dynamic = HashMap::new();
let mut rapier2static = HashMap::new(); let mut rapier2static = HashMap::new();
let mut rapier2link = HashMap::new(); let mut rapier2link = HashMap::new();
let cooking_params =
PxCookingParams::new(&*physics).expect("Failed to init PhysX cooking.");
let mut cooking = PxCooking::new(physics.foundation_mut(), &cooking_params)
.expect("Failed to init PhysX cooking");
/* /*
* *
@@ -231,6 +225,7 @@ impl PhysxWorld {
/* /*
* Articulations. * Articulations.
*/ */
/*
for multibody in multibody_joints.multibodies() { for multibody in multibody_joints.multibodies() {
let mut articulation: Owner<PxArticulationReducedCoordinate> = let mut articulation: Owner<PxArticulationReducedCoordinate> =
physics.create_articulation_reduced_coordinate(()).unwrap(); physics.create_articulation_reduced_coordinate(()).unwrap();
@@ -251,12 +246,9 @@ impl PhysxWorld {
.unwrap(); .unwrap();
// TODO: there is no get_inbound_joint_mut? // TODO: there is no get_inbound_joint_mut?
if let Some(px_inbound_joint) = unsafe { if let Some(px_inbound_joint) =
(PxArticulationLink_getInboundJoint(px_link.as_ptr()) unsafe { (PxArticulationLink_getInboundJoint(px_link.as_ptr())).as_mut() }
as *mut physx_sys::PxArticulationJointBase {
as *mut JointMap)
.as_mut()
} {
let frame1 = link.joint().data.local_frame1.into_physx(); let frame1 = link.joint().data.local_frame1.into_physx();
let frame2 = link.joint().data.local_frame2.into_physx(); let frame2 = link.joint().data.local_frame2.into_physx();
@@ -301,6 +293,8 @@ impl PhysxWorld {
scene.add_articulation(articulation); scene.add_articulation(articulation);
} }
*/
/* /*
* *
* Colliders * Colliders
@@ -308,7 +302,7 @@ impl PhysxWorld {
*/ */
for (_, collider) in colliders.iter() { for (_, collider) in colliders.iter() {
if let Some((mut px_shape, px_material, collider_pos)) = if let Some((mut px_shape, px_material, collider_pos)) =
physx_collider_from_rapier_collider(&mut *physics, &mut cooking, &collider) physx_collider_from_rapier_collider(&mut *physics, &collider)
{ {
if let Some(parent_handle) = collider.parent() { if let Some(parent_handle) = collider.parent() {
let parent_body = &bodies[parent_handle]; let parent_body = &bodies[parent_handle];
@@ -360,7 +354,7 @@ impl PhysxWorld {
continue; continue;
}; };
physx_sys::PxRigidBodyExt_updateMassAndInertia_mut( physx_sys::PxRigidBodyExt_updateMassAndInertia(
actor, actor,
densities.as_ptr(), densities.as_ptr(),
densities.len() as u32, densities.len() as u32,
@@ -371,7 +365,7 @@ impl PhysxWorld {
if rb.is_ccd_enabled() { if rb.is_ccd_enabled() {
physx_sys::PxRigidBody_setRigidBodyFlag_mut( physx_sys::PxRigidBody_setRigidBodyFlag_mut(
actor, actor,
RigidBodyFlag::EnableCcd as u32, RigidBodyFlag::EnableCcd,
true, true,
); );
} }
@@ -449,64 +443,60 @@ impl PhysxWorld {
); );
let motion_x = if joint.1.data.limit_axes.contains(JointAxesMask::X) { let motion_x = if joint.1.data.limit_axes.contains(JointAxesMask::X) {
physx_sys::PxD6Motion::eLIMITED physx_sys::PxD6Motion::Limited
} else if !joint.1.data.locked_axes.contains(JointAxesMask::X) { } else if !joint.1.data.locked_axes.contains(JointAxesMask::X) {
physx_sys::PxD6Motion::eFREE physx_sys::PxD6Motion::Free
} else { } else {
physx_sys::PxD6Motion::eLOCKED physx_sys::PxD6Motion::Locked
}; };
let motion_y = if joint.1.data.limit_axes.contains(JointAxesMask::Y) { let motion_y = if joint.1.data.limit_axes.contains(JointAxesMask::Y) {
physx_sys::PxD6Motion::eLIMITED physx_sys::PxD6Motion::Limited
} else if !joint.1.data.locked_axes.contains(JointAxesMask::Y) { } else if !joint.1.data.locked_axes.contains(JointAxesMask::Y) {
physx_sys::PxD6Motion::eFREE physx_sys::PxD6Motion::Free
} else { } else {
physx_sys::PxD6Motion::eLOCKED physx_sys::PxD6Motion::Locked
}; };
let motion_z = if joint.1.data.limit_axes.contains(JointAxesMask::Z) { let motion_z = if joint.1.data.limit_axes.contains(JointAxesMask::Z) {
physx_sys::PxD6Motion::eLIMITED physx_sys::PxD6Motion::Limited
} else if !joint.1.data.locked_axes.contains(JointAxesMask::Z) { } else if !joint.1.data.locked_axes.contains(JointAxesMask::Z) {
physx_sys::PxD6Motion::eFREE physx_sys::PxD6Motion::Free
} else { } else {
physx_sys::PxD6Motion::eLOCKED physx_sys::PxD6Motion::Locked
}; };
let motion_ax = if joint.1.data.limit_axes.contains(JointAxesMask::ANG_X) { let motion_ax = if joint.1.data.limit_axes.contains(JointAxesMask::ANG_X) {
physx_sys::PxD6Motion::eLIMITED physx_sys::PxD6Motion::Limited
} else if !joint.1.data.locked_axes.contains(JointAxesMask::ANG_X) { } else if !joint.1.data.locked_axes.contains(JointAxesMask::ANG_X) {
physx_sys::PxD6Motion::eFREE physx_sys::PxD6Motion::Free
} else { } else {
physx_sys::PxD6Motion::eLOCKED physx_sys::PxD6Motion::Locked
}; };
let motion_ay = if joint.1.data.limit_axes.contains(JointAxesMask::ANG_Y) { let motion_ay = if joint.1.data.limit_axes.contains(JointAxesMask::ANG_Y) {
physx_sys::PxD6Motion::eLIMITED physx_sys::PxD6Motion::Limited
} else if !joint.1.data.locked_axes.contains(JointAxesMask::ANG_Y) { } else if !joint.1.data.locked_axes.contains(JointAxesMask::ANG_Y) {
physx_sys::PxD6Motion::eFREE physx_sys::PxD6Motion::Free
} else { } else {
physx_sys::PxD6Motion::eLOCKED physx_sys::PxD6Motion::Locked
}; };
let motion_az = if joint.1.data.limit_axes.contains(JointAxesMask::ANG_Z) { let motion_az = if joint.1.data.limit_axes.contains(JointAxesMask::ANG_Z) {
physx_sys::PxD6Motion::eLIMITED physx_sys::PxD6Motion::Limited
} else if !joint.1.data.locked_axes.contains(JointAxesMask::ANG_Z) { } else if !joint.1.data.locked_axes.contains(JointAxesMask::ANG_Z) {
physx_sys::PxD6Motion::eFREE physx_sys::PxD6Motion::Free
} else { } else {
physx_sys::PxD6Motion::eLOCKED physx_sys::PxD6Motion::Locked
}; };
physx_sys::PxD6Joint_setMotion_mut(px_joint, physx_sys::PxD6Axis::eX, motion_x); physx_sys::PxD6Joint_setMotion_mut(px_joint, physx_sys::PxD6Axis::X, motion_x);
physx_sys::PxD6Joint_setMotion_mut(px_joint, physx_sys::PxD6Axis::eY, motion_y); physx_sys::PxD6Joint_setMotion_mut(px_joint, physx_sys::PxD6Axis::Y, motion_y);
physx_sys::PxD6Joint_setMotion_mut(px_joint, physx_sys::PxD6Axis::eZ, motion_z); physx_sys::PxD6Joint_setMotion_mut(px_joint, physx_sys::PxD6Axis::Z, motion_z);
physx_sys::PxD6Joint_setMotion_mut(px_joint, physx_sys::PxD6Axis::Twist, motion_ax);
physx_sys::PxD6Joint_setMotion_mut( physx_sys::PxD6Joint_setMotion_mut(
px_joint, px_joint,
physx_sys::PxD6Axis::eTWIST, physx_sys::PxD6Axis::Swing1,
motion_ax,
);
physx_sys::PxD6Joint_setMotion_mut(
px_joint,
physx_sys::PxD6Axis::eSWING1,
motion_ay, motion_ay,
); );
physx_sys::PxD6Joint_setMotion_mut( physx_sys::PxD6Joint_setMotion_mut(
px_joint, px_joint,
physx_sys::PxD6Axis::eSWING2, physx_sys::PxD6Axis::Swing2,
motion_az, motion_az,
); );
} }
@@ -549,6 +539,7 @@ impl PhysxWorld {
sync_pos(handle, pos); sync_pos(handle, pos);
} }
/*
for articulation in self.scene.as_mut().unwrap().get_articulations() { for articulation in self.scene.as_mut().unwrap().get_articulations() {
if let Some(articulation) = articulation.as_articulation_reduced_coordinate() { if let Some(articulation) = articulation.as_articulation_reduced_coordinate() {
for link in articulation.get_links() { for link in articulation.get_links() {
@@ -558,20 +549,22 @@ impl PhysxWorld {
} }
} }
} }
*/
} }
} }
fn physx_collider_from_rapier_collider( fn physx_collider_from_rapier_collider(
physics: &mut PxPhysicsFoundation, physics: &mut PxPhysicsFoundation,
cooking: &PxCooking,
collider: &Collider, collider: &Collider,
) -> Option<(Owner<PxShape>, Owner<PxMaterial>, Isometry3<f32>)> { ) -> Option<(Owner<PxShape>, Owner<PxMaterial>, Isometry3<f32>)> {
let mut local_pose = collider.position_wrt_parent().copied().unwrap_or(na::one()); let mut local_pose = collider.position_wrt_parent().copied().unwrap_or(na::one());
let cooking_params = PxCookingParams::new(physics).unwrap();
let shape = collider.shape(); let shape = collider.shape();
let shape_flags = if collider.is_sensor() { let shape_flags = if collider.is_sensor() {
ShapeFlag::TriggerShape.into() ShapeFlags::TriggerShape
} else { } else {
ShapeFlag::SimulationShape.into() ShapeFlags::SimulationShape
}; };
let mut material = physics let mut material = physics
.create_material( .create_material(
@@ -618,8 +611,12 @@ fn physx_collider_from_rapier_collider(
.iter() .iter()
.map(|h| PxHeightFieldSample { .map(|h| PxHeightFieldSample {
height: (*h * Y_FACTOR) as i16, height: (*h * Y_FACTOR) as i16,
materialIndex0: PxBitAndByte { mData: 0 }, materialIndex0: PxBitAndByte {
materialIndex1: PxBitAndByte { mData: 0 }, structgen_pad0: [0; 1],
},
materialIndex1: PxBitAndByte {
structgen_pad0: [0; 1],
},
}) })
.collect(); .collect();
heightfield_desc = physx_sys::PxHeightFieldDesc_new(); heightfield_desc = physx_sys::PxHeightFieldDesc_new();
@@ -632,12 +629,10 @@ fn physx_collider_from_rapier_collider(
let heightfield_desc = PxHeightFieldDesc { let heightfield_desc = PxHeightFieldDesc {
obj: heightfield_desc, obj: heightfield_desc,
}; };
let heightfield = cooking.create_height_field(physics, &heightfield_desc); let heightfield = physx::cooking::create_height_field(physics, &heightfield_desc);
if let Some(mut heightfield) = heightfield { if let Some(mut heightfield) = heightfield {
let flags = PxMeshGeometryFlags { let flags = PxMeshGeometryFlags::DoubleSided;
mBits: physx_sys::PxMeshGeometryFlag::eDOUBLE_SIDED as u8,
};
let geometry = PxHeightFieldGeometry::new( let geometry = PxHeightFieldGeometry::new(
&mut *heightfield, &mut *heightfield,
flags, flags,
@@ -661,16 +656,14 @@ fn physx_collider_from_rapier_collider(
convex_desc.points.count = vertices.len() as u32; convex_desc.points.count = vertices.len() as u32;
convex_desc.points.stride = (3 * std::mem::size_of::<f32>()) as u32; convex_desc.points.stride = (3 * std::mem::size_of::<f32>()) as u32;
convex_desc.points.data = vertices.as_ptr() as *const std::ffi::c_void; convex_desc.points.data = vertices.as_ptr() as *const std::ffi::c_void;
convex_desc.flags = PxConvexFlags { convex_desc.flags = PxConvexFlags::ComputeConvex;
mBits: physx_sys::PxConvexFlag::eCOMPUTE_CONVEX as u16,
};
} }
let convex_desc = PxConvexMeshDesc { obj: convex_desc }; let convex_desc = PxConvexMeshDesc { obj: convex_desc };
let convex = cooking.create_convex_mesh(physics, &convex_desc); let convex = physx::cooking::create_convex_mesh(physics, &cooking_params, &convex_desc);
if let ConvexMeshCookingResult::Success(mut convex) = convex { if let ConvexMeshCookingResult::Success(mut convex) = convex {
let flags = PxConvexMeshGeometryFlags { mBits: 0 }; let flags = PxConvexMeshGeometryFlags::empty();
let scaling = unsafe { PxMeshScale_new() }; let scaling = unsafe { PxMeshScale_new() };
let geometry = PxConvexMeshGeometry::new(&mut convex, &scaling, flags); let geometry = PxConvexMeshGeometry::new(&mut convex, &scaling, flags);
physics.create_shape(&geometry, materials, true, shape_flags, ()) physics.create_shape(&geometry, materials, true, shape_flags, ())
@@ -696,13 +689,10 @@ fn physx_collider_from_rapier_collider(
} }
let mesh_desc = PxTriangleMeshDesc { obj: mesh_desc }; let mesh_desc = PxTriangleMeshDesc { obj: mesh_desc };
let trimesh = cooking.create_triangle_mesh(physics, &mesh_desc); let trimesh = physx::cooking::create_triangle_mesh(physics, &cooking_params, &mesh_desc);
if let TriangleMeshCookingResult::Success(mut trimesh) = trimesh { if let TriangleMeshCookingResult::Success(mut trimesh) = trimesh {
let flags = PxMeshGeometryFlags { let flags = PxMeshGeometryFlags::DoubleSided;
mBits: physx_sys::PxMeshGeometryFlag::eDOUBLE_SIDED as u8,
};
let scaling = unsafe { PxMeshScale_new() }; let scaling = unsafe { PxMeshScale_new() };
let geometry = PxTriangleMeshGeometry::new(&mut trimesh, &scaling, flags); let geometry = PxTriangleMeshGeometry::new(&mut trimesh, &scaling, flags);
physics.create_shape(&geometry, materials, true, shape_flags, ()) physics.create_shape(&geometry, materials, true, shape_flags, ())
@@ -724,7 +714,6 @@ type PxShape = physx::shape::PxShape<(), PxMaterial>;
type PxArticulationLink = physx::articulation_link::PxArticulationLink<RigidBodyHandle, PxShape>; type PxArticulationLink = physx::articulation_link::PxArticulationLink<RigidBodyHandle, PxShape>;
type PxRigidStatic = physx::rigid_static::PxRigidStatic<(), PxShape>; type PxRigidStatic = physx::rigid_static::PxRigidStatic<(), PxShape>;
type PxRigidDynamic = physx::rigid_dynamic::PxRigidDynamic<RigidBodyHandle, PxShape>; type PxRigidDynamic = physx::rigid_dynamic::PxRigidDynamic<RigidBodyHandle, PxShape>;
type PxArticulation = physx::articulation::PxArticulation<(), PxArticulationLink>;
type PxArticulationReducedCoordinate = type PxArticulationReducedCoordinate =
physx::articulation_reduced_coordinate::PxArticulationReducedCoordinate<(), PxArticulationLink>; physx::articulation_reduced_coordinate::PxArticulationReducedCoordinate<(), PxArticulationLink>;
type PxScene = physx::scene::PxScene< type PxScene = physx::scene::PxScene<
@@ -732,7 +721,6 @@ type PxScene = physx::scene::PxScene<
PxArticulationLink, PxArticulationLink,
PxRigidStatic, PxRigidStatic,
PxRigidDynamic, PxRigidDynamic,
PxArticulation,
PxArticulationReducedCoordinate, PxArticulationReducedCoordinate,
OnCollision, OnCollision,
OnTrigger, OnTrigger,
@@ -781,7 +769,7 @@ impl AdvanceCallback<PxArticulationLink, PxRigidDynamic> for OnAdvance {
} }
} }
unsafe extern "C" fn ccd_filter_shader(data: *mut FilterShaderCallbackInfo) -> u16 { unsafe extern "C" fn ccd_filter_shader(data: *mut FilterShaderCallbackInfo) -> PxFilterFlags {
(*(*data).pairFlags).mBits |= physx_sys::PxPairFlag::eDETECT_CCD_CONTACT as u16; (*(*data).pairFlags) |= physx_sys::PxPairFlags::DetectCcdContact;
0 PxFilterFlags::empty()
} }