From 7a19c87c7e2e0590f34a12214739d0c4588c31eb Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Sun, 15 Jan 2023 05:35:09 +0100 Subject: C#: Sync `Plane` with Core - Add `Plane(Vector3)` constructor. - Rename `IntersectRay` to `IntersectsRay`. - Rename `IntersectSegment` to `IntersectsSegment`. - Replace `Center` property with `GetCenter` method. - Add and fix documentation about the _normal_ parameter to Core and C# documentation. --- .../mono/glue/GodotSharp/GodotSharp/Core/Plane.cs | 48 ++++++++++++---------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'modules') diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs index 9e5f7c4f9e..8a125e3c73 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs @@ -15,7 +15,7 @@ namespace Godot private Vector3 _normal; /// - /// 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 ax + by + cz = d, this is /// the vector (a, b, c), where d is the property. /// @@ -84,23 +84,6 @@ namespace Godot /// The plane's distance from the origin. public real_t D { get; set; } - /// - /// The center of the plane, the point where the normal line intersects the plane. - /// - /// Equivalent to multiplied by . - public Vector3 Center - { - readonly get - { - return _normal * D; - } - set - { - _normal = value.Normalized(); - D = value.Length(); - } - } - /// /// Returns the shortest distance from this plane to the position . /// @@ -111,6 +94,16 @@ namespace Godot return _normal.Dot(point) - D; } + /// + /// 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. + /// + /// Equivalent to multiplied by . + public readonly Vector3 GetCenter() + { + return _normal * D; + } + /// /// Returns if point is inside the plane. /// Comparison uses a custom minimum tolerance threshold. @@ -155,7 +148,7 @@ namespace Godot /// The start of the ray. /// The direction of the ray, normalized. /// The intersection, or if none is found. - 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 /// The start of the line segment. /// The end of the line segment. /// The intersection, or if none is found. - 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; } + /// + /// Constructs a from a vector. + /// The plane will intersect the origin. + /// + /// The normal of the plane, must be a unit vector. + public Plane(Vector3 normal) + { + _normal = normal; + D = 0; + } + /// /// Constructs a from a vector and /// the plane's distance to the origin . /// - /// The normal of the plane, must be normalized. + /// The normal of the plane, must be a unit vector. /// The plane's distance from the origin. This value is typically non-negative. public Plane(Vector3 normal, real_t d) { @@ -305,7 +309,7 @@ namespace Godot /// Constructs a from a vector and /// a on the plane. /// - /// The normal of the plane, must be normalized. + /// The normal of the plane, must be a unit vector. /// The point on the plane. public Plane(Vector3 normal, Vector3 point) { -- cgit v1.2.3