mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Replace AABB has_no_volume with has_volume
Also replace has_no_surface with has_surface
This commit is contained in:
parent
e7a0a97c0b
commit
817ae95667
@ -47,12 +47,12 @@ struct _NO_DISCARD_ AABB {
|
||||
Vector3 size;
|
||||
|
||||
real_t get_volume() const;
|
||||
_FORCE_INLINE_ bool has_no_volume() const {
|
||||
return (size.x <= 0 || size.y <= 0 || size.z <= 0);
|
||||
_FORCE_INLINE_ bool has_volume() const {
|
||||
return size.x > 0.0f && size.y > 0.0f && size.z > 0.0f;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ bool has_no_surface() const {
|
||||
return (size.x <= 0 && size.y <= 0 && size.z <= 0);
|
||||
_FORCE_INLINE_ bool has_surface() const {
|
||||
return size.x > 0.0f || size.y > 0.0f || size.z > 0.0f;
|
||||
}
|
||||
|
||||
const Vector3 &get_position() const { return position; }
|
||||
|
@ -1938,8 +1938,8 @@ static void _register_variant_builtin_methods() {
|
||||
bind_method(AABB, abs, sarray(), varray());
|
||||
bind_method(AABB, get_center, 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_volume, sarray(), varray());
|
||||
bind_method(AABB, has_surface, sarray(), varray());
|
||||
bind_method(AABB, has_point, sarray("point"), varray());
|
||||
bind_method(AABB, is_equal_approx, sarray("aabb"), varray());
|
||||
bind_method(AABB, intersects, sarray("with"), varray());
|
||||
|
@ -142,18 +142,6 @@
|
||||
Returns a copy of the [AABB] grown a given number of units towards all the sides.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_no_surface" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the [AABB] is empty.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_no_volume" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the [AABB] is flat or empty.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_point" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="point" type="Vector3" />
|
||||
@ -162,6 +150,18 @@
|
||||
[b]Note:[/b] This method is not reliable for [AABB] with a [i]negative size[/i]. Use [method abs] to get a positive sized equivalent [AABB] to check for contained points.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_surface" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the [AABB] has a surface or a length, and [code]false[/code] if the [AABB] is empty (all components of [member size] are zero or negative).
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_volume" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the [AABB] has a volume, and [code]false[/code] if the [AABB] is flat, empty, or has a negative [member size].
|
||||
</description>
|
||||
</method>
|
||||
<method name="intersection" qualifiers="const">
|
||||
<return type="AABB" />
|
||||
<param index="0" name="with" type="AABB" />
|
||||
|
@ -260,7 +260,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
|
||||
}
|
||||
for (int i = 0; i < p_surface.bone_aabbs.size(); i++) {
|
||||
const AABB &bone = p_surface.bone_aabbs[i];
|
||||
if (!bone.has_no_volume()) {
|
||||
if (bone.has_volume()) {
|
||||
mesh->bone_aabbs.write[i].merge_with(bone);
|
||||
}
|
||||
}
|
||||
|
@ -572,12 +572,8 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
|
||||
cfg.bmax[2] = bmax[2];
|
||||
|
||||
AABB baking_aabb = p_nav_mesh->get_filter_baking_aabb();
|
||||
|
||||
bool aabb_has_no_volume = baking_aabb.has_no_volume();
|
||||
|
||||
if (!aabb_has_no_volume) {
|
||||
if (baking_aabb.has_volume()) {
|
||||
Vector3 baking_aabb_offset = p_nav_mesh->get_filter_baking_aabb_offset();
|
||||
|
||||
cfg.bmin[0] = baking_aabb.position[0] + baking_aabb_offset.x;
|
||||
cfg.bmin[1] = baking_aabb.position[1] + baking_aabb_offset.y;
|
||||
cfg.bmin[2] = baking_aabb.position[2] + baking_aabb_offset.z;
|
||||
|
@ -425,7 +425,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface)
|
||||
}
|
||||
for (int i = 0; i < p_surface.bone_aabbs.size(); i++) {
|
||||
const AABB &bone = p_surface.bone_aabbs[i];
|
||||
if (!bone.has_no_volume()) {
|
||||
if (bone.has_volume()) {
|
||||
mesh->bone_aabbs.write[i].merge_with(bone);
|
||||
}
|
||||
}
|
||||
|
@ -1563,7 +1563,7 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
|
||||
}
|
||||
}
|
||||
|
||||
if (p_instance->aabb.has_no_surface()) {
|
||||
if (!p_instance->aabb.has_surface()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ TEST_CASE("[AABB] Volume getters") {
|
||||
Math::is_equal_approx(aabb.get_volume(), 120),
|
||||
"get_volume() should return the expected value with positive size.");
|
||||
CHECK_MESSAGE(
|
||||
!aabb.has_no_volume(),
|
||||
aabb.has_volume(),
|
||||
"Non-empty volumetric AABB should have a volume.");
|
||||
|
||||
aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(-4, 5, 6));
|
||||
@ -114,27 +114,32 @@ TEST_CASE("[AABB] Volume getters") {
|
||||
|
||||
aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 0, 6));
|
||||
CHECK_MESSAGE(
|
||||
aabb.has_no_volume(),
|
||||
!aabb.has_volume(),
|
||||
"Non-empty flat AABB should not have a volume.");
|
||||
|
||||
CHECK_MESSAGE(
|
||||
AABB().has_no_volume(),
|
||||
!AABB().has_volume(),
|
||||
"Empty AABB should not have a volume.");
|
||||
}
|
||||
|
||||
TEST_CASE("[AABB] Surface getters") {
|
||||
AABB aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 5, 6));
|
||||
CHECK_MESSAGE(
|
||||
!aabb.has_no_surface(),
|
||||
aabb.has_surface(),
|
||||
"Non-empty volumetric AABB should have an surface.");
|
||||
|
||||
aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 0, 6));
|
||||
CHECK_MESSAGE(
|
||||
!aabb.has_no_surface(),
|
||||
aabb.has_surface(),
|
||||
"Non-empty flat AABB should have a surface.");
|
||||
|
||||
aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 0, 0));
|
||||
CHECK_MESSAGE(
|
||||
AABB().has_no_surface(),
|
||||
aabb.has_surface(),
|
||||
"Non-empty linear AABB should have a surface.");
|
||||
|
||||
CHECK_MESSAGE(
|
||||
!AABB().has_surface(),
|
||||
"Empty AABB should not have an surface.");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user