| 384 | } |
| 385 | |
| 386 | void LightShadowMap::updatePriority( const SceneRenderState *state, U32 currTimeMs ) |
| 387 | { |
| 388 | PROFILE_SCOPE( LightShadowMap_updatePriority ); |
| 389 | |
| 390 | mLastCull = currTimeMs; |
| 391 | |
| 392 | if ( isViewDependent() ) |
| 393 | { |
| 394 | mLastScreenSize = 1.0f; |
| 395 | mLastPriority = F32_MAX; |
| 396 | return; |
| 397 | } |
| 398 | |
| 399 | U32 timeSinceLastUpdate = currTimeMs - mLastUpdate; |
| 400 | |
| 401 | const Point3F &camPt = state->getCameraPosition(); |
| 402 | F32 range = mLight->getRange().x; |
| 403 | F32 dist; |
| 404 | |
| 405 | if ( mLight->getType() == LightInfo::Spot ) |
| 406 | { |
| 407 | // We treat the cone as a cylinder to get the |
| 408 | // approximate projection distance. |
| 409 | |
| 410 | Point3F endPt = mLight->getPosition() + ( mLight->getDirection() * range ); |
| 411 | Point3F nearPt = MathUtils::mClosestPointOnSegment( mLight->getPosition(), endPt, camPt ); |
| 412 | dist = ( camPt - nearPt ).len(); |
| 413 | |
| 414 | F32 radius = range * mSin( mDegToRad( mLight->getOuterConeAngle() * 0.5f ) ); |
| 415 | dist -= radius; |
| 416 | } |
| 417 | else |
| 418 | dist = SphereF( mLight->getPosition(), range ).distanceTo( camPt ); |
| 419 | |
| 420 | // Get the approximate screen size of the light. |
| 421 | mLastScreenSize = state->projectRadius( dist, range ); |
| 422 | mLastScreenSize /= state->getViewport().extent.y; |
| 423 | |
| 424 | // Update the priority. |
| 425 | mLastPriority = mPow( mLastScreenSize * 50.0f, 2.0f ); |
| 426 | mLastPriority += timeSinceLastUpdate; |
| 427 | mLastPriority *= mLight->getPriority(); |
| 428 | } |
| 429 | |
| 430 | S32 QSORT_CALLBACK LightShadowMap::cmpPriority( LightShadowMap *const *lsm1, LightShadowMap *const *lsm2 ) |
| 431 | { |
no test coverage detected