From 9b812ec34a0022b2b3f604424fae75ceecb3af69 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 2 Oct 2025 18:48:32 +0200 Subject: [PATCH] Fix `BoundingFrustum::GetPlane` in C++ to match C# version (and doc comment) --- Source/Engine/Core/Math/BoundingFrustum.cpp | 13 ++++++++++--- Source/Engine/Core/Math/BoundingFrustum.cs | 2 +- Source/Engine/Core/Math/BoundingFrustum.h | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Source/Engine/Core/Math/BoundingFrustum.cpp b/Source/Engine/Core/Math/BoundingFrustum.cpp index e296fa1a8..e0697ce5e 100644 --- a/Source/Engine/Core/Math/BoundingFrustum.cpp +++ b/Source/Engine/Core/Math/BoundingFrustum.cpp @@ -63,9 +63,16 @@ void BoundingFrustum::SetMatrix(const Matrix& matrix) Plane BoundingFrustum::GetPlane(int32 index) const { - if (index > 5) - return Plane(); - return _planes[index]; + switch (index) + { + case 0: return _pLeft; + case 1: return _pRight; + case 2: return _pTop; + case 3: return _pBottom; + case 4: return _pNear; + case 5: return _pFar; + default: return Plane(); + } } static Vector3 Get3PlanesInterPoint(const Plane& p1, const Plane& p2, const Plane& p3) diff --git a/Source/Engine/Core/Math/BoundingFrustum.cs b/Source/Engine/Core/Math/BoundingFrustum.cs index 6f6e034ce..4f1e27e1e 100644 --- a/Source/Engine/Core/Math/BoundingFrustum.cs +++ b/Source/Engine/Core/Math/BoundingFrustum.cs @@ -182,7 +182,7 @@ namespace FlaxEngine /// /// Returns one of the 6 planes related to this frustum. /// - /// Plane index where 0 fro Left, 1 for Right, 2 for Top, 3 for Bottom, 4 for Near, 5 for Far + /// Plane index where 0 for Left, 1 for Right, 2 for Top, 3 for Bottom, 4 for Near, 5 for Far /// The frustum plane. public Plane GetPlane(int index) { diff --git a/Source/Engine/Core/Math/BoundingFrustum.h b/Source/Engine/Core/Math/BoundingFrustum.h index 30eb70f43..a3a5442e9 100644 --- a/Source/Engine/Core/Math/BoundingFrustum.h +++ b/Source/Engine/Core/Math/BoundingFrustum.h @@ -148,13 +148,13 @@ public: Plane GetPlane(int32 index) const; /// - /// Gets the the 8 corners of the frustum: Near1 (near right down corner), Near2 (near right top corner), Near3 (near Left top corner), Near4 (near Left down corner), Far1 (far right down corner), Far2 (far right top corner), Far3 (far left top corner), Far4 (far left down corner). + /// Gets the 8 corners of the frustum: Near1 (near right down corner), Near2 (near right top corner), Near3 (near Left top corner), Near4 (near Left down corner), Far1 (far right down corner), Far2 (far right top corner), Far3 (far left top corner), Far4 (far left down corner). /// /// The corners. void GetCorners(Float3 corners[8]) const; /// - /// Gets the the 8 corners of the frustum: Near1 (near right down corner), Near2 (near right top corner), Near3 (near Left top corner), Near4 (near Left down corner), Far1 (far right down corner), Far2 (far right top corner), Far3 (far left top corner), Far4 (far left down corner). + /// Gets the 8 corners of the frustum: Near1 (near right down corner), Near2 (near right top corner), Near3 (near Left top corner), Near4 (near Left down corner), Far1 (far right down corner), Far2 (far right top corner), Far3 (far left top corner), Far4 (far left down corner). /// /// The corners. void GetCorners(Double3 corners[8]) const;