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 contains_point(self, point: Vector3) -> bool
pub fn contains_point(self, point: Vector3) -> bool
Returns true
if the AABB contains a point (excluding right/bottom edge).
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_point(self, point: Vector3) -> bool
contains_point()
, for consistency with Rect2i
pub fn has_surface(self) -> bool
pub fn has_surface(self) -> bool
Returns if this bounding box has a surface or a length, i.e. at least one component of Self::size
is greater than 0.
pub fn has_area(self) -> bool
👎Deprecated: Replaced with has_surface()
, which has different semantics
pub fn has_area(self) -> bool
has_surface()
, which has different semanticsReturns true if at least one of the size’s components (X, Y, Z) is greater than 0.
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>
intersect()
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, ray_from: Vector3, ray_dir: Vector3) -> bool
pub fn intersects_ray(self, ray_from: Vector3, ray_dir: Vector3) -> bool
Returns true
if the given ray intersects with this AABB. Ray length is infinite.
Semantically equivalent to self.intersects_ray(ray_from, ray_dir).is_some()
; might be microscopically faster.
§Panics (Debug)
If self.size
is negative.
pub fn intersect_ray(
self,
ray_from: Vector3,
ray_dir: Vector3,
) -> Option<Vector3>
pub fn intersect_ray( self, ray_from: Vector3, ray_dir: Vector3, ) -> Option<Vector3>
Returns the point where the given (infinite) ray intersects with this AABB, or None
if there is no intersection.
§Panics (Debug)
If self.size
is negative, or if ray_dir
is zero. Note that this differs from Godot, which treats rays that degenerate to points as
intersecting if inside, and not if outside the AABB.
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. TODO(v0.3): make private, change to debug_assert().
Trait Implementations§
§impl Export for Aabb
impl Export for Aabb
§fn export_hint() -> PropertyHintInfo
fn export_hint() -> PropertyHintInfo
§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 ParamType for Aabb
impl ParamType for Aabb
§fn owned_to_arg<'v>(self) -> <Aabb as ParamType>::Arg<'v>
fn owned_to_arg<'v>(self) -> <Aabb as ParamType>::Arg<'v>
impl AsArg<T>
. Read more§impl ToGodot for Aabb
impl ToGodot for Aabb
§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.