MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / ComputeModelLOD

Method ComputeModelLOD

Source/Engine/Graphics/RenderTools.cpp:439–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

437}
438
439int32 RenderTools::ComputeModelLOD(const Model* model, const Float3& origin, float radius, const RenderContext& renderContext)
440{
441 const auto lodView = (renderContext.LodProxyView ? renderContext.LodProxyView : &renderContext.View);
442 const float screenRadiusSquared = ComputeBoundsScreenRadiusSquared(origin, radius, *lodView) * renderContext.View.ModelLODDistanceFactorSqrt;
443
444 // Check if model is being culled
445 if (Math::Square(model->MinScreenSize * 0.5f) > screenRadiusSquared)
446 return -1;
447
448 // Skip if no need to calculate LOD
449 if (model->LODs.Count() <= 1)
450 return 0;
451
452 // Iterate backwards and return the first matching LOD
453 for (int32 lodIndex = model->LODs.Count() - 1; lodIndex >= 0; lodIndex--)
454 {
455 if (Math::Square(model->LODs[lodIndex].ScreenSize * 0.5f) >= screenRadiusSquared)
456 {
457 return lodIndex;
458 }
459 }
460
461 return 0;
462}
463
464int32 RenderTools::ComputeModelLOD(const SkinnedModel* model, const Float3& origin, float radius, const RenderContext& renderContext)
465{

Callers 2

OnDrawMethod · 0.80
DrawMethod · 0.80

Calls 3

SquareFunction · 0.85
CountMethod · 0.45

Tested by

no test coverage detected