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

Method prepRender

Engine/source/T3D/lightFlareData.cpp:402–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402void LightFlareData::prepRender(SceneRenderState *state, LightFlareState *flareState)
403{
404 PROFILE_SCOPE(LightFlareData_prepRender);
405
406 const LightInfo *lightInfo = flareState->lightInfo;
407
408 if (mIsZero(flareState->fullBrightness) ||
409 mIsZero(lightInfo->getBrightness()))
410 return;
411
412 // Figure out the element count to render.
413 U32 elementCount = mElementCount;
414 const bool isReflectPass = state->isReflectPass();
415 if (isReflectPass)
416 {
417 // Then we don't render anything this pass.
418 if (!mRenderReflectPass)
419 return;
420
421 // Find the zero distance elements which make
422 // up the corona of the light flare.
423 elementCount = 0.0f;
424 for (U32 i = 0; i < mElementCount; i++)
425 if (mIsZero(mElementDist[i]))
426 elementCount++;
427 }
428
429 // Better have something to render.
430 if (elementCount == 0)
431 return;
432
433 U32 visDelta = U32_MAX;
434 F32 occlusionFade = 1.0f;
435 Point3F lightPosSS;
436 bool lightVisible = _testVisibility(state, flareState, &visDelta, &occlusionFade, &lightPosSS);
437
438 //DebugDrawer::get()->drawBox(flareState->lightMat.getPosition() + Point3F(-0.5, -0.5, -0.5) * 4, flareState->lightMat.getPosition() + Point3F(0.5, 0.5, 0.5) * 4, ColorI::BLUE);
439
440 // We can only skip rendering if the light is not
441 // visible, and it has elapsed the fade out time.
442 if (mIsZero(occlusionFade) ||
443 (!lightVisible && visDelta > FadeOutTime))
444 return;
445
446 const RectI &viewport = GFX->getViewport();
447 Point3F oneOverViewportExtent(1.0f / (F32)viewport.extent.x, 1.0f / (F32)viewport.extent.y, 0.0f);
448
449 lightPosSS *= oneOverViewportExtent;
450 lightPosSS = (lightPosSS * 2.0f) - Point3F::One;
451 lightPosSS.y = -lightPosSS.y;
452 lightPosSS.z = 0.0f;
453
454 // Determine the center of the current projection so we can converge there
455 Point3F centerProj(0);
456 {
457 MatrixF camProjMatrix = state->getSceneManager()->getNonClipProjection();
458 Point3F outCenterPos;
459 RectI centerViewport = RectI(Point2I(0, 0), viewport.extent);

Callers 4

prepRenderImageMethod · 0.45
prepRenderImageMethod · 0.45
prepRenderImageMethod · 0.45
prepRenderImageMethod · 0.45

Calls 15

mIsZeroFunction · 0.85
mProjectWorldToScreenFunction · 0.85
mAcosFunction · 0.85
vectorRotateZAxisFunction · 0.85
getMaxFunction · 0.85
mPowFunction · 0.85
getBrightnessMethod · 0.80
isReflectPassMethod · 0.80
getNearClipMethod · 0.80
RectIClass · 0.50
Point2IClass · 0.50
Point3FClass · 0.50

Tested by

no test coverage detected