MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / registerLights

Method registerLights

Engine/source/T3D/item.cpp:459–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457// Lighting: -----------------------------------------------------------------
458
459void Item::registerLights(LightManager * lightManager, bool lightingScene)
460{
461 if(lightingScene)
462 return;
463
464 if(mDataBlock->lightOnlyStatic && !mStatic)
465 return;
466
467 F32 intensity;
468 switch(mDataBlock->lightType)
469 {
470 case ConstantLight:
471 intensity = mFadeVal;
472 break;
473
474 case PulsingLight:
475 {
476 S32 delta = Sim::getCurrentTime() - mDropTime;
477 intensity = 0.5f + 0.5f * mSin(M_PI_F * F32(delta) / F32(mDataBlock->lightTime));
478 intensity = 0.15f + intensity * 0.85f;
479 intensity *= mFadeVal; // fade out light on flags
480 break;
481 }
482
483 default:
484 return;
485 }
486
487 // Create a light if needed
488 if (!mLight)
489 {
490 mLight = lightManager->createLightInfo();
491 }
492 mLight->setColor( mDataBlock->lightColor * intensity );
493 mLight->setType( LightInfo::Point );
494 mLight->setRange( mDataBlock->lightRadius );
495 mLight->setPosition( getBoxCenter() );
496
497 lightManager->registerGlobalLight( mLight, this );
498}
499
500
501//----------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 8

mSinFunction · 0.85
createLightInfoMethod · 0.80
getCurrentTimeFunction · 0.50
setColorMethod · 0.45
setTypeMethod · 0.45
setRangeMethod · 0.45
setPositionMethod · 0.45
registerGlobalLightMethod · 0.45

Tested by

no test coverage detected