diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-10 16:47:11 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-10 16:47:11 +0200 |
commit | 94721f5ab8af9e7d91a4de58baf2c8d849ceab6e (patch) | |
tree | 92fb34d709310b76de1c2d45cfe2aad8db7a523a /modules/mono | |
parent | 6ab92464bc6356f3342c3efd1fc1bb1a5e4467d5 (diff) |
Revert "Renamed plane's d to distance"
This reverts commit ec7b481170dcd6a7b4cf0e6c1221e204ff7945f3.
This was wrong, `d` is not a distance but the `d` constant in the
parametric equation `ax + by + cz = d` describing the plane.
Diffstat (limited to 'modules/mono')
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs | 46 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_marshal.h | 8 |
2 files changed, 27 insertions, 27 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs index 55a83642fd..885845e3a4 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs @@ -56,29 +56,29 @@ namespace Godot } } - public real_t Distance { get; set; } + public real_t D { get; set; } public Vector3 Center { get { - return _normal * Distance; + return _normal * D; } } public real_t DistanceTo(Vector3 point) { - return _normal.Dot(point) - Distance; + return _normal.Dot(point) - D; } public Vector3 GetAnyPoint() { - return _normal * Distance; + return _normal * D; } public bool HasPoint(Vector3 point, real_t epsilon = Mathf.Epsilon) { - real_t dist = _normal.Dot(point) - Distance; + real_t dist = _normal.Dot(point) - D; return Mathf.Abs(dist) <= epsilon; } @@ -89,9 +89,9 @@ namespace Godot if (Mathf.IsZeroApprox(denom)) return null; - Vector3 result = b._normal.Cross(c._normal) * Distance + - c._normal.Cross(_normal) * b.Distance + - _normal.Cross(b._normal) * c.Distance; + Vector3 result = b._normal.Cross(c._normal) * D + + c._normal.Cross(_normal) * b.D + + _normal.Cross(b._normal) * c.D; return result / denom; } @@ -103,7 +103,7 @@ namespace Godot if (Mathf.IsZeroApprox(den)) return null; - real_t dist = (_normal.Dot(from) - Distance) / den; + real_t dist = (_normal.Dot(from) - D) / den; // This is a ray, before the emitting pos (from) does not exist if (dist > Mathf.Epsilon) @@ -120,7 +120,7 @@ namespace Godot if (Mathf.IsZeroApprox(den)) return null; - real_t dist = (_normal.Dot(begin) - Distance) / den; + real_t dist = (_normal.Dot(begin) - D) / den; // Only allow dist to be in the range of 0 to 1, with tolerance. if (dist < -Mathf.Epsilon || dist > 1.0f + Mathf.Epsilon) @@ -131,7 +131,7 @@ namespace Godot public bool IsPointOver(Vector3 point) { - return _normal.Dot(point) > Distance; + return _normal.Dot(point) > D; } public Plane Normalized() @@ -141,7 +141,7 @@ namespace Godot if (len == 0) return new Plane(0, 0, 0, 0); - return new Plane(_normal / len, Distance / len); + return new Plane(_normal / len, D / len); } public Vector3 Project(Vector3 point) @@ -159,27 +159,27 @@ namespace Godot public static Plane PlaneXY { get { return _planeXY; } } // Constructors - public Plane(real_t a, real_t b, real_t c, real_t distance) + public Plane(real_t a, real_t b, real_t c, real_t d) { _normal = new Vector3(a, b, c); - this.Distance = distance; + this.D = d; } - public Plane(Vector3 normal, real_t distance) + public Plane(Vector3 normal, real_t d) { this._normal = normal; - this.Distance = distance; + this.D = d; } public Plane(Vector3 v1, Vector3 v2, Vector3 v3) { _normal = (v1 - v3).Cross(v1 - v2); _normal.Normalize(); - Distance = _normal.Dot(v1); + D = _normal.Dot(v1); } public static Plane operator -(Plane plane) { - return new Plane(-plane._normal, -plane.Distance); + return new Plane(-plane._normal, -plane.D); } public static bool operator ==(Plane left, Plane right) @@ -204,17 +204,17 @@ namespace Godot public bool Equals(Plane other) { - return _normal == other._normal && Distance == other.Distance; + return _normal == other._normal && D == other.D; } public bool IsEqualApprox(Plane other) { - return _normal.IsEqualApprox(other._normal) && Mathf.IsEqualApprox(Distance, other.Distance); + return _normal.IsEqualApprox(other._normal) && Mathf.IsEqualApprox(D, other.D); } public override int GetHashCode() { - return _normal.GetHashCode() ^ Distance.GetHashCode(); + return _normal.GetHashCode() ^ D.GetHashCode(); } public override string ToString() @@ -222,7 +222,7 @@ namespace Godot return String.Format("({0}, {1})", new object[] { _normal.ToString(), - Distance.ToString() + D.ToString() }); } @@ -231,7 +231,7 @@ namespace Godot return String.Format("({0}, {1})", new object[] { _normal.ToString(format), - Distance.ToString(format) + D.ToString(format) }); } } diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h index fd645f1608..f2d887e6d6 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.h +++ b/modules/mono/mono_gd/gd_mono_marshal.h @@ -274,7 +274,7 @@ enum { MATCHES_Plane = (MATCHES_Vector3 && MATCHES_real_t && (sizeof(Plane) == (sizeof(Vector3) + sizeof(real_t))) && offsetof(Plane, normal) == 0 && - offsetof(Plane, distance) == sizeof(Vector3)) + offsetof(Plane, d) == sizeof(Vector3)) }; // In the future we may force this if we want to ref return these structs @@ -466,14 +466,14 @@ struct M_Color { struct M_Plane { M_Vector3 normal; - real_t distance; + real_t d; static _FORCE_INLINE_ Plane convert_to(const M_Plane &p_from) { - return Plane(M_Vector3::convert_to(p_from.normal), p_from.distance); + return Plane(M_Vector3::convert_to(p_from.normal), p_from.d); } static _FORCE_INLINE_ M_Plane convert_from(const Plane &p_from) { - M_Plane ret = { M_Vector3::convert_from(p_from.normal), p_from.distance }; + M_Plane ret = { M_Vector3::convert_from(p_from.normal), p_from.d }; return ret; } }; |