diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 657c66325..df9cac33b 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -534,6 +534,8 @@ void CStateManager::BuildDynamicLightListForWorld() { } x8e0_dynamicLights.clear(); + x8e0_dynamicLights.reserve(GetLightObjectList().size()); + for (const CEntity* ent : GetLightObjectList()) { const auto& light = static_cast(*ent); if (light.GetActive()) { @@ -543,7 +545,18 @@ void CStateManager::BuildDynamicLightListForWorld() { } } } + + std::sort(x8e0_dynamicLights.begin(), x8e0_dynamicLights.end(), [](const CLight& a, const CLight& b) { + if (b.GetPriority() > a.GetPriority()) { + return true; + } else if (b.GetPriority() == a.GetPriority()) { + return a.GetIntensity() > b.GetIntensity(); + } else { + return false; + } + }); } + void CStateManager::DrawDebugStuff() const { if (com_developer != nullptr && !com_developer->toBoolean()) { return; diff --git a/Runtime/Graphics/CLight.hpp b/Runtime/Graphics/CLight.hpp index 5a31628e1..7610b1c31 100644 --- a/Runtime/Graphics/CLight.hpp +++ b/Runtime/Graphics/CLight.hpp @@ -90,6 +90,7 @@ public: ELightType GetType() const { return x1c_type; } u32 GetId() const { return x40_lightId; } + u32 GetPriority() const { return x3c_priority; } float GetIntensity() const; float GetRadius() const; const zeus::CColor& GetColor() const { return x18_color; }