summaryrefslogtreecommitdiff
path: root/Runtime/Geometry/BoundingUtils.h
blob: 5338706bdb988f4f81906353c35ca0e348521faa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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);