| 437 | } |
| 438 | |
| 439 | int32 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 | |
| 464 | int32 RenderTools::ComputeModelLOD(const SkinnedModel* model, const Float3& origin, float radius, const RenderContext& renderContext) |
| 465 | { |
no test coverage detected