pub mod type_bridge;
use bevy::prelude::*;
use physx::prelude::*;
use physx_sys::PxBase_getConcreteType;
use crate::types::*;
pub unsafe fn get_actor_entity_from_ptr(actor: *const physx_sys::PxRigidActor) -> Entity {
let actor_type = ConcreteType::from(unsafe { PxBase_getConcreteType(actor as *const _) });
match actor_type {
ConcreteType::RigidDynamic => {
let actor: &PxRigidDynamic = unsafe { &*(actor as *const _) };
let entity = *actor.get_user_data();
entity
}
ConcreteType::RigidStatic => {
let actor: &PxRigidStatic = unsafe { &*(actor as *const _) };
let entity = *actor.get_user_data();
entity
}
ConcreteType::ArticulationLink => {
let actor: &PxArticulationLink = unsafe { &*(actor as *const _) };
let entity = *actor.get_user_data();
entity
}
_ => unreachable!()
}
}
pub unsafe fn get_shape_entity_from_ptr(shape: *const physx_sys::PxShape) -> Entity {
let shape = &*(shape as *const PxShape);
*shape.get_user_data()
}