diff --git a/Source/Engine/Content/Assets/Model.h b/Source/Engine/Content/Assets/Model.h index ffc63e31d..9a030f07f 100644 --- a/Source/Engine/Content/Assets/Model.h +++ b/Source/Engine/Content/Assets/Model.h @@ -54,16 +54,6 @@ public: return _loadedLODs; } - /// - /// Determines whether the specified index is a valid LOD index. - /// - /// The index. - /// True if the specified index is a valid LOD index, otherwise false. - FORCE_INLINE bool IsValidLODIndex(int32 index) const - { - return Math::IsInRange(index, 0, LODs.Count() - 1); - } - /// /// Clamps the index of the LOD to be valid for rendering (only loaded LODs). /// @@ -79,7 +69,7 @@ public: /// FORCE_INLINE int32 HighestResidentLODIndex() const { - return GetLODsCount() - _loadedLODs; + return LODs.Count() - _loadedLODs; } /// diff --git a/Source/Engine/Content/Assets/SkinnedModel.h b/Source/Engine/Content/Assets/SkinnedModel.h index 84b6bb859..a0cc060c8 100644 --- a/Source/Engine/Content/Assets/SkinnedModel.h +++ b/Source/Engine/Content/Assets/SkinnedModel.h @@ -55,16 +55,6 @@ public: return _loadedLODs; } - /// - /// Determines whether the specified index is a valid LOD index. - /// - /// The index. - /// True if the specified index is a valid LOD index, otherwise false. - FORCE_INLINE bool IsValidLODIndex(int32 index) const - { - return Math::IsInRange(index, 0, LODs.Count() - 1); - } - /// /// Clamps the index of the LOD to be valid for rendering (only loaded LODs). /// @@ -80,7 +70,7 @@ public: /// FORCE_INLINE int32 HighestResidentLODIndex() const { - return GetLODsCount() - _loadedLODs; + return LODs.Count() - _loadedLODs; } /// diff --git a/Source/Engine/Graphics/RenderView.cpp b/Source/Engine/Graphics/RenderView.cpp index 125897ea7..e127e6656 100644 --- a/Source/Engine/Graphics/RenderView.cpp +++ b/Source/Engine/Graphics/RenderView.cpp @@ -188,23 +188,6 @@ void RenderView::CopyFrom(Camera* camera, Viewport* viewport) RenderLayersMask = camera->RenderLayersMask; } -DrawPass RenderView::GetShadowsDrawPassMask(ShadowsCastingMode shadowsMode) const -{ - switch (shadowsMode) - { - case ShadowsCastingMode::All: - return DrawPass::All; - case ShadowsCastingMode::DynamicOnly: - return IsOfflinePass ? ~DrawPass::Depth : DrawPass::All; - case ShadowsCastingMode::StaticOnly: - return IsOfflinePass ? DrawPass::All : ~DrawPass::Depth; - case ShadowsCastingMode::None: - return ~DrawPass::Depth; - default: - return DrawPass::All; - } -} - void RenderView::GetWorldMatrix(const Transform& transform, Matrix& world) const { const Float3 translation = transform.Translation - Origin; diff --git a/Source/Engine/Graphics/RenderView.h b/Source/Engine/Graphics/RenderView.h index dd974761e..4cb453f8b 100644 --- a/Source/Engine/Graphics/RenderView.h +++ b/Source/Engine/Graphics/RenderView.h @@ -296,7 +296,22 @@ public: void CopyFrom(Camera* camera, Viewport* viewport = nullptr); public: - DrawPass GetShadowsDrawPassMask(ShadowsCastingMode shadowsMode) const; + FORCE_INLINE DrawPass GetShadowsDrawPassMask(ShadowsCastingMode shadowsMode) const + { + switch (shadowsMode) + { + case ShadowsCastingMode::All: + return DrawPass::All; + case ShadowsCastingMode::DynamicOnly: + return IsOfflinePass ? ~DrawPass::Depth : DrawPass::All; + case ShadowsCastingMode::StaticOnly: + return IsOfflinePass ? DrawPass::All : ~DrawPass::Depth; + case ShadowsCastingMode::None: + return ~DrawPass::Depth; + default: + return DrawPass::All; + } + } public: // Camera's View * Projection matrix diff --git a/Source/Engine/Level/Scene/SceneRendering.cpp b/Source/Engine/Level/Scene/SceneRendering.cpp index 8dcde5afc..111a30f65 100644 --- a/Source/Engine/Level/Scene/SceneRendering.cpp +++ b/Source/Engine/Level/Scene/SceneRendering.cpp @@ -41,12 +41,26 @@ void SceneRendering::Draw(RenderContext& renderContext) { for (int32 i = 0; i < Actors.Count(); i++) { - auto e = Actors[i]; + auto e = Actors.Get()[i]; e.Bounds.Center -= origin; if (view.RenderLayersMask.Mask & e.LayerMask && (e.NoCulling || frustum.Intersects(e.Bounds)) && e.Actor->GetStaticFlags() & view.StaticFlagsMask) { #if SCENE_RENDERING_USE_PROFILER PROFILE_CPU_ACTOR(e.Actor); +#endif + e.Actor->Draw(renderContext); + } + } + } + else if (origin.IsZero()) + { + for (int32 i = 0; i < Actors.Count(); i++) + { + auto e = Actors.Get()[i]; + if (view.RenderLayersMask.Mask & e.LayerMask && (e.NoCulling || frustum.Intersects(e.Bounds))) + { +#if SCENE_RENDERING_USE_PROFILER + PROFILE_CPU_ACTOR(e.Actor); #endif e.Actor->Draw(renderContext); } @@ -56,7 +70,7 @@ void SceneRendering::Draw(RenderContext& renderContext) { for (int32 i = 0; i < Actors.Count(); i++) { - auto e = Actors[i]; + auto e = Actors.Get()[i]; e.Bounds.Center -= origin; if (view.RenderLayersMask.Mask & e.LayerMask && (e.NoCulling || frustum.Intersects(e.Bounds))) { diff --git a/Source/Engine/Streaming/StreamingHandlers.cpp b/Source/Engine/Streaming/StreamingHandlers.cpp index 17ca1c6f5..8c848356e 100644 --- a/Source/Engine/Streaming/StreamingHandlers.cpp +++ b/Source/Engine/Streaming/StreamingHandlers.cpp @@ -104,22 +104,20 @@ int32 ModelsStreamingHandler::CalculateResidency(StreamableResource* resource, f if (quality < ZeroTolerance) return 0; ASSERT(resource); - auto& model = *(Model*)resource; - + const auto& model = *(Model*)resource; const int32 lodCount = model.GetLODsCount(); - int32 lods = Math::CeilToInt(quality * (float)lodCount); - ASSERT(model.IsValidLODIndex(lods - 1)); + const int32 lods = Math::CeilToInt(quality * (float)lodCount); return lods; } int32 ModelsStreamingHandler::CalculateRequestedResidency(StreamableResource* resource, int32 targetResidency) { ASSERT(resource); - auto& model = *(Model*)resource; + const auto& model = *(Model*)resource; // Always load only single LOD at once int32 residency = targetResidency; - int32 currentResidency = model.GetCurrentResidency(); + const int32 currentResidency = model.GetCurrentResidency(); if (currentResidency < targetResidency) { // Up @@ -145,22 +143,20 @@ int32 SkinnedModelsStreamingHandler::CalculateResidency(StreamableResource* reso if (quality < ZeroTolerance) return 0; ASSERT(resource); - auto& model = *(SkinnedModel*)resource; - + const auto& model = *(SkinnedModel*)resource; const int32 lodCount = model.GetLODsCount(); - int32 lods = Math::CeilToInt(quality * (float)lodCount); - ASSERT(model.IsValidLODIndex(lods - 1)); + const int32 lods = Math::CeilToInt(quality * (float)lodCount); return lods; } int32 SkinnedModelsStreamingHandler::CalculateRequestedResidency(StreamableResource* resource, int32 targetResidency) { ASSERT(resource); - auto& model = *(SkinnedModel*)resource; + const auto& model = *(SkinnedModel*)resource; // Always load only single LOD at once int32 residency = targetResidency; - int32 currentResidency = model.GetCurrentResidency(); + const int32 currentResidency = model.GetCurrentResidency(); if (currentResidency < targetResidency) { // Up