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

Method submitLights

Engine/source/T3D/shapeImage.cpp:3289–3355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3287}
3288
3289void ShapeBase::submitLights( LightManager *lm, bool staticLighting )
3290{
3291 if ( staticLighting )
3292 return;
3293
3294 // Submit lights for MountedImage(s)
3295 for ( S32 i = 0; i < MaxMountedImages; i++ )
3296 {
3297 ShapeBaseImageData *imageData = getMountedImage( i );
3298
3299 if ( imageData != NULL && imageData->lightType != ShapeBaseImageData::NoLight )
3300 {
3301 MountedImage &image = mMountedImageList[i];
3302
3303 F32 intensity;
3304
3305 switch ( imageData->lightType )
3306 {
3307 case ShapeBaseImageData::ConstantLight:
3308 case ShapeBaseImageData::SpotLight:
3309 intensity = 1.0f;
3310 break;
3311
3312 case ShapeBaseImageData::PulsingLight:
3313 intensity = 0.5f + 0.5f * mSin( M_PI_F * (F32)Sim::getCurrentTime() / (F32)imageData->lightDuration + image.lightStart );
3314 intensity = 0.15f + intensity * 0.85f;
3315 break;
3316
3317 case ShapeBaseImageData::WeaponFireLight:
3318 {
3319 S32 elapsed = Sim::getCurrentTime() - image.lightStart;
3320 if ( elapsed > imageData->lightDuration )
3321 continue;
3322 intensity = ( 1.0 - (F32)elapsed / (F32)imageData->lightDuration ) * imageData->lightBrightness;
3323 break;
3324 }
3325 default:
3326 intensity = 1.0f;
3327 return;
3328 }
3329
3330 if ( !image.lightInfo )
3331 image.lightInfo = LightManager::createLightInfo();
3332
3333 image.lightInfo->setColor( imageData->lightColor );
3334 image.lightInfo->setBrightness( intensity );
3335 image.lightInfo->setRange( imageData->lightRadius );
3336
3337 if ( imageData->lightType == ShapeBaseImageData::SpotLight )
3338 {
3339 image.lightInfo->setType( LightInfo::Spot );
3340 // Do we want to expose these or not?
3341 image.lightInfo->setInnerConeAngle( 15 );
3342 image.lightInfo->setOuterConeAngle( 40 );
3343 }
3344 else
3345 image.lightInfo->setType( LightInfo::Point );
3346

Callers

nothing calls this directly

Calls 10

mSinFunction · 0.85
setBrightnessMethod · 0.80
setInnerConeAngleMethod · 0.80
setOuterConeAngleMethod · 0.80
getCurrentTimeFunction · 0.50
setColorMethod · 0.45
setRangeMethod · 0.45
setTypeMethod · 0.45
setTransformMethod · 0.45
registerGlobalLightMethod · 0.45

Tested by

no test coverage detected