summaryrefslogtreecommitdiffstats
path: root/Common/interface
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-08-27 04:07:02 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-08-27 04:07:02 +0000
commit87e1ecdff765f9e7ada318ada1918fb63ca5984c (patch)
treee547a5a262620e94e314c520ddb7de81f5f52356 /Common/interface
parentD3D12 backend: fixed issue with the barriers when old and new states are the ... (diff)
downloadDiligentCore-87e1ecdff765f9e7ada318ada1918fb63ca5984c.tar.gz
DiligentCore-87e1ecdff765f9e7ada318ada1918fb63ca5984c.zip
Updated math lib: added GetBoxNearestCorner and GetBoxFarthestCorner functions
Diffstat (limited to 'Common/interface')
-rw-r--r--Common/interface/AdvancedMath.h22
1 files changed, 22 insertions, 0 deletions
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;