Optimize some code by manual inlining
This commit is contained in:
@@ -54,16 +54,6 @@ public:
|
||||
return _loadedLODs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified index is a valid LOD index.
|
||||
/// </summary>
|
||||
/// <param name="index">The index.</param>
|
||||
/// <returns>True if the specified index is a valid LOD index, otherwise false.</returns>
|
||||
FORCE_INLINE bool IsValidLODIndex(int32 index) const
|
||||
{
|
||||
return Math::IsInRange(index, 0, LODs.Count() - 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clamps the index of the LOD to be valid for rendering (only loaded LODs).
|
||||
/// </summary>
|
||||
@@ -79,7 +69,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE int32 HighestResidentLODIndex() const
|
||||
{
|
||||
return GetLODsCount() - _loadedLODs;
|
||||
return LODs.Count() - _loadedLODs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -55,16 +55,6 @@ public:
|
||||
return _loadedLODs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified index is a valid LOD index.
|
||||
/// </summary>
|
||||
/// <param name="index">The index.</param>
|
||||
/// <returns>True if the specified index is a valid LOD index, otherwise false.</returns>
|
||||
FORCE_INLINE bool IsValidLODIndex(int32 index) const
|
||||
{
|
||||
return Math::IsInRange(index, 0, LODs.Count() - 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clamps the index of the LOD to be valid for rendering (only loaded LODs).
|
||||
/// </summary>
|
||||
@@ -80,7 +70,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE int32 HighestResidentLODIndex() const
|
||||
{
|
||||
return GetLODsCount() - _loadedLODs;
|
||||
return LODs.Count() - _loadedLODs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)))
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user