| 457 | // Lighting: ----------------------------------------------------------------- |
| 458 | |
| 459 | void 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 | //---------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected