diff options
Diffstat (limited to 'Runtime/Geometry/BoundingUtils.h')
-rw-r--r-- | Runtime/Geometry/BoundingUtils.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Runtime/Geometry/BoundingUtils.h b/Runtime/Geometry/BoundingUtils.h new file mode 100644 index 0000000..5338706 --- /dev/null +++ b/Runtime/Geometry/BoundingUtils.h @@ -0,0 +1,30 @@ +#pragma once + + +#include "Runtime/Math/Vector3.h" +#include <vector> + +class MinMaxAABB; +class Plane; +class Matrix4x4f; + +struct SpotLightBounds +{ + enum { kPointCount = 5 }; + Vector3f points[kPointCount]; +}; + +// 7-----6 far +// / /| +// 3-----2 | +// | 4 | 5 +// | |/ +// 0-----1 near + +void GetFrustumPoints( const Matrix4x4f& clipToWorld, Vector3f* frustum ); +void GetFrustumPortion( const Vector3f* frustum, float nearSplit, float farSplit, Vector3f* outPortion ); +void CalcHullBounds(const Vector3f* __restrict hullPoints, const UInt8* __restrict hullCounts, UInt8 hullFaces, const Plane& nearPlane, const Matrix4x4f& cameraWorldToClip, MinMaxAABB& aabb); +void CalculateFocusedLightHull( const Vector3f* frustum, const Vector3f& lightDir, const MinMaxAABB& sceneAABB, std::vector<Vector3f>& points ); +void CalculateBoundingSphereFromFrustumPoints(const Vector3f points[8], Vector3f& outCenter, float& outRadius); +void CalculateSphereFrom4Points(const Vector3f points[4], Vector3f& outCenter, float& outRadius); +void CalculateSpotLightBounds (const float range, const float cotanHalfSpotAngle, const Matrix4x4f& lightMatrix, SpotLightBounds& outBounds); |