Struct Aabb
#[repr(C)]pub struct Aabb {
pub position: Vector3,
pub size: Vector3,
}
Expand description
Fields§
§position: Vector3
§size: Vector3
Implementations§
§impl Aabb
impl Aabb
pub const fn new(position: Vector3, size: Vector3) -> Aabb
pub const fn new(position: Vector3, size: Vector3) -> Aabb
Create a new Aabb
from a position and a size.
Godot equivalent: Aabb(Vector3 position, Vector3 size)
pub fn from_corners(position: Vector3, end: Vector3) -> Aabb
pub fn from_corners(position: Vector3, end: Vector3) -> Aabb
Create a new Aabb
with the first corner at position
and opposite corner at end
.
pub fn abs(self) -> Aabb
pub fn abs(self) -> Aabb
Returns an AABB with the same geometry, with most-negative corner as position
and non-negative size
.
pub fn encloses(self, b: Aabb) -> bool
pub fn encloses(self, b: Aabb) -> bool
Whether self
covers at least the entire area of b
(and possibly more).
pub fn merge(self, b: Aabb) -> Aabb
pub fn merge(self, b: Aabb) -> Aabb
Returns a larger AABB that contains this AABB and b
.
§Panics
If either self.size
or b.size
is negative.
pub fn center(self) -> Vector3
pub fn center(self) -> Vector3
Returns the center of the AABB, which is equal to position + (size / 2)
.
pub fn grow(self, amount: f32) -> Aabb
pub fn grow(self, amount: f32) -> Aabb
Returns a copy of the AABB grown by the specified amount
on all sides.
pub fn has_point(self, point: Vector3) -> bool
pub fn has_point(self, point: Vector3) -> bool
Returns true
if the AABB contains a point. By convention,
the right and bottom edges of the AABB are considered exclusive, so points on these edges are not included.
§Panics
If self.size
is negative.
pub fn has_area(self) -> bool
pub fn has_area(self) -> bool
Returns true
if the AABB has area, and false
if the AABB is linear, empty, or has a negative size. See also Aabb.area()
.
pub fn has_volume(self) -> bool
pub fn has_volume(self) -> bool
Returns true if the AABB has a volume, and false if the AABB is flat, linear, empty, or has a negative size.
pub fn intersection(self, b: Aabb) -> Option<Aabb>
pub fn intersection(self, b: Aabb) -> Option<Aabb>
pub fn is_finite(self) -> bool
pub fn is_finite(self) -> bool
Returns true
if this AABB is finite, by calling @GlobalScope.is_finite
on each component.
pub fn set_end(&mut self, end: Vector3)
pub fn set_end(&mut self, end: Vector3)
Set size based on desired end-point.
NOTE: This does not make the AABB absolute, and Aabb.abs()
should be called if the size becomes negative.
pub fn longest_axis(self) -> Option<Vector3>
pub fn longest_axis(self) -> Option<Vector3>
Returns the normalized longest axis of the AABB.
pub fn longest_axis_index(self) -> Option<Vector3Axis>
pub fn longest_axis_index(self) -> Option<Vector3Axis>
Returns the index of the longest axis of the AABB (according to Vector3’s AXIS_* constants).
pub fn longest_axis_size(self) -> f32
pub fn longest_axis_size(self) -> f32
Returns the scalar length of the longest axis of the AABB.
pub fn shortest_axis(self) -> Option<Vector3>
pub fn shortest_axis(self) -> Option<Vector3>
Returns the normalized shortest axis of the AABB.
pub fn shortest_axis_index(self) -> Option<Vector3Axis>
pub fn shortest_axis_index(self) -> Option<Vector3Axis>
Returns the index of the shortest axis of the AABB (according to Vector3::AXIS* enum).
pub fn shortest_axis_size(self) -> f32
pub fn shortest_axis_size(self) -> f32
Returns the scalar length of the shortest axis of the AABB.
pub fn support(self, dir: Vector3) -> Vector3
pub fn support(self, dir: Vector3) -> Vector3
Returns the support point in a given direction. This is useful for collision detection algorithms.
pub fn intersects(self, b: Aabb) -> bool
pub fn intersects(self, b: Aabb) -> bool
Checks whether two AABBs have at least one point in common.
Also returns true
if the AABBs only touch each other (share a point/edge/face).
See intersects_exclude_borders
if you want to return false
in that case.
Godot equivalent: AABB.intersects(AABB b, bool include_borders = true)
pub fn intersects_exclude_borders(self, b: Aabb) -> bool
pub fn intersects_exclude_borders(self, b: Aabb) -> bool
Checks whether two AABBs have at least one inner point in common (not on the borders).
Returns false
if the AABBs only touch each other (share a point/edge/face).
See intersects
if you want to return true
in that case.
Godot equivalent: AABB.intersects(AABB b, bool include_borders = false)
pub fn intersects_plane(self, plane: Plane) -> bool
pub fn intersects_plane(self, plane: Plane) -> bool
Returns true
if the AABB is on both sides of a plane.
pub fn intersects_ray(self, from: Vector3, dir: Vector3) -> bool
pub fn intersects_ray(self, from: Vector3, dir: Vector3) -> bool
Returns true
if the given ray intersects with this AABB. Ray length is infinite.
§Panics
If self.size
is negative.
pub fn intersects_segment(self, from: Vector3, to: Vector3) -> bool
pub fn intersects_segment(self, from: Vector3, to: Vector3) -> bool
Returns true
if the given ray intersects with this AABB. Segment length is finite.
§Panics
If self.size
is negative.
pub fn assert_nonnegative(self)
pub fn assert_nonnegative(self)
Assert that the size of the Aabb
is not negative.
Most functions will fail to give a correct result if the size is negative.
Trait Implementations§
§impl ArrayElement for Aabb
impl ArrayElement for Aabb
fn debug_validate_elements(_array: &Array<Self>) -> Result<(), ConvertError>
§impl Export for Aabb
impl Export for Aabb
§fn export_hint() -> PropertyHintInfo
fn export_hint() -> PropertyHintInfo
§fn as_node_class() -> Option<ClassName>
fn as_node_class() -> Option<ClassName>
§impl FromGodot for Aabb
impl FromGodot for Aabb
§fn try_from_godot(
via: <Aabb as GodotConvert>::Via,
) -> Result<Aabb, ConvertError>
fn try_from_godot( via: <Aabb as GodotConvert>::Via, ) -> Result<Aabb, ConvertError>
Err
on failure.§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
§fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Variant
, returning Err
on failure.§fn from_variant(variant: &Variant) -> Self
fn from_variant(variant: &Variant) -> Self
§impl Mul<Aabb> for Transform3D
impl Mul<Aabb> for Transform3D
§impl ToGodot for Aabb
impl ToGodot for Aabb
§type ToVia<'v> = <Aabb as GodotConvert>::Via
type ToVia<'v> = <Aabb as GodotConvert>::Via
to_godot()
, which differs from Via
for pass-by-reference types.§fn to_godot(&self) -> <Aabb as ToGodot>::ToVia<'_>
fn to_godot(&self) -> <Aabb as ToGodot>::ToVia<'_>
§fn to_variant(&self) -> Variant
fn to_variant(&self) -> Variant
§impl Var for Aabb
impl Var for Aabb
fn get_property(&self) -> <Aabb as GodotConvert>::Via
fn set_property(&mut self, value: <Aabb as GodotConvert>::Via)
§fn var_hint() -> PropertyHintInfo
fn var_hint() -> PropertyHintInfo
GodotType::property_info
, e.g. for enums/newtypes.impl Copy for Aabb
impl GodotType for Aabb
impl StructuralPartialEq for Aabb
Auto Trait Implementations§
impl Freeze for Aabb
impl RefUnwindSafe for Aabb
impl Send for Aabb
impl Sync for Aabb
impl Unpin for Aabb
impl UnwindSafe for Aabb
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)