From 87e1ecdff765f9e7ada318ada1918fb63ca5984c Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 26 Aug 2019 21:07:02 -0700 Subject: Updated math lib: added GetBoxNearestCorner and GetBoxFarthestCorner functions --- Common/interface/AdvancedMath.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'Common/interface') diff --git a/Common/interface/AdvancedMath.h b/Common/interface/AdvancedMath.h index 0a8d0a6b..0039a41a 100644 --- a/Common/interface/AdvancedMath.h +++ b/Common/interface/AdvancedMath.h @@ -173,6 +173,28 @@ enum class BoxVisibility FullyVisible }; +/// Returns the nearest bounding box corner along the given direction +inline float3 GetBoxNearestCorner(const float3& Direction, const BoundBox& Box) +{ + return float3 + { + (Direction.x > 0) ? Box.Min.x : Box.Max.x, + (Direction.y > 0) ? Box.Min.y : Box.Max.y, + (Direction.z > 0) ? Box.Min.z : Box.Max.z + }; +} + +/// Returns the farthest bounding box corner along the given direction +inline float3 GetBoxFarthestCorner(const float3& Direction, const BoundBox& Box) +{ + return float3 + { + (Direction.x > 0) ? Box.Max.x : Box.Min.x, + (Direction.y > 0) ? Box.Max.y : Box.Min.y, + (Direction.z > 0) ? Box.Max.z : Box.Min.z + }; +} + inline BoxVisibility GetBoxVisibilityAgainstPlane(const Plane3D& Plane, const BoundBox& Box) { const float3& Normal = Plane.Normal; -- cgit v1.2.3