Skip to content

Commit 54bf053

Browse files
committed
Aabb: replace has_area() -> has_surface()
1 parent c2da611 commit 54bf053

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

godot-core/src/builtin/aabb.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,15 @@ impl Aabb {
153153
self.contains_point(point)
154154
}
155155

156-
/// Returns `true` if the AABB has area, and `false` if the AABB is linear, empty, or has a negative size. See also `Aabb.area()`.
156+
/// Returns if this bounding box has a surface or a length, i.e. at least one component of [`Self::size`] is greater than 0.
157157
#[inline]
158+
pub fn has_surface(self) -> bool {
159+
(self.size.x > 0.0) || (self.size.y > 0.0) || (self.size.z > 0.0)
160+
}
161+
162+
/// Returns true if at least one of the size's components (X, Y, Z) is greater than 0.
163+
#[inline]
164+
#[deprecated = "Replaced with `has_surface()`, which has different semantics"]
158165
pub fn has_area(self) -> bool {
159166
((self.size.x > 0.0) as u8 + (self.size.y > 0.0) as u8 + (self.size.z > 0.0) as u8) >= 2
160167
}
@@ -226,7 +233,8 @@ impl Aabb {
226233
/// Returns the scalar length of the longest axis of the AABB.
227234
#[inline]
228235
pub fn longest_axis_size(self) -> real {
229-
self.size.x.max(self.size.y.max(self.size.z))
236+
let size = self.size;
237+
size.x.max(size.y).max(size.z)
230238
}
231239

232240
/// Returns the normalized shortest axis of the AABB.
@@ -253,6 +261,7 @@ impl Aabb {
253261

254262
/// Returns the support point in a given direction. This is useful for collision detection algorithms.
255263
#[inline]
264+
#[doc(alias = "get_support")]
256265
pub fn support(self, dir: Vector3) -> Vector3 {
257266
let half_extents = self.size * 0.5;
258267
let relative_center_point = self.position + half_extents;

godot-core/src/builtin/rect2.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ impl Rect2 {
177177
self.size.x > 0.0 && self.size.y > 0.0
178178
}
179179

180-
/// Returns `true` if the Rect2 contains a point. By convention, the right and bottom edges of the Rect2 are considered exclusive, so points on these edges are not included.
180+
/// Returns `true` if the Rect2 contains a point (excluding right/bottom edges).
181+
///
182+
/// By convention, the right and bottom edges of the Rect2 are considered exclusive, so points on these edges are not included.
181183
///
182184
/// Note: This method is not reliable for Rect2 with a negative size. Use `abs` to get a positive sized equivalent rectangle to check for contained points.
183185
#[inline]

0 commit comments

Comments
 (0)