From 5345e615a131c588af7b4ef44a1baf34a31abc66 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Mar 2015 18:17:44 +0100 Subject: [PATCH 01/21] (SimpleTextDrawer) Added GetText method Former-commit-id: e4a6b7d915f05fdaef840e3a8320c2180415631f --- include/Nazara/Utility/SimpleTextDrawer.hpp | 1 + src/Nazara/Utility/SimpleTextDrawer.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/Nazara/Utility/SimpleTextDrawer.hpp b/include/Nazara/Utility/SimpleTextDrawer.hpp index 5793fdce2..0f6046fe5 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.hpp +++ b/include/Nazara/Utility/SimpleTextDrawer.hpp @@ -26,6 +26,7 @@ class NAZARA_API NzSimpleTextDrawer : public NzAbstractTextDrawer, NzObjectListe const NzColor& GetColor() const; NzFont* GetFont() const; nzUInt32 GetStyle() const; + const NzString& GetText() const; void SetCharacterSize(unsigned int characterSize); void SetColor(const NzColor& color); diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index 020ad021d..2cc3051af 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -42,6 +42,11 @@ nzUInt32 NzSimpleTextDrawer::GetStyle() const return m_style; } +const NzString& NzSimpleTextDrawer::GetText() const +{ + return m_text; +} + void NzSimpleTextDrawer::SetCharacterSize(unsigned int characterSize) { m_characterSize = characterSize; From 36b39ec868df49b69d297c86ebf18d701ee55d33 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Mar 2015 18:17:52 +0100 Subject: [PATCH 02/21] Alphabetical commit Former-commit-id: 4f1e73bd1228fefefd7f788adcd3ccb396d0b141 --- include/Nazara/Graphics/View.hpp | 2 +- src/Nazara/Graphics/View.cpp | 36 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/Nazara/Graphics/View.hpp b/include/Nazara/Graphics/View.hpp index b10b30cc0..30f8ba73c 100644 --- a/include/Nazara/Graphics/View.hpp +++ b/include/Nazara/Graphics/View.hpp @@ -46,8 +46,8 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget float GetZFar() const; float GetZNear() const; - NzVector2i MapWorldToPixel(const NzVector2f& coords); NzVector2f MapPixelToWorld(const NzVector2i& pixel); + NzVector2i MapWorldToPixel(const NzVector2f& coords); void SetSize(const NzVector2f& size); void SetSize(float width, float height); diff --git a/src/Nazara/Graphics/View.cpp b/src/Nazara/Graphics/View.cpp index 65c636f1c..b58e10ead 100644 --- a/src/Nazara/Graphics/View.cpp +++ b/src/Nazara/Graphics/View.cpp @@ -170,6 +170,24 @@ float NzView::GetZNear() const return m_zNear; } +NzVector2f NzView::MapPixelToWorld(const NzVector2i& pixel) +{ + if (!m_invViewProjMatrixUpdated) + UpdateInvViewProjMatrix(); + + if (!m_viewportUpdated) + UpdateViewport(); + + // Conversion du viewport en flottant + NzRectf viewport(m_viewport); + + NzVector2f normalized; + normalized.x = -1.f + 2.f * (pixel.x - viewport.x) / viewport.width; + normalized.y = 1.f - 2.f * (pixel.y - viewport.y) / viewport.height; + + return m_invViewProjMatrix.Transform(normalized); +} + NzVector2i NzView::MapWorldToPixel(const NzVector2f& coords) { if (!m_viewProjMatrixUpdated) @@ -190,24 +208,6 @@ NzVector2i NzView::MapWorldToPixel(const NzVector2f& coords) return pixel; } -NzVector2f NzView::MapPixelToWorld(const NzVector2i& pixel) -{ - if (!m_invViewProjMatrixUpdated) - UpdateInvViewProjMatrix(); - - if (!m_viewportUpdated) - UpdateViewport(); - - // Conversion du viewport en flottant - NzRectf viewport(m_viewport); - - NzVector2f normalized; - normalized.x = -1.f + 2.f * (pixel.x - viewport.x) / viewport.width; - normalized.y = 1.f - 2.f * (pixel.y - viewport.y) / viewport.height; - - return m_invViewProjMatrix.Transform(normalized); -} - void NzView::SetSize(const NzVector2f& size) { SetSize(size.x, size.y); From 88c3b9d482f7948e8aa5a38dcf31e054a13033f6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 24 Mar 2015 12:50:04 +0100 Subject: [PATCH 03/21] Added LuaInstance::Call Former-commit-id: 3bbf04804868ab46dfcf1f9c30ad4de621c880b8 --- include/Nazara/Lua/LuaInstance.hpp | 3 +++ src/Nazara/Lua/LuaInstance.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index f694c2fe7..b959b61db 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -35,6 +35,9 @@ class NAZARA_API NzLuaInstance : NzNonCopyable int ArgError(unsigned int argNum, const char* error); int ArgError(unsigned int argNum, const NzString& error); + bool Call(unsigned int argCount); + bool Call(unsigned int argCount, unsigned int resultCount); + void CheckAny(int index) const; bool CheckBoolean(int index) const; bool CheckBoolean(int index, bool defValue) const; diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index c1e1fa875..710e039e2 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -159,6 +159,16 @@ int NzLuaInstance::ArgError(unsigned int argNum, const NzString& error) return luaL_argerror(m_state, argNum, error.GetConstBuffer()); } +bool NzLuaInstance::Call(unsigned int argCount) +{ + return lua_pcall(m_state, argCount, LUA_MULTRET, 0) == LUA_OK; +} + +bool NzLuaInstance::Call(unsigned int argCount, unsigned int resultCount) +{ + return lua_pcall(m_state, argCount, resultCount, 0) == LUA_OK; +} + void NzLuaInstance::CheckAny(int index) const { luaL_checkany(m_state, index); From bcefe9462d2ead9ba3c40743bc0be93158a06e8d Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 24 Mar 2015 13:12:35 +0100 Subject: [PATCH 04/21] (LuaInstance) Added Lua 5.3 operators Former-commit-id: 17d1c8e325a1ee5441dac1f8d86d0a01dc5d8270 --- include/Nazara/Lua/Enums.hpp | 7 +++++++ src/Nazara/Lua/LuaInstance.cpp | 21 ++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/Nazara/Lua/Enums.hpp b/include/Nazara/Lua/Enums.hpp index 8e54ed526..199c539e0 100644 --- a/include/Nazara/Lua/Enums.hpp +++ b/include/Nazara/Lua/Enums.hpp @@ -19,8 +19,15 @@ enum nzLuaComparison enum nzLuaOperation { nzLuaOperation_Addition, + nzLuaOperation_BitwiseAnd, + nzLuaOperation_BitwiseLeftShift, + nzLuaOperation_BitwiseNot, + nzLuaOperation_BitwiseOr, + nzLuaOperation_BitwideRightShift, + nzLuaOperation_BitwiseXOr, nzLuaOperation_Division, nzLuaOperation_Exponentiation, + nzLuaOperation_FloorDivision, nzLuaOperation_Modulo, nzLuaOperation_Multiplication, nzLuaOperation_Negation, diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index 710e039e2..955cb1db8 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -95,13 +95,20 @@ namespace static_assert(sizeof(s_comparisons)/sizeof(int) == nzLuaComparison_Max+1, "Lua comparison array is incomplete"); int s_operations[] = { - LUA_OPADD, // nzLuaOperation_Addition - LUA_OPDIV, // nzLuaOperation_Division - LUA_OPPOW, // nzLuaOperation_Exponentiation - LUA_OPMOD, // nzLuaOperation_Modulo - LUA_OPMUL, // nzLuaOperation_Multiplication - LUA_OPUNM, // nzLuaOperation_Negation - LUA_OPSUB // nzLuaOperation_Substraction + LUA_OPADD, // nzLuaOperation_Addition + LUA_OPBAND, // nzLuaOperation_BitwiseAnd + LUA_OPSHL, // nzLuaOperation_BitwiseLeftShift + LUA_OPBNOT, // nzLuaOperation_BitwiseNot + LUA_OPBOR, // nzLuaOperation_BitwiseOr + LUA_OPSHR, // nzLuaOperation_BitwiseRightShift + LUA_OPBXOR, // nzLuaOperation_BitwiseXOr + LUA_OPDIV, // nzLuaOperation_Division + LUA_OPPOW, // nzLuaOperation_Exponentiation + LUA_OPIDIV, // nzLuaOperation_FloorDivision + LUA_OPMUL, // nzLuaOperation_Multiplication + LUA_OPMOD, // nzLuaOperation_Modulo + LUA_OPUNM, // nzLuaOperation_Negation + LUA_OPSUB // nzLuaOperation_Substraction }; static_assert(sizeof(s_operations)/sizeof(int) == nzLuaOperation_Max+1, "Lua operation array is incomplete"); From 3e16369d099ba7cc651c4660c3f2489e8d47b26b Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 28 Mar 2015 14:42:11 +0100 Subject: [PATCH 05/21] (Camera) Fixed SetTarget not invalidating viewport and stuff Former-commit-id: ecce5389ffc3497828a9864a5ee46f597bdbfb76 --- src/Nazara/Graphics/Camera.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Nazara/Graphics/Camera.cpp b/src/Nazara/Graphics/Camera.cpp index ba7539481..6b51c0fb5 100644 --- a/src/Nazara/Graphics/Camera.cpp +++ b/src/Nazara/Graphics/Camera.cpp @@ -171,6 +171,10 @@ void NzCamera::SetTarget(const NzRenderTarget* renderTarget) m_target = renderTarget; if (m_target) m_target->AddListener(this); + + m_frustumUpdated = false; + m_projectionMatrixUpdated = false; + m_viewportUpdated = false; } void NzCamera::SetTarget(const NzRenderTarget& renderTarget) From 23cefe1fbe0f125f7876b0e960e65785d97bf39b Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 28 Mar 2015 14:45:21 +0100 Subject: [PATCH 06/21] (LuaInstance) Fixed Call() not resetting time limiter clock Former-commit-id: 0d397fc21682f85114dc892eaea98a8f54969cde --- include/Nazara/Lua/LuaInstance.hpp | 2 +- src/Nazara/Lua/LuaInstance.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index b959b61db..45bad2276 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -149,7 +149,7 @@ class NAZARA_API NzLuaInstance : NzNonCopyable static NzLuaInstance* GetInstance(lua_State* state); private: - bool Run(); + bool Run(int argCount, int resultCount); static void* MemoryAllocator(void *ud, void *ptr, std::size_t osize, std::size_t nsize); static int ProxyFunc(lua_State* state); diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index 955cb1db8..3aa8f9a23 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -168,12 +168,12 @@ int NzLuaInstance::ArgError(unsigned int argNum, const NzString& error) bool NzLuaInstance::Call(unsigned int argCount) { - return lua_pcall(m_state, argCount, LUA_MULTRET, 0) == LUA_OK; + return Run(argCount, LUA_MULTRET); } bool NzLuaInstance::Call(unsigned int argCount, unsigned int resultCount) { - return lua_pcall(m_state, argCount, resultCount, 0) == LUA_OK; + return Run(argCount, resultCount); } void NzLuaInstance::CheckAny(int index) const @@ -387,7 +387,7 @@ bool NzLuaInstance::Execute(const NzString& code) return false; } - return Run(); + return Run(0, 0); } bool NzLuaInstance::ExecuteFromFile(const NzString& filePath) @@ -433,7 +433,7 @@ bool NzLuaInstance::ExecuteFromStream(NzInputStream& stream) return false; } - return Run(); + return Run(0, 0); } int NzLuaInstance::GetAbsIndex(int index) const @@ -830,12 +830,12 @@ NzLuaInstance* NzLuaInstance::GetInstance(lua_State* state) return instance; } -bool NzLuaInstance::Run() +bool NzLuaInstance::Run(int argCount, int resultCount) { if (m_level++ == 0) m_clock.Restart(); - int status = lua_pcall(m_state, 0, 0, 0); + int status = lua_pcall(m_state, argCount, resultCount, 0); m_level--; From 40321cf9b1d3304ae482f2883957357792b8e525 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 28 Mar 2015 14:54:52 +0100 Subject: [PATCH 07/21] (RenderTexture) Fixed size computation Former-commit-id: 67f6408f0fe88af5066f9eb2c29f2426673db7cd --- include/Nazara/Renderer/RenderTexture.hpp | 1 + src/Nazara/Renderer/RenderTexture.cpp | 37 ++++++++++++++--------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/Nazara/Renderer/RenderTexture.hpp b/include/Nazara/Renderer/RenderTexture.hpp index 68460eeed..43c5b0cd0 100644 --- a/include/Nazara/Renderer/RenderTexture.hpp +++ b/include/Nazara/Renderer/RenderTexture.hpp @@ -68,6 +68,7 @@ class NAZARA_API NzRenderTexture : public NzRenderTarget, NzObjectListener, NzNo private: bool OnObjectDestroy(const NzRefCounted* object, int index) override; void UpdateDrawBuffers() const; + void UpdateSize() const; void UpdateTargets() const; NzRenderTextureImpl* m_impl = nullptr; diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp index 4f1b53962..e83ac9467 100644 --- a/src/Nazara/Renderer/RenderTexture.cpp +++ b/src/Nazara/Renderer/RenderTexture.cpp @@ -74,6 +74,7 @@ struct NzRenderTextureImpl bool complete = false; bool userDefinedTargets = false; mutable bool drawBuffersUpdated = true; + mutable bool sizeUpdated = false; mutable bool targetsUpdated = true; unsigned int height; unsigned int width; @@ -171,6 +172,7 @@ bool NzRenderTexture::AttachBuffer(nzAttachmentPoint attachmentPoint, nzUInt8 in attachment.width = buffer->GetWidth(); m_impl->checked = false; + m_impl->sizeUpdated = false; if (attachmentPoint == nzAttachmentPoint_Color && !m_impl->userDefinedTargets) { @@ -316,6 +318,7 @@ bool NzRenderTexture::AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 i attachment.width = texture->GetWidth(); m_impl->checked = false; + m_impl->sizeUpdated = false; if (attachmentPoint == nzAttachmentPoint_Color && !m_impl->userDefinedTargets) { @@ -469,8 +472,8 @@ unsigned int NzRenderTexture::GetHeight() const } #endif - if (!m_impl->targetsUpdated) - UpdateTargets(); + if (!m_impl->sizeUpdated) + UpdateSize(); return m_impl->height; } @@ -499,8 +502,8 @@ NzVector2ui NzRenderTexture::GetSize() const } #endif - if (!m_impl->targetsUpdated) - UpdateTargets(); + if (!m_impl->sizeUpdated) + UpdateSize(); return NzVector2ui(m_impl->width, m_impl->height); } @@ -515,8 +518,8 @@ unsigned int NzRenderTexture::GetWidth() const } #endif - if (!m_impl->targetsUpdated) - UpdateTargets(); + if (!m_impl->sizeUpdated) + UpdateSize(); return m_impl->width; } @@ -915,11 +918,21 @@ void NzRenderTexture::UpdateDrawBuffers() const m_impl->drawBuffersUpdated = true; } +void NzRenderTexture::UpdateSize() const +{ + m_impl->width = 0; + m_impl->height = 0; + for (Attachment& attachment : m_impl->attachments) + { + m_impl->height = std::max(m_impl->height, attachment.height); + m_impl->width = std::max(m_impl->width, attachment.width); + } + + m_impl->sizeUpdated = true; +} + void NzRenderTexture::UpdateTargets() const { - m_impl->width = std::numeric_limits::max(); - m_impl->height = std::numeric_limits::max(); - if (m_impl->colorTargets.empty()) { m_impl->drawBuffers.resize(1); @@ -930,13 +943,7 @@ void NzRenderTexture::UpdateTargets() const m_impl->drawBuffers.resize(m_impl->colorTargets.size()); GLenum* ptr = &m_impl->drawBuffers[0]; for (nzUInt8 index : m_impl->colorTargets) - { *ptr++ = GL_COLOR_ATTACHMENT0 + index; - - Attachment& attachment = m_impl->attachments[attachmentIndex[nzAttachmentPoint_Color] + index]; - m_impl->height = std::min(m_impl->height, attachment.height); - m_impl->width = std::min(m_impl->width, attachment.width); - } } m_impl->targetsUpdated = true; From fca2dad9d3eae46cb2e2c218fe10c286d0c82cc9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Apr 2015 20:14:03 +0200 Subject: [PATCH 09/21] (SimpleTextDrawer) Fixed some methods visibility Former-commit-id: 39bad2d5e64f7132f5cd4d4a949d6d3fbb5b98e1 --- include/Nazara/Utility/SimpleTextDrawer.hpp | 9 ++- src/Nazara/Utility/SimpleTextDrawer.cpp | 68 ++++++++++----------- 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/include/Nazara/Utility/SimpleTextDrawer.hpp b/include/Nazara/Utility/SimpleTextDrawer.hpp index 0f6046fe5..a84f8a2c3 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.hpp +++ b/include/Nazara/Utility/SimpleTextDrawer.hpp @@ -25,6 +25,10 @@ class NAZARA_API NzSimpleTextDrawer : public NzAbstractTextDrawer, NzObjectListe unsigned int GetCharacterSize() const; const NzColor& GetColor() const; NzFont* GetFont() const; + NzFont* GetFont(unsigned int index) const override; + unsigned int GetFontCount() const override; + const Glyph& GetGlyph(unsigned int index) const override; + unsigned int GetGlyphCount() const override; nzUInt32 GetStyle() const; const NzString& GetText() const; @@ -38,11 +42,6 @@ class NAZARA_API NzSimpleTextDrawer : public NzAbstractTextDrawer, NzObjectListe static NzSimpleTextDrawer Draw(NzFont* font, const NzString& str, unsigned int characterSize, nzUInt32 style = nzTextStyle_Regular, const NzColor& color = NzColor::White); private: - NzFont* GetFont(unsigned int index) const override; - unsigned int GetFontCount() const override; - const Glyph& GetGlyph(unsigned int index) const override; - unsigned int GetGlyphCount() const override; - bool OnObjectModified(const NzRefCounted* object, int index, unsigned int code) override; void OnObjectReleased(const NzRefCounted* object, int index) override; void UpdateGlyphs() const; diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index 2cc3051af..f8fe74841 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -37,6 +37,40 @@ NzFont* NzSimpleTextDrawer::GetFont() const return m_font; } +NzFont* NzSimpleTextDrawer::GetFont(unsigned int index) const +{ + #if NAZARA_UTILITY_SAFE + if (index > 0) + { + NazaraError("Font index out of range (" + NzString::Number(index) + " >= 1)"); + return nullptr; + } + #endif + + return m_font; +} + +unsigned int NzSimpleTextDrawer::GetFontCount() const +{ + return 1; +} + +const NzAbstractTextDrawer::Glyph& NzSimpleTextDrawer::GetGlyph(unsigned int index) const +{ + if (!m_glyphUpdated) + UpdateGlyphs(); + + return m_glyphs[index]; +} + +unsigned int NzSimpleTextDrawer::GetGlyphCount() const +{ + if (!m_glyphUpdated) + UpdateGlyphs(); + + return m_glyphs.size(); +} + nzUInt32 NzSimpleTextDrawer::GetStyle() const { return m_style; @@ -106,40 +140,6 @@ NzSimpleTextDrawer NzSimpleTextDrawer::Draw(NzFont* font, const NzString& str, u return drawer; } -NzFont* NzSimpleTextDrawer::GetFont(unsigned int index) const -{ - #if NAZARA_UTILITY_SAFE - if (index > 0) - { - NazaraError("Font index out of range (" + NzString::Number(index) + " >= 1)"); - return nullptr; - } - #endif - - return m_font; -} - -unsigned int NzSimpleTextDrawer::GetFontCount() const -{ - return 1; -} - -const NzAbstractTextDrawer::Glyph& NzSimpleTextDrawer::GetGlyph(unsigned int index) const -{ - if (!m_glyphUpdated) - UpdateGlyphs(); - - return m_glyphs[index]; -} - -unsigned int NzSimpleTextDrawer::GetGlyphCount() const -{ - if (!m_glyphUpdated) - UpdateGlyphs(); - - return m_glyphs.size(); -} - bool NzSimpleTextDrawer::OnObjectModified(const NzRefCounted* object, int index, unsigned int code) { NazaraUnused(object); From 51942c1eb9d5f2159c41873fdeeadd6eadfaff10 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 7 Apr 2015 17:42:00 +0200 Subject: [PATCH 10/21] (GuillotineBinPack) Improved readability Former-commit-id: a65647370d30dfe110ba38c65afc850328f84b01 --- include/Nazara/Core/GuillotineBinPack.hpp | 41 ++++++++++++----------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/include/Nazara/Core/GuillotineBinPack.hpp b/include/Nazara/Core/GuillotineBinPack.hpp index c1562ba3a..10aa9ab89 100644 --- a/include/Nazara/Core/GuillotineBinPack.hpp +++ b/include/Nazara/Core/GuillotineBinPack.hpp @@ -18,25 +18,8 @@ class NAZARA_API NzGuillotineBinPack { public: - enum FreeRectChoiceHeuristic - { - RectBestAreaFit, - RectBestLongSideFit, - RectBestShortSideFit, - RectWorstAreaFit, - RectWorstLongSideFit, - RectWorstShortSideFit - }; - - enum GuillotineSplitHeuristic - { - SplitLongerAxis, - SplitLongerLeftoverAxis, - SplitMaximizeArea, - SplitMinimizeArea, - SplitShorterAxis, - SplitShorterLeftoverAxis - }; + enum FreeRectChoiceHeuristic : int; + enum GuillotineSplitHeuristic : int; NzGuillotineBinPack(); NzGuillotineBinPack(unsigned int width, unsigned int height); @@ -70,6 +53,26 @@ class NAZARA_API NzGuillotineBinPack NzGuillotineBinPack& operator=(const NzGuillotineBinPack&) = default; NzGuillotineBinPack& operator=(NzGuillotineBinPack&&) = default; + enum FreeRectChoiceHeuristic : int + { + RectBestAreaFit, + RectBestLongSideFit, + RectBestShortSideFit, + RectWorstAreaFit, + RectWorstLongSideFit, + RectWorstShortSideFit + }; + + enum GuillotineSplitHeuristic : int + { + SplitLongerAxis, + SplitLongerLeftoverAxis, + SplitMaximizeArea, + SplitMinimizeArea, + SplitShorterAxis, + SplitShorterLeftoverAxis + }; + private: void SplitFreeRectAlongAxis(const NzRectui& freeRect, const NzRectui& placedRect, bool splitHorizontal); void SplitFreeRectByHeuristic(const NzRectui& freeRect, const NzRectui& placedRect, GuillotineSplitHeuristic method); From 0404927663aa51c76d65ee4a1498453acd5f3201 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 7 Apr 2015 17:42:36 +0200 Subject: [PATCH 11/21] Fixed some files encoding Former-commit-id: 78d0389774a67043d5e59e66b77ff4a1760dd1f4 --- include/Nazara/Physics/Debug.hpp | 2 +- include/Nazara/Physics/DebugOff.hpp | 4 ++-- include/Nazara/Physics/Geom.hpp | 2 +- include/Nazara/Physics/Physics.hpp | 2 +- src/Nazara/Physics/Debug/NewOverload.cpp | 4 ++-- src/Nazara/Physics/Geom.cpp | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/Nazara/Physics/Debug.hpp b/include/Nazara/Physics/Debug.hpp index c97bc63f7..3f3d8fe41 100644 --- a/include/Nazara/Physics/Debug.hpp +++ b/include/Nazara/Physics/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics/DebugOff.hpp b/include/Nazara/Physics/DebugOff.hpp index 6e6dd97a4..4ea033e46 100644 --- a/include/Nazara/Physics/DebugOff.hpp +++ b/include/Nazara/Physics/DebugOff.hpp @@ -1,8 +1,8 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp -// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp #if NAZARA_PHYSICS_MANAGE_MEMORY #undef delete #undef new diff --git a/include/Nazara/Physics/Geom.hpp b/include/Nazara/Physics/Geom.hpp index 5c851ee30..bab915f55 100644 --- a/include/Nazara/Physics/Geom.hpp +++ b/include/Nazara/Physics/Geom.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics/Physics.hpp b/include/Nazara/Physics/Physics.hpp index c4da3db7f..9fa7649a9 100644 --- a/include/Nazara/Physics/Physics.hpp +++ b/include/Nazara/Physics/Physics.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics/Debug/NewOverload.cpp b/src/Nazara/Physics/Debug/NewOverload.cpp index ed0126e77..4e991cb2c 100644 --- a/src/Nazara/Physics/Debug/NewOverload.cpp +++ b/src/Nazara/Physics/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -6,7 +6,7 @@ #if NAZARA_PHYSICS_MANAGE_MEMORY #include -#include // Nécessaire ? +#include // Nécessaire ? void* operator new(std::size_t size) { diff --git a/src/Nazara/Physics/Geom.cpp b/src/Nazara/Physics/Geom.cpp index 8bb344ba4..03654651a 100644 --- a/src/Nazara/Physics/Geom.cpp +++ b/src/Nazara/Physics/Geom.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -48,7 +48,7 @@ NzBoxf NzBaseGeom::ComputeAABB(const NzVector3f& translation, const NzQuaternion NzVector3f min, max; NewtonCollisionCalculateAABB(m_collision, NzMatrix4f::Transform(translation, rotation), min, max); - // Et on applique le scale à la fin + // Et on applique le scale à la fin return NzBoxf(scale*min, scale*max); } From 301bb56efce066cb09b86b2d69aefe05470ea95e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 2 May 2015 09:14:45 +0200 Subject: [PATCH 12/21] Core/ParameterList: Fixed compilation Thanks to Bl4ckb0ne Former-commit-id: eca68dafb00ffcefc00a5c2e3177f26ca14d10dd --- src/Nazara/Core/ParameterList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index 746f70ce6..2bafb827f 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -267,7 +267,7 @@ bool NzParameterList::GetUserdataParameter(const NzString& name, void** value) c else { NazaraError("Parameter value is not an userdata"); - return nullptr; + return false; } } From b29d1ffcd80b3bc72bdd104e9c6b42b8bab6a319 Mon Sep 17 00:00:00 2001 From: Youri Hubaut Date: Sat, 2 May 2015 16:19:46 +0200 Subject: [PATCH 13/21] Little fixes and recursive mutex in NzFile Former-commit-id: 7b5f3a6b14d027dc664e5d220257a22caca25c95 --- src/Nazara/Core/ConditionVariable.cpp | 2 +- src/Nazara/Core/File.cpp | 23 +++++++++---------- src/Nazara/Core/MemoryManager.cpp | 3 +++ .../Core/Posix/ConditionVariableImpl.cpp | 2 +- src/Nazara/Core/Posix/DirectoryImpl.cpp | 11 +++++---- src/Nazara/Core/Posix/MutexImpl.cpp | 2 +- src/Nazara/Core/Posix/ThreadImpl.cpp | 4 ++-- src/Nazara/Core/Win32/TaskSchedulerImpl.cpp | 2 +- 8 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/Nazara/Core/ConditionVariable.cpp b/src/Nazara/Core/ConditionVariable.cpp index ac8dcd50a..b9194d233 100644 --- a/src/Nazara/Core/ConditionVariable.cpp +++ b/src/Nazara/Core/ConditionVariable.cpp @@ -11,7 +11,7 @@ #elif defined(NAZARA_PLATFORM_POSIX) #include #else - #error Thread condition has no implementation + #error Condition variable has no implementation #endif #include diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 6c38f30f7..d0959b56e 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -85,10 +85,10 @@ void NzFile::Close() bool NzFile::Delete() { - NazaraLock(m_mutex) - Close(); + NazaraLock(m_mutex) + return Delete(m_filePath); } @@ -266,11 +266,12 @@ std::size_t NzFile::Read(void* buffer, std::size_t typeSize, unsigned int count) bool NzFile::Rename(const NzString& newFilePath) { - NazaraLock(m_mutex) - bool opened = IsOpen(); + Close(); + NazaraLock(m_mutex) + bool success = Rename(m_filePath, newFilePath); if (success) m_filePath = NormalizePath(newFilePath); @@ -283,10 +284,10 @@ bool NzFile::Rename(const NzString& newFilePath) bool NzFile::Open(unsigned long openMode) { - NazaraLock(m_mutex) - Close(); + NazaraLock(m_mutex) + if (m_filePath.IsEmpty()) return false; @@ -314,8 +315,6 @@ bool NzFile::Open(unsigned long openMode) bool NzFile::Open(const NzString& filePath, unsigned long openMode) { - NazaraLock(m_mutex) - Close(); SetFile(filePath); @@ -361,10 +360,10 @@ void NzFile::SetEndianness(nzEndianness endianness) bool NzFile::SetFile(const NzString& filePath) { - NazaraLock(m_mutex) - if (IsOpen()) { + NazaraLock(m_mutex) + if (filePath.IsEmpty()) return false; @@ -446,8 +445,6 @@ bool NzFile::Write(const NzString& string) std::size_t NzFile::Write(const void* buffer, std::size_t typeSize, unsigned int count) { - NazaraLock(m_mutex) - #if NAZARA_CORE_SAFE if (!IsOpen()) { @@ -462,6 +459,8 @@ std::size_t NzFile::Write(const void* buffer, std::size_t typeSize, unsigned int } #endif + NazaraLock(m_mutex) + if (!buffer || count == 0 || typeSize == 0) return 0; diff --git a/src/Nazara/Core/MemoryManager.cpp b/src/Nazara/Core/MemoryManager.cpp index a91133234..739c75d82 100644 --- a/src/Nazara/Core/MemoryManager.cpp +++ b/src/Nazara/Core/MemoryManager.cpp @@ -209,6 +209,7 @@ void NzMemoryManager::Initialize() #ifdef NAZARA_PLATFORM_WINDOWS InitializeCriticalSection(&s_mutex); + //#elif defined(NAZARA_PLATFORM_POSIX) is already done in the namespace #endif s_initialized = true; @@ -224,6 +225,8 @@ void NzMemoryManager::Uninitialize() { #ifdef NAZARA_PLATFORM_WINDOWS DeleteCriticalSection(&s_mutex); + #elif defined(NAZARA_PLATFORM_POSIX) + pthread_mutex_destroy(&s_mutex); #endif FILE* log = std::fopen(s_MLTFileName, "a"); diff --git a/src/Nazara/Core/Posix/ConditionVariableImpl.cpp b/src/Nazara/Core/Posix/ConditionVariableImpl.cpp index d75af776e..7a8ba8fc3 100644 --- a/src/Nazara/Core/Posix/ConditionVariableImpl.cpp +++ b/src/Nazara/Core/Posix/ConditionVariableImpl.cpp @@ -35,7 +35,7 @@ bool NzConditionVariableImpl::Wait(NzMutexImpl* mutex, nzUInt32 timeout) { // get the current time timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); // construct the time limit (current time + time to wait) timespec ti; diff --git a/src/Nazara/Core/Posix/DirectoryImpl.cpp b/src/Nazara/Core/Posix/DirectoryImpl.cpp index 50451edbe..9bd78e65f 100644 --- a/src/Nazara/Core/Posix/DirectoryImpl.cpp +++ b/src/Nazara/Core/Posix/DirectoryImpl.cpp @@ -82,14 +82,15 @@ bool NzDirectoryImpl::Exists(const NzString& dirPath) NzString NzDirectoryImpl::GetCurrent() { NzString currentPath; - char* path = new char[_PC_PATH_MAX]; + char* path = getcwd(nullptr, 0); - if (getcwd(path, _PC_PATH_MAX)) + if (path) + { currentPath = path; + free(path); + } else - NazaraError("Unable to get current directory: " + NzError::GetLastSystemError()); - - delete[] path; + NazaraError("Unable to get current directory: " + NzError::GetLastSystemError()); // Bug: initialisation -> if no path for log ! return currentPath; } diff --git a/src/Nazara/Core/Posix/MutexImpl.cpp b/src/Nazara/Core/Posix/MutexImpl.cpp index dee6078dc..0ed78092f 100644 --- a/src/Nazara/Core/Posix/MutexImpl.cpp +++ b/src/Nazara/Core/Posix/MutexImpl.cpp @@ -7,7 +7,7 @@ NzMutexImpl::NzMutexImpl() { - pthread_mutex_init(&m_handle, NULL); + pthread_mutex_init(&m_handle, nullptr); } NzMutexImpl::~NzMutexImpl() diff --git a/src/Nazara/Core/Posix/ThreadImpl.cpp b/src/Nazara/Core/Posix/ThreadImpl.cpp index c97abe19c..77099e3c0 100644 --- a/src/Nazara/Core/Posix/ThreadImpl.cpp +++ b/src/Nazara/Core/Posix/ThreadImpl.cpp @@ -57,9 +57,9 @@ void NzThreadImpl::Sleep(nzUInt32 time) // create a mutex and thread condition pthread_mutex_t mutex; - pthread_mutex_init(&mutex, 0); + pthread_mutex_init(&mutex, nullptr); pthread_cond_t condition; - pthread_cond_init(&condition, 0); + pthread_cond_init(&condition, nullptr); // wait... pthread_mutex_lock(&mutex); diff --git a/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp b/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp index f0a605d4a..4e1439c2d 100644 --- a/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp +++ b/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp @@ -11,7 +11,7 @@ bool NzTaskSchedulerImpl::Initialize(unsigned int workerCount) { - if (s_workerCount > 0) + if (IsInitialized()) return true; // Déjà initialisé #if NAZARA_CORE_SAFE From 100952d0b11ddcb7f207a1c353f4423b0d67e9a0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 2 May 2015 20:40:43 +0200 Subject: [PATCH 14/21] Core/ParameterList: Fixed typo Former-commit-id: b4e43b8072eebb74df1cc145968e80c1f449b3e0 --- src/Nazara/Core/ParameterList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index 2bafb827f..3add83482 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -266,7 +266,7 @@ bool NzParameterList::GetUserdataParameter(const NzString& name, void** value) c } else { - NazaraError("Parameter value is not an userdata"); + NazaraError("Parameter value is not a userdata"); return false; } } From 4bbb02eadc53f7c4a3101689b9d6bc40bdb9c8b9 Mon Sep 17 00:00:00 2001 From: Youri Hubaut Date: Sun, 3 May 2015 16:15:29 +0200 Subject: [PATCH 15/21] Revert Former-commit-id: cb73baf4bb2a95b65e8439ee552f7ad85ede1008 --- src/Nazara/Core/File.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index d0959b56e..1acee0122 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -85,10 +85,10 @@ void NzFile::Close() bool NzFile::Delete() { - Close(); - NazaraLock(m_mutex) + Close(); + return Delete(m_filePath); } @@ -266,12 +266,11 @@ std::size_t NzFile::Read(void* buffer, std::size_t typeSize, unsigned int count) bool NzFile::Rename(const NzString& newFilePath) { - bool opened = IsOpen(); - - Close(); - NazaraLock(m_mutex) + bool opened = IsOpen(); + Close(); + bool success = Rename(m_filePath, newFilePath); if (success) m_filePath = NormalizePath(newFilePath); @@ -284,10 +283,10 @@ bool NzFile::Rename(const NzString& newFilePath) bool NzFile::Open(unsigned long openMode) { - Close(); - NazaraLock(m_mutex) + Close(); + if (m_filePath.IsEmpty()) return false; @@ -315,6 +314,8 @@ bool NzFile::Open(unsigned long openMode) bool NzFile::Open(const NzString& filePath, unsigned long openMode) { + NazaraLock(m_mutex) + Close(); SetFile(filePath); @@ -360,10 +361,10 @@ void NzFile::SetEndianness(nzEndianness endianness) bool NzFile::SetFile(const NzString& filePath) { + NazaraLock(m_mutex) + if (IsOpen()) { - NazaraLock(m_mutex) - if (filePath.IsEmpty()) return false; @@ -445,6 +446,8 @@ bool NzFile::Write(const NzString& string) std::size_t NzFile::Write(const void* buffer, std::size_t typeSize, unsigned int count) { + NazaraLock(m_mutex) + #if NAZARA_CORE_SAFE if (!IsOpen()) { @@ -459,8 +462,6 @@ std::size_t NzFile::Write(const void* buffer, std::size_t typeSize, unsigned int } #endif - NazaraLock(m_mutex) - if (!buffer || count == 0 || typeSize == 0) return 0; @@ -732,7 +733,7 @@ bool NzFile::FillHash(NzAbstractHash* hash) const unsigned int size; while (remainingSize > 0) { - size = std::min(remainingSize, static_cast(NAZARA_CORE_FILE_BUFFERSIZE)); + size = static_cast(std::min(remainingSize, static_cast(NAZARA_CORE_FILE_BUFFERSIZE))); if (file.Read(&buffer[0], sizeof(char), size) != sizeof(char)*size) { NazaraError("Unable to read file"); From 7b2e6bb3f2a113a5a59e15defd8cf5f0aeceeb0d Mon Sep 17 00:00:00 2001 From: Youri Hubaut Date: Sun, 3 May 2015 16:15:48 +0200 Subject: [PATCH 16/21] NzMutex is now a recursive mutex Former-commit-id: c36c5543dfb8f79a6b961ef6c97aa9f647c93e57 --- src/Nazara/Core/Posix/MutexImpl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Core/Posix/MutexImpl.cpp b/src/Nazara/Core/Posix/MutexImpl.cpp index 0ed78092f..c53ad61ff 100644 --- a/src/Nazara/Core/Posix/MutexImpl.cpp +++ b/src/Nazara/Core/Posix/MutexImpl.cpp @@ -7,7 +7,11 @@ NzMutexImpl::NzMutexImpl() { - pthread_mutex_init(&m_handle, nullptr); + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + + pthread_mutex_init(&m_handle, &attr); } NzMutexImpl::~NzMutexImpl() From 4b43cc2d59286d1180deece9002daf664857b4d5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 3 May 2015 18:07:57 +0200 Subject: [PATCH 17/21] Core/MemoryManager: Made NextFree thread-safe Former-commit-id: e87a05254538b265761f836a35b1f00474fbf3c7 --- src/Nazara/Core/MemoryManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Core/MemoryManager.cpp b/src/Nazara/Core/MemoryManager.cpp index 8b7acfee9..651437b95 100644 --- a/src/Nazara/Core/MemoryManager.cpp +++ b/src/Nazara/Core/MemoryManager.cpp @@ -33,8 +33,8 @@ namespace bool s_initialized = false; const unsigned int s_magic = 0xDEADB33FUL; const char* s_logFileName = "NazaraMemory.log"; - const char* s_nextFreeFile = "(Internal error)"; - unsigned int s_nextFreeLine = 0; + thread_local const char* s_nextFreeFile = "(Internal error)"; + thread_local unsigned int s_nextFreeLine = 0; Block s_list = { From d7f48dfa7f50505c7ad776b24a1260f40a4033c4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 6 May 2015 23:29:46 +0200 Subject: [PATCH 19/21] Graphics/DeferredShading: Fixed phong lighting unifoms Former-commit-id: 09adf80261d29cb2518adddfb90b3173ab34b068 --- src/Nazara/Graphics/DeferredPhongLightingPass.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp index 1e7a306ae..bf9faac47 100644 --- a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp +++ b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp @@ -127,8 +127,8 @@ bool NzDeferredPhongLightingPass::Process(const NzScene* scene, unsigned int fir NzRenderer::SetRenderStates(lightStates); NzRenderer::SetShader(m_pointSpotLightShader); - m_pointSpotLightShader->SendColor(m_pointSpotLightShaderEyePositionLocation, scene->GetAmbientColor()); - m_pointSpotLightShader->SendVector(m_pointSpotLightShaderSceneAmbientLocation, scene->GetViewer()->GetEyePosition()); + m_pointSpotLightShader->SendColor(m_pointSpotLightShaderSceneAmbientLocation, scene->GetAmbientColor()); + m_pointSpotLightShader->SendVector(m_pointSpotLightShaderEyePositionLocation, scene->GetViewer()->GetEyePosition()); NzMatrix4f lightMatrix; lightMatrix.MakeIdentity(); From 1fff550c0603a23b590671c5d77b08a488eb28e8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 6 May 2015 23:31:42 +0200 Subject: [PATCH 20/21] Graphics/ForwardShading: Fixed non-lit translucide rendering Former-commit-id: dea27941badf51be183e9912c82be6f719015490 --- .../Graphics/ForwardRenderTechnique.cpp | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 5605812ec..bed2b9c40 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -658,9 +658,12 @@ void NzForwardRenderTechnique::DrawTransparentModels(const NzScene* scene) const shader->SendVector(shaderUniforms->eyePosition, viewer->GetEyePosition()); // On envoie les lumières directionnelles s'il y a (Les mêmes pour tous) - lightCount = std::min(m_directionalLights.GetLightCount(), NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); - for (unsigned int i = 0; i < lightCount; ++i) - m_directionalLights.GetLight(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i); + if (shaderUniforms->hasLightUniforms) + { + lightCount = std::min(m_directionalLights.GetLightCount(), NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); + for (unsigned int i = 0; i < lightCount; ++i) + m_directionalLights.GetLight(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i); + } lastShader = shader; } @@ -690,21 +693,24 @@ void NzForwardRenderTechnique::DrawTransparentModels(const NzScene* scene) const NzRenderer::SetIndexBuffer(indexBuffer); NzRenderer::SetVertexBuffer(vertexBuffer); - // Calcul des lumières les plus proches - if (lightCount < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS && !m_lights.IsEmpty()) + if (shaderUniforms->hasLightUniforms) { - NzVector3f position = matrix.GetTranslation() + modelData.squaredBoundingSphere.GetPosition(); - float radius = modelData.squaredBoundingSphere.radius; - unsigned int closestLightCount = m_lights.ComputeClosestLights(position, radius, NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS); + // Calcul des lumières les plus proches + if (lightCount < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS && !m_lights.IsEmpty()) + { + NzVector3f position = matrix.GetTranslation() + modelData.squaredBoundingSphere.GetPosition(); + float radius = modelData.squaredBoundingSphere.radius; + unsigned int closestLightCount = m_lights.ComputeClosestLights(position, radius, NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS); - unsigned int count = std::min(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS - lightCount, closestLightCount); - for (unsigned int i = 0; i < count; ++i) - m_lights.GetResult(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*(lightCount++)); + unsigned int count = std::min(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS - lightCount, closestLightCount); + for (unsigned int i = 0; i < count; ++i) + m_lights.GetResult(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*(lightCount++)); + } + + for (unsigned int i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) + NzLight::Disable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i); } - for (unsigned int i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) - NzLight::Disable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i); - NzRenderer::SetMatrix(nzMatrixType_World, matrix); drawFunc(meshData.primitiveMode, 0, indexCount); } From 55b94f2bbff65a06bfeca96efcde3edff52f869a Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 6 May 2015 23:33:07 +0200 Subject: [PATCH 21/21] Math/Matrix: Removed deprecated comment Former-commit-id: f29b0b453b1313e991f783e8e3be183faa29d8bd --- include/Nazara/Math/Matrix4.inl | 1 - 1 file changed, 1 deletion(-) diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index d689879d0..e3d172c32 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -748,7 +748,6 @@ NzMatrix4& NzMatrix4::Set(const T matrix[16]) template NzMatrix4& NzMatrix4::Set(const NzMatrix4& matrix) { - // Le membre isIdentity est copié en même temps que les valeurs std::memcpy(this, &matrix, sizeof(NzMatrix4)); return *this;