Browse Source

Merge pull request #63289 from Chaosus/code_style_tolerance

Rename `epsilon` to `tolerance` in the `Plane::has_point` method
Yuri Rubinsky 3 years ago
parent
commit
74be36e622

+ 3 - 3
core/math/plane.h

@@ -52,7 +52,7 @@ struct _NO_DISCARD_ Plane {
 
 
 	_FORCE_INLINE_ bool is_point_over(const Vector3 &p_point) const; ///< Point is over plane
 	_FORCE_INLINE_ bool is_point_over(const Vector3 &p_point) const; ///< Point is over plane
 	_FORCE_INLINE_ real_t distance_to(const Vector3 &p_point) const;
 	_FORCE_INLINE_ real_t distance_to(const Vector3 &p_point) const;
-	_FORCE_INLINE_ bool has_point(const Vector3 &p_point, real_t _epsilon = CMP_EPSILON) const;
+	_FORCE_INLINE_ bool has_point(const Vector3 &p_point, real_t p_tolerance = CMP_EPSILON) const;
 
 
 	/* intersections */
 	/* intersections */
 
 
@@ -97,10 +97,10 @@ real_t Plane::distance_to(const Vector3 &p_point) const {
 	return (normal.dot(p_point) - d);
 	return (normal.dot(p_point) - d);
 }
 }
 
 
-bool Plane::has_point(const Vector3 &p_point, real_t _epsilon) const {
+bool Plane::has_point(const Vector3 &p_point, real_t p_tolerance) const {
 	real_t dist = normal.dot(p_point) - d;
 	real_t dist = normal.dot(p_point) - d;
 	dist = ABS(dist);
 	dist = ABS(dist);
-	return (dist <= _epsilon);
+	return (dist <= p_tolerance);
 }
 }
 
 
 Plane::Plane(const Vector3 &p_normal, real_t p_d) :
 Plane::Plane(const Vector3 &p_normal, real_t p_d) :

+ 1 - 1
core/variant/variant_call.cpp

@@ -1732,7 +1732,7 @@ static void _register_variant_builtin_methods() {
 	bind_method(Plane, is_equal_approx, sarray("to_plane"), varray());
 	bind_method(Plane, is_equal_approx, sarray("to_plane"), varray());
 	bind_method(Plane, is_point_over, sarray("plane"), varray());
 	bind_method(Plane, is_point_over, sarray("plane"), varray());
 	bind_method(Plane, distance_to, sarray("point"), varray());
 	bind_method(Plane, distance_to, sarray("point"), varray());
-	bind_method(Plane, has_point, sarray("point", "epsilon"), varray(CMP_EPSILON));
+	bind_method(Plane, has_point, sarray("point", "tolerance"), varray(CMP_EPSILON));
 	bind_method(Plane, project, sarray("point"), varray());
 	bind_method(Plane, project, sarray("point"), varray());
 	bind_methodv(Plane, intersect_3, &Plane::intersect_3_bind, sarray("b", "c"), varray());
 	bind_methodv(Plane, intersect_3, &Plane::intersect_3_bind, sarray("b", "c"), varray());
 	bind_methodv(Plane, intersects_ray, &Plane::intersects_ray_bind, sarray("from", "dir"), varray());
 	bind_methodv(Plane, intersects_ray, &Plane::intersects_ray_bind, sarray("from", "dir"), varray());

+ 2 - 2
doc/classes/Plane.xml

@@ -83,9 +83,9 @@
 		<method name="has_point" qualifiers="const">
 		<method name="has_point" qualifiers="const">
 			<return type="bool" />
 			<return type="bool" />
 			<argument index="0" name="point" type="Vector3" />
 			<argument index="0" name="point" type="Vector3" />
-			<argument index="1" name="epsilon" type="float" default="1e-05" />
+			<argument index="1" name="tolerance" type="float" default="1e-05" />
 			<description>
 			<description>
-				Returns [code]true[/code] if [code]point[/code] is inside the plane. Comparison uses a custom minimum [code]epsilon[/code] threshold.
+				Returns [code]true[/code] if [code]point[/code] is inside the plane. Comparison uses a custom minimum [code]tolerance[/code] threshold.
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="intersect_3" qualifiers="const">
 		<method name="intersect_3" qualifiers="const">

+ 4 - 4
modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs

@@ -118,15 +118,15 @@ namespace Godot
 
 
         /// <summary>
         /// <summary>
         /// Returns <see langword="true"/> if point is inside the plane.
         /// Returns <see langword="true"/> if point is inside the plane.
-        /// Comparison uses a custom minimum epsilon threshold.
+        /// Comparison uses a custom minimum tolerance threshold.
         /// </summary>
         /// </summary>
         /// <param name="point">The point to check.</param>
         /// <param name="point">The point to check.</param>
-        /// <param name="epsilon">The tolerance threshold.</param>
+        /// <param name="tolerance">The tolerance threshold.</param>
         /// <returns>A <see langword="bool"/> for whether or not the plane has the point.</returns>
         /// <returns>A <see langword="bool"/> for whether or not the plane has the point.</returns>
-        public bool HasPoint(Vector3 point, real_t epsilon = Mathf.Epsilon)
+        public bool HasPoint(Vector3 point, real_t tolerance = Mathf.Epsilon)
         {
         {
             real_t dist = _normal.Dot(point) - D;
             real_t dist = _normal.Dot(point) - D;
-            return Mathf.Abs(dist) <= epsilon;
+            return Mathf.Abs(dist) <= tolerance;
         }
         }
 
 
         /// <summary>
         /// <summary>