pub struct BoxShape {
pub half_extents: Vec3,
}Expand description
An axis-aligned box defined by half-extents.
Fields§
§half_extents: Vec3Half-extents along each axis.
Implementations§
Source§impl BoxShape
impl BoxShape
Sourcepub fn volume_explicit(&self) -> Real
pub fn volume_explicit(&self) -> Real
Volume: (2hx)(2hy)(2hz).
Sourcepub fn surface_area(&self) -> Real
pub fn surface_area(&self) -> Real
Surface area: 2*(2hx2hy + 2hy2hz + 2hx*2hz).
Sourcepub fn inertia_tensor_array(&self, mass: f64) -> [[f64; 3]; 3]
pub fn inertia_tensor_array(&self, mass: f64) -> [[f64; 3]; 3]
Inertia tensor as [[f64;3\];3] row-major. Diagonal: m/12*(b²+c², a²+c², a²+b²) where a,b,c are full side lengths.
Sourcepub fn ray_cast_array(
&self,
origin: [f64; 3],
direction: [f64; 3],
max_toi: f64,
) -> Option<(f64, [f64; 3])>
pub fn ray_cast_array( &self, origin: [f64; 3], direction: [f64; 3], max_toi: f64, ) -> Option<(f64, [f64; 3])>
Ray cast returning (t, normal) as plain arrays (slab method).
Sourcepub fn support(&self, direction: [f64; 3]) -> [f64; 3]
pub fn support(&self, direction: [f64; 3]) -> [f64; 3]
GJK support function: farthest point in direction (componentwise sign).
Sourcepub fn vertex_list(&self) -> [[f64; 3]; 8]
pub fn vertex_list(&self) -> [[f64; 3]; 8]
All 8 vertices of the box.
Sourcepub fn face_normals() -> [[f64; 3]; 6]
pub fn face_normals() -> [[f64; 3]; 6]
Returns the 6 face normals of the box (axis-aligned, outward).
Sourcepub fn edge_list() -> [(usize, usize); 12]
pub fn edge_list() -> [(usize, usize); 12]
Returns the 12 edges of the box as pairs of vertex indices into vertex_list().
Sourcepub fn face_vertex_indices() -> [[usize; 4]; 6]
pub fn face_vertex_indices() -> [[usize; 4]; 6]
Returns the 6 faces as groups of 4 vertex indices (into vertex_list()).
Each face’s vertices are in counter-clockwise order from outside.
Sourcepub fn face_areas(&self) -> [f64; 6]
pub fn face_areas(&self) -> [f64; 6]
Area of each face: returns [+X, -X, +Y, -Y, +Z, -Z].
Sourcepub fn closest_point(&self, p: [f64; 3]) -> [f64; 3]
pub fn closest_point(&self, p: [f64; 3]) -> [f64; 3]
Closest point on (or inside) the box to point p.
Sourcepub fn contains_point(&self, p: [f64; 3]) -> bool
pub fn contains_point(&self, p: [f64; 3]) -> bool
Returns true if p is inside (or on the surface of) the box.
Sourcepub fn signed_distance(&self, p: [f64; 3]) -> f64
pub fn signed_distance(&self, p: [f64; 3]) -> f64
Signed distance from a point to the box surface. Negative if inside, positive if outside.
Sourcepub fn clip_segment(&self, a: [f64; 3], b: [f64; 3]) -> Option<(f64, f64)>
pub fn clip_segment(&self, a: [f64; 3], b: [f64; 3]) -> Option<(f64, f64)>
Clip a line segment (from a to b) against this box.
Returns Some((t_enter, t_exit)) where 0 <= t_enter <= t_exit <= 1,
or None if the segment doesn’t intersect the box.
Sourcepub fn classify_face(&self, p: [f64; 3]) -> usize
pub fn classify_face(&self, p: [f64; 3]) -> usize
Determine which face a surface point is on. Returns the face index (0=+X, 1=-X, 2=+Y, 3=-Y, 4=+Z, 5=-Z).
Sourcepub fn diagonal_length(&self) -> f64
pub fn diagonal_length(&self) -> f64
Diagonal length of the box: 2 * sqrt(hx² + hy² + hz²).
Sourcepub fn edge_lengths(&self) -> [f64; 3]
pub fn edge_lengths(&self) -> [f64; 3]
Edge lengths: [2hx, 2hy, 2*hz].
Trait Implementations§
Source§impl Shape for BoxShape
impl Shape for BoxShape
Source§fn bounding_box(&self) -> Aabb
fn bounding_box(&self) -> Aabb
Source§fn support_point(&self, direction: &Vec3) -> Vec3
fn support_point(&self, direction: &Vec3) -> Vec3
Source§fn center_of_mass(&self) -> Vec3
fn center_of_mass(&self) -> Vec3
Source§fn inertia_tensor(&self, mass: Real) -> Mat3
fn inertia_tensor(&self, mass: Real) -> Mat3
Source§fn ray_cast(
&self,
ray_origin: &Vec3,
ray_direction: &Vec3,
max_toi: Real,
) -> Option<RayHit>
fn ray_cast( &self, ray_origin: &Vec3, ray_direction: &Vec3, max_toi: Real, ) -> Option<RayHit>
max_toi.Source§fn mass_properties(&self, density: Real) -> MassProperties
fn mass_properties(&self, density: Real) -> MassProperties
Auto Trait Implementations§
impl Freeze for BoxShape
impl RefUnwindSafe for BoxShape
impl Send for BoxShape
impl Sync for BoxShape
impl Unpin for BoxShape
impl UnsafeUnpin for BoxShape
impl UnwindSafe for BoxShape
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.