2
0
Эх сурвалжийг харах

Replace AABB/Rect2(i) HasNo* methods in C#

Aaron Franke 3 жил өмнө
parent
commit
7c2f0a82f0

+ 37 - 33
modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs

@@ -132,15 +132,6 @@ namespace Godot
             return new AABB(begin, end - begin);
         }
 
-        /// <summary>
-        /// Returns the area of the <see cref="AABB"/>.
-        /// </summary>
-        /// <returns>The area.</returns>
-        public real_t GetArea()
-        {
-            return _size.x * _size.y * _size.z;
-        }
-
         /// <summary>
         /// Gets the position of one of the 8 endpoints of the <see cref="AABB"/>.
         /// </summary>
@@ -320,6 +311,15 @@ namespace Godot
                 dir.z > 0f ? -halfExtents.z : halfExtents.z);
         }
 
+        /// <summary>
+        /// Returns the volume of the <see cref="AABB"/>.
+        /// </summary>
+        /// <returns>The volume.</returns>
+        public real_t GetVolume()
+        {
+            return _size.x * _size.y * _size.z;
+        }
+
         /// <summary>
         /// Returns a copy of the <see cref="AABB"/> grown a given amount of units towards all the sides.
         /// </summary>
@@ -339,30 +339,6 @@ namespace Godot
             return res;
         }
 
-        /// <summary>
-        /// Returns <see langword="true"/> if the <see cref="AABB"/> is flat or empty,
-        /// or <see langword="false"/> otherwise.
-        /// </summary>
-        /// <returns>
-        /// A <see langword="bool"/> for whether or not the <see cref="AABB"/> has area.
-        /// </returns>
-        public bool HasNoArea()
-        {
-            return _size.x <= 0f || _size.y <= 0f || _size.z <= 0f;
-        }
-
-        /// <summary>
-        /// Returns <see langword="true"/> if the <see cref="AABB"/> has no surface (no size),
-        /// or <see langword="false"/> otherwise.
-        /// </summary>
-        /// <returns>
-        /// A <see langword="bool"/> for whether or not the <see cref="AABB"/> has area.
-        /// </returns>
-        public bool HasNoSurface()
-        {
-            return _size.x <= 0f && _size.y <= 0f && _size.z <= 0f;
-        }
-
         /// <summary>
         /// Returns <see langword="true"/> if the <see cref="AABB"/> contains a point,
         /// or <see langword="false"/> otherwise.
@@ -389,6 +365,34 @@ namespace Godot
             return true;
         }
 
+        /// <summary>
+        /// Returns <see langword="true"/> if the <see cref="AABB"/>
+        /// has a surface or a length, and <see langword="false"/>
+        /// if the <see cref="AABB"/> is empty (all components
+        /// of <see cref="Size"/> are zero or negative).
+        /// </summary>
+        /// <returns>
+        /// A <see langword="bool"/> for whether or not the <see cref="AABB"/> has surface.
+        /// </returns>
+        public bool HasSurface()
+        {
+            return _size.x > 0.0f || _size.y > 0.0f || _size.z > 0.0f;
+        }
+
+        /// <summary>
+        /// Returns <see langword="true"/> if the <see cref="AABB"/> has
+        /// area, and <see langword="false"/> if the <see cref="AABB"/>
+        /// is linear, empty, or has a negative <see cref="Size"/>.
+        /// See also <see cref="GetVolume"/>.
+        /// </summary>
+        /// <returns>
+        /// A <see langword="bool"/> for whether or not the <see cref="AABB"/> has volume.
+        /// </returns>
+        public bool HasVolume()
+        {
+            return _size.x > 0.0f && _size.y > 0.0f && _size.z > 0.0f;
+        }
+
         /// <summary>
         /// Returns the intersection of this <see cref="AABB"/> and <paramref name="with"/>.
         /// </summary>

+ 6 - 4
modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs

@@ -234,15 +234,17 @@ namespace Godot
         }
 
         /// <summary>
-        /// Returns <see langword="true"/> if the <see cref="Rect2"/> is flat or empty,
-        /// or <see langword="false"/> otherwise.
+        /// Returns <see langword="true"/> if the <see cref="Rect2"/> has
+        /// area, and <see langword="false"/> if the <see cref="Rect2"/>
+        /// is linear, empty, or has a negative <see cref="Size"/>.
+        /// See also <see cref="GetArea"/>.
         /// </summary>
         /// <returns>
         /// A <see langword="bool"/> for whether or not the <see cref="Rect2"/> has area.
         /// </returns>
-        public bool HasNoArea()
+        public bool HasArea()
         {
-            return _size.x <= 0 || _size.y <= 0;
+            return _size.x > 0.0f && _size.y > 0.0f;
         }
 
         /// <summary>

+ 6 - 4
modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs

@@ -236,15 +236,17 @@ namespace Godot
         }
 
         /// <summary>
-        /// Returns <see langword="true"/> if the <see cref="Rect2i"/> is flat or empty,
-        /// or <see langword="false"/> otherwise.
+        /// Returns <see langword="true"/> if the <see cref="Rect2i"/> has
+        /// area, and <see langword="false"/> if the <see cref="Rect2i"/>
+        /// is linear, empty, or has a negative <see cref="Size"/>.
+        /// See also <see cref="GetArea"/>.
         /// </summary>
         /// <returns>
         /// A <see langword="bool"/> for whether or not the <see cref="Rect2i"/> has area.
         /// </returns>
-        public bool HasNoArea()
+        public bool HasArea()
         {
-            return _size.x <= 0 || _size.y <= 0;
+            return _size.x > 0 && _size.y > 0;
         }
 
         /// <summary>