MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / updatePriority

Method updatePriority

Engine/source/lighting/shadowMap/lightShadowMap.cpp:386–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384}
385
386void 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
430S32 QSORT_CALLBACK LightShadowMap::cmpPriority( LightShadowMap *const *lsm1, LightShadowMap *const *lsm2 )
431{

Callers 1

renderMethod · 0.80

Calls 14

mClosestPointOnSegmentFunction · 0.85
mSinFunction · 0.85
mDegToRadFunction · 0.85
mPowFunction · 0.85
getRangeMethod · 0.80
getOuterConeAngleMethod · 0.80
SphereFClass · 0.50
getTypeMethod · 0.45
getPositionMethod · 0.45
getDirectionMethod · 0.45
lenMethod · 0.45
distanceToMethod · 0.45

Tested by

no test coverage detected