pub mod events;
pub mod raycast;
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 _) };
*actor.get_user_data()
}
ConcreteType::RigidStatic => {
let actor: &PxRigidStatic = unsafe { &*(actor as *const _) };
*actor.get_user_data()
}
ConcreteType::ArticulationLink => {
let actor: &PxArticulationLink = unsafe { &*(actor as *const _) };
*actor.get_user_data()
}
_ => unreachable!()
}
}
pub unsafe fn get_shape_entity_from_ptr(shape: *const physx_sys::PxShape) -> Entity {
unsafe {
let shape = &*(shape as *const PxShape);
*shape.get_user_data()
}
}