use crate::{math::PxBounds3, owner::Owner, traits::Class};
use physx_sys::{
PxBVHStructure_getBounds,
PxBVHStructure_getNbBounds,
PxBase_release_mut,
};
#[repr(transparent)]
pub struct BvhStructure {
obj: physx_sys::PxBVHStructure,
}
crate::DeriveClassForNewType!(BvhStructure: PxBVHStructure, PxBase);
impl BvhStructure {
pub(crate) unsafe fn from_raw(ptr: *mut physx_sys::PxBVHStructure) -> Option<Owner<Self>> {
Owner::from_raw(ptr as *mut Self)
}
}
unsafe impl Send for BvhStructure {}
unsafe impl Sync for BvhStructure {}
impl Drop for BvhStructure {
fn drop(&mut self) {
unsafe { PxBase_release_mut(self.as_mut_ptr()) }
}
}
impl BvhStructure {
pub fn get_bounds(&self) -> &[PxBounds3] {
unsafe {
std::slice::from_raw_parts(
PxBVHStructure_getBounds(self.as_ptr()) as *const PxBounds3,
PxBVHStructure_getNbBounds(self.as_ptr()) as usize,
)
}
}
pub fn get_nb_bounds(&self) -> u32 {
unsafe { PxBVHStructure_getNbBounds(self.as_ptr()) }
}
}