pub struct CollisionChecker {
pub n_triangles: usize,
pub root: BVHNode,
}
Expand description
Collision checker using a Bounding Volume Hierarchy tree.
Fields§
§n_triangles: usize
§root: BVHNode
Implementations§
Source§impl CollisionChecker
impl CollisionChecker
Sourcepub fn new(tri_file: &Path) -> Self
pub fn new(tri_file: &Path) -> Self
Construct a new CollisionChecker
from a file of triangles or an existing list.
Sourcepub fn read_tri_file<P: AsRef<Path>>(
tri_file: P,
buffer_size: usize,
) -> Vec<Triangle>
pub fn read_tri_file<P: AsRef<Path>>( tri_file: P, buffer_size: usize, ) -> Vec<Triangle>
Read a .tri file containing triangles.
From https://github.com/pnxenopoulos/awpy/blob/main/awpy/visibility.py#L757
§Panics
Will panic if no file exists at the given path or if the file cannot be read.
Sourcepub fn build_bvh(triangles: Vec<Triangle>) -> BVHNode
pub fn build_bvh(triangles: Vec<Triangle>) -> BVHNode
Build a Bounding Volume Hierarchy tree from a list of triangles.
§Panics
Will panic if not triangles were provided or a triangle centroid coordinate comparison fails.
Sourcepub fn save_to_binary(&self, filename: &Path)
pub fn save_to_binary(&self, filename: &Path)
Save the loaded collision checker with the BVH to a file.
§Panics
Will panic if the file cannot be created or written to.
Sourcepub fn from_binary(filename: &Path) -> Self
pub fn from_binary(filename: &Path) -> Self
Load a struct instance from a JSON file
§Panics
Will panic if the file cannot be read or deserialized.
Sourcepub fn connection_unobstructed(&self, start: Position, end: Position) -> bool
pub fn connection_unobstructed(&self, start: Position, end: Position) -> bool
Check if the line segment between start and end is visible. Returns true if no triangle obstructs the view.
Trait Implementations§
Source§impl Clone for CollisionChecker
impl Clone for CollisionChecker
Source§fn clone(&self) -> CollisionChecker
fn clone(&self) -> CollisionChecker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CollisionChecker
impl Debug for CollisionChecker
Source§impl<'de> Deserialize<'de> for CollisionChecker
impl<'de> Deserialize<'de> for CollisionChecker
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for CollisionChecker
impl Display for CollisionChecker
Source§impl<'py> IntoPyObject<'py> for CollisionChecker
impl<'py> IntoPyObject<'py> for CollisionChecker
Source§type Target = CollisionChecker
type Target = CollisionChecker
Source§type Output = Bound<'py, <CollisionChecker as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <CollisionChecker as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for CollisionChecker
impl PyClass for CollisionChecker
Source§impl PyClassImpl for CollisionChecker
impl PyClassImpl for CollisionChecker
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§type ThreadChecker = SendablePyClass<CollisionChecker>
type ThreadChecker = SendablePyClass<CollisionChecker>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature<CollisionChecker> for PyClassImplCollector<CollisionChecker>
impl PyClassNewTextSignature<CollisionChecker> for PyClassImplCollector<CollisionChecker>
fn new_text_signature(self) -> Option<&'static str>
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a CollisionChecker
impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a CollisionChecker
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut CollisionChecker
impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut CollisionChecker
Source§impl PyMethods<CollisionChecker> for PyClassImplCollector<CollisionChecker>
impl PyMethods<CollisionChecker> for PyClassImplCollector<CollisionChecker>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for CollisionChecker
impl PyTypeInfo for CollisionChecker
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
Source§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
PyTypeInfo::type_object
PyTypeInfo::type_object
.Source§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type or a subclass of this type.Source§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
PyTypeInfo::is_type_of
PyTypeInfo::is_type_of
.Source§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type.Source§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
PyTypeInfo::is_exact_type_of
PyTypeInfo::is_exact_type_of
.Source§impl Serialize for CollisionChecker
impl Serialize for CollisionChecker
impl DerefToPyAny for CollisionChecker
Auto Trait Implementations§
impl Freeze for CollisionChecker
impl RefUnwindSafe for CollisionChecker
impl Send for CollisionChecker
impl Sync for CollisionChecker
impl Unpin for CollisionChecker
impl UnwindSafe for CollisionChecker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromPyObject<'_> for T
impl<T> FromPyObject<'_> for T
Source§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self
into an owned Python object, dropping type information.