This is a migration guide for the physx
crate from the version (0.16.*) that was wrapping PhysX SDK 4.1, and the version (0.17) that transition to PhysX SDK 5.1.3. (see [PR#183] for the PR that actually made a bulk of the transition)
See the physx-sys
migration guide for more in depth information on the FFI API changes.
Note that there is a migration guide from NVidia for the C++ code here.
All enums are now re-exported from physx-sys
as the C++ enums are now both bound as normal Rust enums with the appropriately sized integer representation, and all of the enum variants are now named in UpperCamelCase
to make them pleasant to use directly in Rust.
-#[bitflags]
-#[derive(Debug, Copy, Clone)]
-#[repr(u8)]
-pub enum ActorFlag {
- Visualization = 1,
- DisableGravity = 2,
- SendSleepNotifies = 4,
- DisableSimulation = 8,
-}
-impl From<ActorFlag> for PxActorFlag::Enum {
- fn from(value: ActorFlag) -> Self {
- match value {
- ActorFlag::Visualization => 1,
- ActorFlag::DisableGravity => 2,
- ActorFlag::SendSleepNotifies => 4,
- ActorFlag::DisableSimulation => 8,
- }
- }
-}
-impl From<PxActorFlag::Enum> for ActorFlag {
- fn from(other: PxActorFlag::Enum) -> Self {
- match other {
- 1 => ActorFlag::Visualization,
- 2 => ActorFlag::DisableGravity,
- 4 => ActorFlag::SendSleepNotifies,
- 8 => ActorFlag::DisableSimulation,
- _ => unreachable!("InvalidActorFlag"),
- }
- }
-}
+pub use physx_sys::PxActorFlag as ActorFlag;
Previously the physx
crate used enumflags2
to create bitsets for the various enums that acted as flags in the API. These have all been removed as the physx-sys
crate now creates these automatically during binding generation, with a few exceptions (ie physx::foundation::ErrorCodes
, physx::physics::AggregateFilterHint
, and physx::shape::CollisionLayers
), and are directly reexported from the physx-sys crate with the same name as it had in the previous version of the physx
crate.
-pub type ActorFlags = BitFlags<ActorFlag>;
-
-impl PxFlags for ActorFlags {
- type Target = PxActorFlags;
-
- fn into_px(self) -> Self::Target {
- PxActorFlags { mBits: self.bits() }
- }
-
- fn from_px(flags: Self::Target) -> Self {
- BitFlags::from_bits_truncate(flags.mBits)
- }
-}
+pub use physx_sys::PxActorFlags as ActorFlags;
The API for bitflags
is largely the same as enumflags2
so this change should mostly be transparent.
This also means that the PxFlags
trait has been completely removed as it is no longer needed.
- The
PxCooking
structure has been marked as#[deprecated]
. It is deprecated in the underlying C++ SDK and we will replace it in a future version.
ArticulationBase
andArticulation
have been removed from PhysX, with some of their functionality moving intoArticulationReducedCoordinate
ArticulationMap
has been removedArticulationJointBase
andArticulationJoint
have been removed from PhysX, with some of their functionality moving intoArticulationJointReducedCoordinate
JointMap
has been removedArticulationLink::get_inbound_joint
has been temporarily removed
BvhStructure
has been renamed toBvh
, methods have that operate onBvh
have also been renamedPxBvhStructureDesc
has been renamed toPxBVHDesc