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); 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/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/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index f694c2fe7..45bad2276 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; @@ -146,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/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; 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/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/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/include/Nazara/Utility/SimpleTextDrawer.hpp b/include/Nazara/Utility/SimpleTextDrawer.hpp index 5793fdce2..a84f8a2c3 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.hpp +++ b/include/Nazara/Utility/SimpleTextDrawer.hpp @@ -25,7 +25,12 @@ 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; void SetCharacterSize(unsigned int characterSize); void SetColor(const NzColor& color); @@ -37,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/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/MemoryManager.cpp b/src/Nazara/Core/MemoryManager.cpp index 8b7acfee9..5e4d45e22 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 = { @@ -235,6 +235,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; @@ -250,6 +251,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_logFileName, "a"); diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index 746f70ce6..3add83482 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -266,8 +266,8 @@ bool NzParameterList::GetUserdataParameter(const NzString& name, void** value) c } else { - NazaraError("Parameter value is not an userdata"); - return nullptr; + NazaraError("Parameter value is not a userdata"); + return false; } } 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..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, NULL); + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + + pthread_mutex_init(&m_handle, &attr); } 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 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) 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(); 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); } 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); diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index c1e1fa875..3aa8f9a23 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"); @@ -159,6 +166,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 Run(argCount, LUA_MULTRET); +} + +bool NzLuaInstance::Call(unsigned int argCount, unsigned int resultCount) +{ + return Run(argCount, resultCount); +} + void NzLuaInstance::CheckAny(int index) const { luaL_checkany(m_state, index); @@ -370,7 +387,7 @@ bool NzLuaInstance::Execute(const NzString& code) return false; } - return Run(); + return Run(0, 0); } bool NzLuaInstance::ExecuteFromFile(const NzString& filePath) @@ -416,7 +433,7 @@ bool NzLuaInstance::ExecuteFromStream(NzInputStream& stream) return false; } - return Run(); + return Run(0, 0); } int NzLuaInstance::GetAbsIndex(int index) const @@ -813,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--; 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 0651921af..77952dfef 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 diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp index 5793dde87..14edc0c51 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; diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index 020ad021d..f8fe74841 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -37,11 +37,50 @@ 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; } +const NzString& NzSimpleTextDrawer::GetText() const +{ + return m_text; +} + void NzSimpleTextDrawer::SetCharacterSize(unsigned int characterSize) { m_characterSize = characterSize; @@ -101,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);