SceneCullingState with culling and camera frustum

- Fix for issue https://github.com/GarageGames/Torque3D/issues/525  This
fix takes into account the skewed view into the world when you have a
projection offset and the ability to see further into the scene at the
edges opposite to the offset.
- SceneCullingState now has two frustum rather than one: a culling
frustum and camera frustum.
- The camera frustum should be referenced when you need the projection
matrix or don't want a skewed frustum.
- The culling frustum should be referenced during any scene culling or
when determining what dynamic geometry to render.  It currently skews
itself to take into account any projection offset (automatically
calculated in SceneCullingState constructor).
- When there is no projection offset, the camera frustum and culling
frustum are the same.  This usually means any time when not using the
Oculus Rift.
This commit is contained in:
DavidWyand-GG 2013-11-07 15:07:16 -05:00
parent 9af13248cf
commit 91e542b8ec
22 changed files with 161 additions and 47 deletions

View file

@ -412,6 +412,9 @@ class Frustum : public PolyhedronImpl< FrustumData >
/// points typically used for early rejection.
const Box3F& getBounds() const { _update(); return mBounds; }
// Does the frustum have a projection offset?
bool hasProjectionOffset() const { return !mProjectionOffset.isZero(); }
/// Get the offset used when calculating the projection matrix
const Point2F& getProjectionOffset() const { return mProjectionOffset; }
@ -424,6 +427,10 @@ class Frustum : public PolyhedronImpl< FrustumData >
/// Clear any offset used when calculating the projection matrix
void clearProjectionOffset() { mProjectionOffset.zero(); mProjectionOffsetMatrix.identity(); }
/// Enlarges the frustum to contain the planes generated by a project offset, if any.
/// Used by scene culling to ensure that all object are contained within the asymetrical frustum.
bool bakeProjectionOffset();
/// Generates a projection matrix from the frustum.
void getProjectionMatrix( MatrixF *proj, bool gfxRotate=true ) const;