| 209 | //----------------------------------------------------------------------------- |
| 210 | |
| 211 | void Frustum::setNearFarDist( F32 nearDist, F32 farDist ) |
| 212 | { |
| 213 | if( mNearDist == nearDist && mFarDist == farDist ) |
| 214 | return; |
| 215 | |
| 216 | // Recalculate the frustum. |
| 217 | MatrixF xfm( mTransform ); |
| 218 | |
| 219 | const F32 CENTER_EPSILON = 0.001f; |
| 220 | F32 centerX = mNearLeft + (mNearRight - mNearLeft) * 0.5; |
| 221 | F32 centerY = mNearBottom + (mNearTop - mNearBottom) * 0.5; |
| 222 | if ((centerX > CENTER_EPSILON || centerX < -CENTER_EPSILON) || (centerY > CENTER_EPSILON || centerY < -CENTER_EPSILON) ) |
| 223 | { |
| 224 | // Off-center projection, so re-calc use the new distances |
| 225 | FovPort expectedFovPort; |
| 226 | expectedFovPort.leftTan = -(mNearLeft / mNearDist); |
| 227 | expectedFovPort.rightTan = (mNearRight / mNearDist); |
| 228 | expectedFovPort.upTan = (mNearTop / mNearDist); |
| 229 | expectedFovPort.downTan = -(mNearBottom / mNearDist); |
| 230 | MathUtils::makeFovPortFrustum(this, mIsOrtho, nearDist, farDist, expectedFovPort); |
| 231 | } |
| 232 | else |
| 233 | { |
| 234 | // Projection is not off-center, use the normal code |
| 235 | set(mIsOrtho, getFov(), getAspectRatio(), nearDist, farDist, xfm); |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | //----------------------------------------------------------------------------- |
| 240 |
nothing calls this directly
no test coverage detected