summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/math/aabb.cpp2
-rw-r--r--core/math/aabb.h4
-rw-r--r--core/variant/variant_call.cpp4
-rw-r--r--doc/classes/AABB.xml20
-rw-r--r--servers/physics_3d/godot_collision_object_3d.cpp2
-rw-r--r--servers/physics_3d/godot_shape_3d.h14
-rw-r--r--tests/test_aabb.h30
7 files changed, 38 insertions, 38 deletions
diff --git a/core/math/aabb.cpp b/core/math/aabb.cpp
index 51a1309f0e..f3e78c0080 100644
--- a/core/math/aabb.cpp
+++ b/core/math/aabb.cpp
@@ -33,7 +33,7 @@
#include "core/string/print_string.h"
#include "core/variant/variant.h"
-real_t AABB::get_area() const {
+real_t AABB::get_volume() const {
return size.x * size.y * size.z;
}
diff --git a/core/math/aabb.h b/core/math/aabb.h
index c458e61475..02ce2501a0 100644
--- a/core/math/aabb.h
+++ b/core/math/aabb.h
@@ -46,8 +46,8 @@ public:
Vector3 position;
Vector3 size;
- real_t get_area() const; /// get area
- _FORCE_INLINE_ bool has_no_area() const {
+ real_t get_volume() const;
+ _FORCE_INLINE_ bool has_no_volume() const {
return (size.x <= 0 || size.y <= 0 || size.z <= 0);
}
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index 2b1d330942..f710a1267f 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1748,8 +1748,8 @@ static void _register_variant_builtin_methods() {
bind_method(AABB, abs, sarray(), varray());
bind_method(AABB, get_center, sarray(), varray());
- bind_method(AABB, get_area, sarray(), varray());
- bind_method(AABB, has_no_area, sarray(), varray());
+ bind_method(AABB, get_volume, sarray(), varray());
+ bind_method(AABB, has_no_volume, sarray(), varray());
bind_method(AABB, has_no_surface, sarray(), varray());
bind_method(AABB, has_point, sarray("point"), varray());
bind_method(AABB, is_equal_approx, sarray("aabb"), varray());
diff --git a/doc/classes/AABB.xml b/doc/classes/AABB.xml
index d7b7a309ad..f353cd19b8 100644
--- a/doc/classes/AABB.xml
+++ b/doc/classes/AABB.xml
@@ -57,12 +57,6 @@
Returns this [AABB] expanded to include a given point.
</description>
</method>
- <method name="get_area" qualifiers="const">
- <return type="float" />
- <description>
- Returns the volume of the [AABB].
- </description>
- </method>
<method name="get_center" qualifiers="const">
<return type="Vector3" />
<description>
@@ -119,6 +113,12 @@
Returns the support point in a given direction. This is useful for collision detection algorithms.
</description>
</method>
+ <method name="get_volume" qualifiers="const">
+ <return type="float" />
+ <description>
+ Returns the volume of the [AABB].
+ </description>
+ </method>
<method name="grow" qualifiers="const">
<return type="AABB" />
<argument index="0" name="by" type="float" />
@@ -126,16 +126,16 @@
Returns a copy of the [AABB] grown a given amount of units towards all the sides.
</description>
</method>
- <method name="has_no_area" qualifiers="const">
+ <method name="has_no_surface" qualifiers="const">
<return type="bool" />
<description>
- Returns [code]true[/code] if the [AABB] is flat or empty.
+ Returns [code]true[/code] if the [AABB] is empty.
</description>
</method>
- <method name="has_no_surface" qualifiers="const">
+ <method name="has_no_volume" qualifiers="const">
<return type="bool" />
<description>
- Returns [code]true[/code] if the [AABB] is empty.
+ Returns [code]true[/code] if the [AABB] is flat or empty.
</description>
</method>
<method name="has_point" qualifiers="const">
diff --git a/servers/physics_3d/godot_collision_object_3d.cpp b/servers/physics_3d/godot_collision_object_3d.cpp
index 80a3d18ce0..deb058b3ac 100644
--- a/servers/physics_3d/godot_collision_object_3d.cpp
+++ b/servers/physics_3d/godot_collision_object_3d.cpp
@@ -171,7 +171,7 @@ void GodotCollisionObject3D::_update_shapes() {
s.aabb_cache = shape_aabb;
Vector3 scale = xform.get_basis().get_scale();
- s.area_cache = s.shape->get_area() * scale.x * scale.y * scale.z;
+ s.area_cache = s.shape->get_volume() * scale.x * scale.y * scale.z;
if (s.bpid == 0) {
s.bpid = space->get_broadphase()->create(this, i, shape_aabb, _static);
diff --git a/servers/physics_3d/godot_shape_3d.h b/servers/physics_3d/godot_shape_3d.h
index 67497ba9b7..1bbcd903f7 100644
--- a/servers/physics_3d/godot_shape_3d.h
+++ b/servers/physics_3d/godot_shape_3d.h
@@ -64,7 +64,7 @@ public:
FEATURE_CIRCLE,
};
- virtual real_t get_area() const { return aabb.get_area(); }
+ virtual real_t get_volume() const { return aabb.get_volume(); }
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
_FORCE_INLINE_ RID get_self() const { return self; }
@@ -120,7 +120,7 @@ class GodotWorldBoundaryShape3D : public GodotShape3D {
public:
Plane get_plane() const;
- virtual real_t get_area() const override { return INFINITY; }
+ virtual real_t get_volume() const override { return INFINITY; }
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_WORLD_BOUNDARY; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const override;
@@ -147,7 +147,7 @@ public:
real_t get_length() const;
bool get_slide_on_slope() const;
- virtual real_t get_area() const override { return 0.0; }
+ virtual real_t get_volume() const override { return 0.0; }
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_SEPARATION_RAY; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const override;
@@ -173,7 +173,7 @@ class GodotSphereShape3D : public GodotShape3D {
public:
real_t get_radius() const;
- virtual real_t get_area() const override { return 4.0 / 3.0 * Math_PI * radius * radius * radius; }
+ virtual real_t get_volume() const override { return 4.0 / 3.0 * Math_PI * radius * radius * radius; }
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_SPHERE; }
@@ -198,7 +198,7 @@ class GodotBoxShape3D : public GodotShape3D {
public:
_FORCE_INLINE_ Vector3 get_half_extents() const { return half_extents; }
- virtual real_t get_area() const override { return 8 * half_extents.x * half_extents.y * half_extents.z; }
+ virtual real_t get_volume() const override { return 8 * half_extents.x * half_extents.y * half_extents.z; }
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_BOX; }
@@ -227,7 +227,7 @@ public:
_FORCE_INLINE_ real_t get_height() const { return height; }
_FORCE_INLINE_ real_t get_radius() const { return radius; }
- virtual real_t get_area() const override { return 4.0 / 3.0 * Math_PI * radius * radius * radius + (height - radius * 2.0) * Math_PI * radius * radius; }
+ virtual real_t get_volume() const override { return 4.0 / 3.0 * Math_PI * radius * radius * radius + (height - radius * 2.0) * Math_PI * radius * radius; }
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CAPSULE; }
@@ -256,7 +256,7 @@ public:
_FORCE_INLINE_ real_t get_height() const { return height; }
_FORCE_INLINE_ real_t get_radius() const { return radius; }
- virtual real_t get_area() const override { return height * Math_PI * radius * radius; }
+ virtual real_t get_volume() const override { return height * Math_PI * radius * radius; }
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CYLINDER; }
diff --git a/tests/test_aabb.h b/tests/test_aabb.h
index 2724d9481a..0312e185a1 100644
--- a/tests/test_aabb.h
+++ b/tests/test_aabb.h
@@ -90,38 +90,38 @@ TEST_CASE("[AABB] Basic setters") {
"set_size() should result in the expected AABB.");
}
-TEST_CASE("[AABB] Area getters") {
+TEST_CASE("[AABB] Volume getters") {
AABB aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 5, 6));
CHECK_MESSAGE(
- Math::is_equal_approx(aabb.get_area(), 120),
- "get_area() should return the expected value with positive size.");
+ Math::is_equal_approx(aabb.get_volume(), 120),
+ "get_volume() should return the expected value with positive size.");
CHECK_MESSAGE(
- !aabb.has_no_area(),
- "Non-empty volumetric AABB should have an area.");
+ !aabb.has_no_volume(),
+ "Non-empty volumetric AABB should have a volume.");
aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(-4, 5, 6));
CHECK_MESSAGE(
- Math::is_equal_approx(aabb.get_area(), -120),
- "get_area() should return the expected value with negative size (1 component).");
+ Math::is_equal_approx(aabb.get_volume(), -120),
+ "get_volume() should return the expected value with negative size (1 component).");
aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(-4, -5, 6));
CHECK_MESSAGE(
- Math::is_equal_approx(aabb.get_area(), 120),
- "get_area() should return the expected value with negative size (2 components).");
+ Math::is_equal_approx(aabb.get_volume(), 120),
+ "get_volume() should return the expected value with negative size (2 components).");
aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(-4, -5, -6));
CHECK_MESSAGE(
- Math::is_equal_approx(aabb.get_area(), -120),
- "get_area() should return the expected value with negative size (3 components).");
+ Math::is_equal_approx(aabb.get_volume(), -120),
+ "get_volume() should return the expected value with negative size (3 components).");
aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 0, 6));
CHECK_MESSAGE(
- aabb.has_no_area(),
- "Non-empty flat AABB should not have an area.");
+ aabb.has_no_volume(),
+ "Non-empty flat AABB should not have a volume.");
CHECK_MESSAGE(
- AABB().has_no_area(),
- "Empty AABB should not have an area.");
+ AABB().has_no_volume(),
+ "Empty AABB should not have a volume.");
}
TEST_CASE("[AABB] Surface getters") {