mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
Fix setNearFarDist for off-center projections
This commit is contained in:
parent
694dd4abfa
commit
14628e3937
1 changed files with 20 additions and 2 deletions
|
|
@ -214,8 +214,26 @@ void Frustum::setNearFarDist( F32 nearDist, F32 farDist )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Recalculate the frustum.
|
// Recalculate the frustum.
|
||||||
MatrixF xfm( mTransform );
|
MatrixF xfm( mTransform );
|
||||||
set( mIsOrtho, getFov(), getAspectRatio(), nearDist, farDist, xfm );
|
|
||||||
|
const F32 CENTER_EPSILON = 0.01;
|
||||||
|
F32 centerX = mNearLeft + (mNearRight - mNearLeft) * 0.5;
|
||||||
|
F32 centerY = mNearBottom + (mNearTop - mNearBottom) * 0.5;
|
||||||
|
if ((centerX > CENTER_EPSILON || centerX < -CENTER_EPSILON) || (centerY > CENTER_EPSILON || centerY < -CENTER_EPSILON) )
|
||||||
|
{
|
||||||
|
// Off-center projection, so re-calc use the new distances
|
||||||
|
FovPort expectedFovPort;
|
||||||
|
expectedFovPort.leftTan = -(mNearLeft / mNearDist);
|
||||||
|
expectedFovPort.rightTan = (mNearRight / mNearDist);
|
||||||
|
expectedFovPort.upTan = (mNearTop / mNearDist);
|
||||||
|
expectedFovPort.downTan = -(mNearBottom / mNearDist);
|
||||||
|
MathUtils::makeFovPortFrustum(this, mIsOrtho, nearDist, farDist, expectedFovPort);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Projection is not off-center, use the normal code
|
||||||
|
set(mIsOrtho, getFov(), getAspectRatio(), nearDist, farDist, xfm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue