소스 검색

Merge pull request #71456 from raulsntos/dotnet/sync-plane

C#: Sync `Plane` with Core
Rémi Verschelde 2 년 전
부모
커밋
88c81bfbe5
2개의 변경된 파일30개의 추가작업 그리고 23개의 파일을 삭제
  1. 4 1
      doc/classes/Plane.xml
  2. 26 22
      modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs

+ 4 - 1
doc/classes/Plane.xml

@@ -38,6 +38,7 @@
 			<param index="0" name="normal" type="Vector3" />
 			<description>
 				Creates a plane from the normal vector. The plane will intersect the origin.
+				The [param normal] of the plane must be a unit vector.
 			</description>
 		</constructor>
 		<constructor name="Plane">
@@ -46,6 +47,7 @@
 			<param index="1" name="d" type="float" />
 			<description>
 				Creates a plane from the normal vector and the plane's distance from the origin.
+				The [param normal] of the plane must be a unit vector.
 			</description>
 		</constructor>
 		<constructor name="Plane">
@@ -54,6 +56,7 @@
 			<param index="1" name="point" type="Vector3" />
 			<description>
 				Creates a plane from the normal vector and a point on the plane.
+				The [param normal] of the plane must be a unit vector.
 			</description>
 		</constructor>
 		<constructor name="Plane">
@@ -152,7 +155,7 @@
 			In the scalar equation of the plane [code]ax + by + cz = d[/code], this is [code]d[/code], while the [code](a, b, c)[/code] coordinates are represented by the [member normal] property.
 		</member>
 		<member name="normal" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)">
-			The normal of the plane, which must be normalized.
+			The normal of the plane, which must be a unit vector.
 			In the scalar equation of the plane [code]ax + by + cz = d[/code], this is the vector [code](a, b, c)[/code], where [code]d[/code] is the [member d] property.
 		</member>
 		<member name="x" type="float" setter="" getter="" default="0.0">

+ 26 - 22
modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs

@@ -15,7 +15,7 @@ namespace Godot
         private Vector3 _normal;
 
         /// <summary>
-        /// The normal of the plane, which must be normalized.
+        /// The normal of the plane, which must be a unit vector.
         /// In the scalar equation of the plane <c>ax + by + cz = d</c>, this is
         /// the vector <c>(a, b, c)</c>, where <c>d</c> is the <see cref="D"/> property.
         /// </summary>
@@ -84,23 +84,6 @@ namespace Godot
         /// <value>The plane's distance from the origin.</value>
         public real_t D { get; set; }
 
-        /// <summary>
-        /// The center of the plane, the point where the normal line intersects the plane.
-        /// </summary>
-        /// <value>Equivalent to <see cref="Normal"/> multiplied by <see cref="D"/>.</value>
-        public Vector3 Center
-        {
-            readonly get
-            {
-                return _normal * D;
-            }
-            set
-            {
-                _normal = value.Normalized();
-                D = value.Length();
-            }
-        }
-
         /// <summary>
         /// Returns the shortest distance from this plane to the position <paramref name="point"/>.
         /// </summary>
@@ -111,6 +94,16 @@ namespace Godot
             return _normal.Dot(point) - D;
         }
 
+        /// <summary>
+        /// Returns the center of the plane, the point on the plane closest to the origin.
+        /// The point where the normal line going through the origin intersects the plane.
+        /// </summary>
+        /// <value>Equivalent to <see cref="Normal"/> multiplied by <see cref="D"/>.</value>
+        public readonly Vector3 GetCenter()
+        {
+            return _normal * D;
+        }
+
         /// <summary>
         /// Returns <see langword="true"/> if point is inside the plane.
         /// Comparison uses a custom minimum tolerance threshold.
@@ -155,7 +148,7 @@ namespace Godot
         /// <param name="from">The start of the ray.</param>
         /// <param name="dir">The direction of the ray, normalized.</param>
         /// <returns>The intersection, or <see langword="null"/> if none is found.</returns>
-        public readonly Vector3? IntersectRay(Vector3 from, Vector3 dir)
+        public readonly Vector3? IntersectsRay(Vector3 from, Vector3 dir)
         {
             real_t den = _normal.Dot(dir);
 
@@ -183,7 +176,7 @@ namespace Godot
         /// <param name="begin">The start of the line segment.</param>
         /// <param name="end">The end of the line segment.</param>
         /// <returns>The intersection, or <see langword="null"/> if none is found.</returns>
-        public readonly Vector3? IntersectSegment(Vector3 begin, Vector3 end)
+        public readonly Vector3? IntersectsSegment(Vector3 begin, Vector3 end)
         {
             Vector3 segment = begin - end;
             real_t den = _normal.Dot(segment);
@@ -289,11 +282,22 @@ namespace Godot
             D = d;
         }
 
+        /// <summary>
+        /// Constructs a <see cref="Plane"/> from a <paramref name="normal"/> vector.
+        /// The plane will intersect the origin.
+        /// </summary>
+        /// <param name="normal">The normal of the plane, must be a unit vector.</param>
+        public Plane(Vector3 normal)
+        {
+            _normal = normal;
+            D = 0;
+        }
+
         /// <summary>
         /// Constructs a <see cref="Plane"/> from a <paramref name="normal"/> vector and
         /// the plane's distance to the origin <paramref name="d"/>.
         /// </summary>
-        /// <param name="normal">The normal of the plane, must be normalized.</param>
+        /// <param name="normal">The normal of the plane, must be a unit vector.</param>
         /// <param name="d">The plane's distance from the origin. This value is typically non-negative.</param>
         public Plane(Vector3 normal, real_t d)
         {
@@ -305,7 +309,7 @@ namespace Godot
         /// Constructs a <see cref="Plane"/> from a <paramref name="normal"/> vector and
         /// a <paramref name="point"/> on the plane.
         /// </summary>
-        /// <param name="normal">The normal of the plane, must be normalized.</param>
+        /// <param name="normal">The normal of the plane, must be a unit vector.</param>
         /// <param name="point">The point on the plane.</param>
         public Plane(Vector3 normal, Vector3 point)
         {