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<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.