pub struct BoundingBox {
pub width: f32,
pub height: f32,
pub position: Vector3<f32>,
}Expand description
Structure representing the bounding box
Fields§
§width: f32Width of the bounding box
height: f32Height of the bounding box
position: Vector3<f32>Position of the bounding box.
Use 0.0 for the third value and ignore it if the bounding box is in a 2D dimension
Implementations§
Source§impl BoundingBox
impl BoundingBox
Sourcepub fn new(width: f32, height: f32, position: Vector3<f32>) -> Self
pub fn new(width: f32, height: f32, position: Vector3<f32>) -> Self
Creates a new instance of BoundingBox
§Arguments
width: width of the bounding boxheight: height of the bounding boxposition:Vector3<f32>of the bounding box. Use0.0for the third (z) value if the box is in a 2D dimension
Sourcepub fn check_collision(&self, other: &BoundingBox) -> bool
pub fn check_collision(&self, other: &BoundingBox) -> bool
Checks if a collision happened between two bounding boxes
§Arguments
other: immutable reference to a box with which the collision should be checked
§Examples
use nalgebra::Vector3;
use fennel_physics::aabb::BoundingBox;
let first_box = BoundingBox::new(10.0, 10.0, Vector3::new(3.0, 4.0, 0.0)); // 2d plane
let second_box = BoundingBox::new(10.0, 10.0, Vector3::new(3.0, 6.0, 0.0));
assert!(first_box.check_collision(&second_box)); // boxes collideTrait Implementations§
Auto Trait Implementations§
impl Freeze for BoundingBox
impl RefUnwindSafe for BoundingBox
impl Send for BoundingBox
impl Sync for BoundingBox
impl Unpin for BoundingBox
impl UnsafeUnpin for BoundingBox
impl UnwindSafe for BoundingBox
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
Mutably borrows from an owned value. Read more
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.