diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index d26a2daa8..0b4f2ce10 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -59,7 +59,7 @@ namespace Ndk * \param args Arguments used to create the window */ #ifndef NDK_SERVER - template + template T& Application::AddWindow(Args&&... args) { static_assert(std::is_base_of::value, "Type must inherit Window"); @@ -82,7 +82,7 @@ namespace Ndk * \param args Arguments used to create the world */ - template + template World& Application::AddWorld(Args&&... args) { m_worlds.emplace_back(std::forward(args)...); @@ -373,9 +373,9 @@ namespace Ndk { } - inline Application::WindowInfo::WindowInfo(std::unique_ptr&& window) : + inline Application::WindowInfo::WindowInfo(std::unique_ptr&& windowPtr) : renderTarget(nullptr), - window(std::move(window)) + window(std::move(windowPtr)) { } #endif diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index b536fc154..f8cd6d957 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -73,19 +73,19 @@ namespace Ndk { } - Renderable(Renderable&& renderable) noexcept : - renderableInvalidationSlot(std::move(renderable.renderableInvalidationSlot)), - renderableReleaseSlot(std::move(renderable.renderableReleaseSlot)), - data(std::move(renderable.data)), - renderable(std::move(renderable.renderable)), - dataUpdated(renderable.dataUpdated) + Renderable(Renderable&& rhs) noexcept : + renderableInvalidationSlot(std::move(rhs.renderableInvalidationSlot)), + renderableReleaseSlot(std::move(rhs.renderableReleaseSlot)), + data(std::move(rhs.data)), + renderable(std::move(rhs.renderable)), + dataUpdated(rhs.dataUpdated) { } ~Renderable() { // Disconnect release slot before releasing instanced renderable reference - renderableReleaseSlot.Disconnect(); + renderableReleaseSlot.Disconnect(); } Renderable& operator=(Renderable&& r) noexcept @@ -118,4 +118,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP -#endif // NDK_SERVER \ No newline at end of file +#endif // NDK_SERVER diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index 1ae2ddd43..e50699528 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -223,7 +223,7 @@ namespace Nz inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Matrix4f* mat, TypeTag) { - Matrix4d matDouble; + Matrix4d matDouble = Matrix4d::Identity(); unsigned int ret = LuaImplQueryArg(instance, index, &matDouble, TypeTag()); mat->Set(matDouble); diff --git a/SDK/src/NDK/LuaBinding_Audio.cpp b/SDK/src/NDK/LuaBinding_Audio.cpp index 46791b6c7..60f504939 100644 --- a/SDK/src/NDK/LuaBinding_Audio.cpp +++ b/SDK/src/NDK/LuaBinding_Audio.cpp @@ -41,12 +41,12 @@ namespace Ndk music.BindMethod("Stop", &Nz::Music::Stop); // Manual - music.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Music& music, std::size_t /*argumentCount*/) -> int + music.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Music& instance, std::size_t /*argumentCount*/) -> int { - Nz::StringStream stream("Music("); - stream << music.GetFilePath() << ')'; + Nz::StringStream ss("Music("); + ss << instance.GetFilePath() << ')'; - lua.PushString(stream); + lua.PushString(ss); return 1; }); @@ -65,15 +65,15 @@ namespace Ndk sound.BindMethod("SetPlayingOffset", &Nz::Sound::SetPlayingOffset); // Manual - sound.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Sound& sound, std::size_t /*argumentCount*/) -> int + sound.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Sound& instance, std::size_t /*argumentCount*/) -> int { - Nz::StringStream stream("Sound("); - if (const Nz::SoundBuffer* buffer = sound.GetBuffer()) - stream << buffer; + Nz::StringStream ss("Sound("); + if (const Nz::SoundBuffer* buffer = instance.GetBuffer()) + ss << buffer; - stream << ')'; + ss << ')'; - lua.PushString(stream); + lua.PushString(ss); return 1; }); @@ -124,18 +124,18 @@ namespace Ndk soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int { - Nz::StringStream stream("SoundBuffer("); + Nz::StringStream ss("SoundBuffer("); if (instance->IsValid()) { Nz::String filePath = instance->GetFilePath(); if (!filePath.IsEmpty()) - stream << "File: " << filePath << ", "; + ss << "File: " << filePath << ", "; - stream << "Duration: " << instance->GetDuration() / 1000.f << "s"; + ss << "Duration: " << instance->GetDuration() / 1000.f << "s"; } - stream << ')'; + ss << ')'; - lua.PushString(stream); + lua.PushString(ss); return 1; }); diff --git a/SDK/src/NDK/LuaBinding_Core.cpp b/SDK/src/NDK/LuaBinding_Core.cpp index dc149e3d0..4a1e343f4 100644 --- a/SDK/src/NDK/LuaBinding_Core.cpp +++ b/SDK/src/NDK/LuaBinding_Core.cpp @@ -13,13 +13,13 @@ namespace Ndk void LuaBinding::BindCore() { /*********************************** Nz::Clock **********************************/ - clock.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* clock, std::size_t /*argumentCount*/) + clock.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* instance, std::size_t /*argumentCount*/) { int argIndex = 2; Nz::Int64 startingValue = lua.Check(&argIndex, 0); bool paused = lua.Check(&argIndex, false); - Nz::PlacementNew(clock, startingValue, paused); + Nz::PlacementNew(instance, startingValue, paused); return true; }); @@ -32,19 +32,19 @@ namespace Ndk clock.BindMethod("Unpause", &Nz::Clock::Unpause); // Manual - clock.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& clock, std::size_t /*argumentCount*/) -> int { - Nz::StringStream stream("Clock(Elapsed: "); - stream << clock.GetSeconds(); - stream << "s, Paused: "; - stream << clock.IsPaused(); - stream << ')'; + clock.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& instance, std::size_t /*argumentCount*/) -> int { + Nz::StringStream ss("Clock(Elapsed: "); + ss << instance.GetSeconds(); + ss << "s, Paused: "; + ss << instance.IsPaused(); + ss << ')'; - lua.PushString(stream); + lua.PushString(ss); return 1; }); /********************************* Nz::Directory ********************************/ - directory.SetConstructor([](Nz::LuaInstance& lua, Nz::Directory* directory, std::size_t argumentCount) + directory.SetConstructor([](Nz::LuaInstance& lua, Nz::Directory* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 1U); @@ -52,11 +52,11 @@ namespace Ndk switch (argCount) { case 0: - Nz::PlacementNew(directory); + Nz::PlacementNew(instance); return true; case 1: - Nz::PlacementNew(directory, lua.Check(&argIndex)); + Nz::PlacementNew(instance, lua.Check(&argIndex)); return true; } @@ -85,12 +85,12 @@ namespace Ndk directory.BindStaticMethod("SetCurrent", Nz::Directory::SetCurrent); // Manual - directory.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Directory& directory, std::size_t /*argumentCount*/) -> int { - Nz::StringStream stream("Directory("); - stream << directory.GetPath(); - stream << ')'; + directory.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Directory& instance, std::size_t /*argumentCount*/) -> int { + Nz::StringStream ss("Directory("); + ss << instance.GetPath(); + ss << ')'; - lua.PushString(stream); + lua.PushString(ss); return 1; }); @@ -110,35 +110,35 @@ namespace Ndk stream.BindMethod("IsWritable", &Nz::Stream::IsWritable); stream.BindMethod("SetCursorPos", &Nz::Stream::SetCursorPos); - stream.BindMethod("Read", [] (Nz::LuaInstance& lua, Nz::Stream& stream, std::size_t /*argumentCount*/) -> int { + stream.BindMethod("Read", [] (Nz::LuaInstance& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; std::size_t length = lua.Check(&argIndex); std::unique_ptr buffer(new char[length]); - std::size_t readLength = stream.Read(buffer.get(), length); + std::size_t readLength = instance.Read(buffer.get(), length); lua.PushString(Nz::String(buffer.get(), readLength)); return 1; }); - stream.BindMethod("Write", [] (Nz::LuaInstance& lua, Nz::Stream& stream, std::size_t /*argumentCount*/) -> int { + stream.BindMethod("Write", [] (Nz::LuaInstance& lua, Nz::Stream& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; std::size_t bufferSize = 0; const char* buffer = lua.CheckString(argIndex, &bufferSize); - if (stream.IsTextModeEnabled()) - lua.Push(stream.Write(Nz::String(buffer, bufferSize))); + if (instance.IsTextModeEnabled()) + lua.Push(instance.Write(Nz::String(buffer, bufferSize))); else - lua.Push(stream.Write(buffer, bufferSize)); + lua.Push(instance.Write(buffer, bufferSize)); return 1; }); /*********************************** Nz::File ***********************************/ file.Inherit(stream); - file.SetConstructor([] (Nz::LuaInstance& lua, Nz::File* file, std::size_t argumentCount) + file.SetConstructor([] (Nz::LuaInstance& lua, Nz::File* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 1U); @@ -146,14 +146,14 @@ namespace Ndk switch (argCount) { case 0: - Nz::PlacementNew(file); + Nz::PlacementNew(instance); return true; case 1: { Nz::String filePath = lua.Check(&argIndex); - Nz::PlacementNew(file, filePath); + Nz::PlacementNew(instance, filePath); return true; } @@ -162,7 +162,7 @@ namespace Ndk Nz::String filePath = lua.Check(&argIndex); Nz::UInt32 openMode = lua.Check(&argIndex); - Nz::PlacementNew(file, filePath, openMode); + Nz::PlacementNew(instance, filePath, openMode); return true; } } @@ -201,7 +201,7 @@ namespace Ndk file.BindStaticMethod("Rename", &Nz::File::Rename); // Manual - file.BindMethod("Open", [] (Nz::LuaInstance& lua, Nz::File& file, std::size_t argumentCount) -> int + file.BindMethod("Open", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 2U); @@ -210,13 +210,13 @@ namespace Ndk { case 0: case 1: - return lua.Push(file.Open(lua.Check(&argIndex, Nz::OpenMode_NotOpen))); + return lua.Push(instance.Open(lua.Check(&argIndex, Nz::OpenMode_NotOpen))); case 2: { Nz::String filePath = lua.Check(&argIndex); Nz::UInt32 openMode = lua.Check(&argIndex, Nz::OpenMode_NotOpen); - return lua.Push(file.Open(filePath, openMode)); + return lua.Push(instance.Open(filePath, openMode)); } } @@ -224,7 +224,7 @@ namespace Ndk return 0; }); - file.BindMethod("SetCursorPos", [] (Nz::LuaInstance& lua, Nz::File& file, std::size_t argumentCount) -> int + file.BindMethod("SetCursorPos", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 2U); @@ -232,13 +232,13 @@ namespace Ndk switch (argCount) { case 1: - return lua.Push(file.SetCursorPos(lua.Check(&argIndex))); + return lua.Push(instance.SetCursorPos(lua.Check(&argIndex))); case 2: { Nz::CursorPosition curPos = lua.Check(&argIndex); Nz::Int64 offset = lua.Check(&argIndex); - return lua.Push(file.SetCursorPos(curPos, offset)); + return lua.Push(instance.SetCursorPos(curPos, offset)); } } @@ -246,14 +246,14 @@ namespace Ndk return 0; }); - file.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& file, std::size_t /*argumentCount*/) -> int { - Nz::StringStream stream("File("); - if (file.IsOpen()) - stream << "Path: " << file.GetPath(); + file.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t /*argumentCount*/) -> int { + Nz::StringStream ss("File("); + if (instance.IsOpen()) + ss << "Path: " << instance.GetPath(); - stream << ')'; + ss << ')'; - lua.PushString(stream); + lua.PushString(ss); return 1; }); } diff --git a/SDK/src/NDK/LuaBinding_Graphics.cpp b/SDK/src/NDK/LuaBinding_Graphics.cpp index 4a2b53422..d1cff2ef5 100644 --- a/SDK/src/NDK/LuaBinding_Graphics.cpp +++ b/SDK/src/NDK/LuaBinding_Graphics.cpp @@ -231,14 +231,14 @@ namespace Ndk }); /*********************************** Nz::Model ***********************************/ - model.Inherit(instancedRenderable, [] (Nz::ModelRef* model) -> Nz::InstancedRenderableRef* + model.Inherit(instancedRenderable, [] (Nz::ModelRef* modelRef) -> Nz::InstancedRenderableRef* { - return reinterpret_cast(model); //TODO: Make a ObjectRefCast + return reinterpret_cast(modelRef); //TODO: Make a ObjectRefCast }); - model.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::ModelRef* model, std::size_t /*argumentCount*/) + model.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::ModelRef* instance, std::size_t /*argumentCount*/) { - Nz::PlacementNew(model, Nz::Model::New()); + Nz::PlacementNew(instance, Nz::Model::New()); return true; }); @@ -260,14 +260,14 @@ namespace Ndk model.BindMethod("SetSkinCount", &Nz::Model::SetSkinCount); /*********************************** Nz::Sprite ***********************************/ - sprite.Inherit(instancedRenderable, [] (Nz::SpriteRef* sprite) -> Nz::InstancedRenderableRef* + sprite.Inherit(instancedRenderable, [] (Nz::SpriteRef* spriteRef) -> Nz::InstancedRenderableRef* { - return reinterpret_cast(sprite); //TODO: Make a ObjectRefCast + return reinterpret_cast(spriteRef); //TODO: Make a ObjectRefCast }); - sprite.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::SpriteRef* sprite, std::size_t /*argumentCount*/) + sprite.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::SpriteRef* instance, std::size_t /*argumentCount*/) { - Nz::PlacementNew(sprite, Nz::Sprite::New()); + Nz::PlacementNew(instance, Nz::Sprite::New()); return true; }); diff --git a/SDK/src/NDK/LuaBinding_Math.cpp b/SDK/src/NDK/LuaBinding_Math.cpp index 51a510238..35ad13a2e 100644 --- a/SDK/src/NDK/LuaBinding_Math.cpp +++ b/SDK/src/NDK/LuaBinding_Math.cpp @@ -14,22 +14,22 @@ namespace Ndk void LuaBinding::BindMath() { /*********************************** Nz::EulerAngles **********************************/ - eulerAngles.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* angles, std::size_t argumentCount) + eulerAngles.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 1U); switch (argCount) { case 0: - Nz::PlacementNew(angles, Nz::EulerAnglesd::Zero()); + Nz::PlacementNew(instance, Nz::EulerAnglesd::Zero()); return true; case 1: - Nz::PlacementNew(angles, *static_cast(lua.CheckUserdata(1, "EulerAngles"))); + Nz::PlacementNew(instance, *static_cast(lua.CheckUserdata(1, "EulerAngles"))); return true; case 3: - Nz::PlacementNew(angles, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3)); + Nz::PlacementNew(instance, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3)); return true; } @@ -154,7 +154,7 @@ namespace Ndk return false; }); - + /*********************************** Nz::Matrix4 **********************************/ matrix4d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Matrix4d* matrix, std::size_t argumentCount) { @@ -227,7 +227,7 @@ namespace Ndk { Nz::Matrix4d result; instance.GetTransposed(&result); - + return lua.Push(result); }); @@ -360,7 +360,7 @@ namespace Ndk }); /*********************************** Nz::Rect **********************************/ - rect.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* rect, std::size_t argumentCount) + rect.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 4U); @@ -368,23 +368,23 @@ namespace Ndk { case 0: case 4: - PlacementNew(rect, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0), lua.CheckNumber(4, 0.0)); + PlacementNew(instance, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0), lua.CheckNumber(4, 0.0)); return true; case 1: { if (lua.IsOfType(1, "Rect")) - PlacementNew(rect, *static_cast(lua.ToUserdata(1))); + PlacementNew(instance, *static_cast(lua.ToUserdata(1))); else if (lua.IsOfType(1, Nz::LuaType_Table)) { // TODO => Faire sans avoir à mettre de nom dans la table et prendre les éléments un à un pour créer le Rectd - PlacementNew(rect, lua.CheckField("x", 1), - lua.CheckField("y", 1), - lua.CheckField("width", 1), - lua.CheckField("height", 1)); + PlacementNew(instance, lua.CheckField("x", 1), + lua.CheckField("y", 1), + lua.CheckField("width", 1), + lua.CheckField("height", 1)); } else if (lua.IsOfType(1, "Vector2")) - PlacementNew(rect, *static_cast(lua.ToUserdata(1))); + PlacementNew(instance, *static_cast(lua.ToUserdata(1))); else break; @@ -394,9 +394,9 @@ namespace Ndk case 2: { if (lua.IsOfType(1, Nz::LuaType_Number) && lua.IsOfType(2, Nz::LuaType_Number)) - PlacementNew(rect, lua.CheckNumber(1), lua.CheckNumber(2)); + PlacementNew(instance, lua.CheckNumber(1), lua.CheckNumber(2)); else if (lua.IsOfType(1, "Vector2") && lua.IsOfType(2, "Vector2")) - PlacementNew(rect, *static_cast(lua.ToUserdata(1)), *static_cast(lua.ToUserdata(2))); + PlacementNew(instance, *static_cast(lua.ToUserdata(1)), *static_cast(lua.ToUserdata(2))); else break; @@ -516,22 +516,22 @@ namespace Ndk }); /*********************************** Nz::Quaternion **********************************/ - quaternion.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* quaternion, std::size_t argumentCount) + quaternion.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 4U); switch (argCount) { case 0: - Nz::PlacementNew(quaternion, Nz::Quaterniond::Zero()); + Nz::PlacementNew(instance, Nz::Quaterniond::Zero()); return true; case 1: { if (lua.IsOfType(1, "EulerAngles")) - Nz::PlacementNew(quaternion, *static_cast(lua.ToUserdata(1))); + Nz::PlacementNew(instance, *static_cast(lua.ToUserdata(1))); else if (lua.IsOfType(1, "Quaternion")) - Nz::PlacementNew(quaternion, *static_cast(lua.ToUserdata(1))); + Nz::PlacementNew(instance, *static_cast(lua.ToUserdata(1))); else break; @@ -539,11 +539,11 @@ namespace Ndk } case 2: - Nz::PlacementNew(quaternion, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(2, "Vector3"))); + Nz::PlacementNew(instance, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(2, "Vector3"))); return true; case 4: - Nz::PlacementNew(quaternion, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3), lua.CheckNumber(4)); + Nz::PlacementNew(instance, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3), lua.CheckNumber(4)); return true; default: diff --git a/SDK/src/NDK/LuaBinding_Math.cpp.save-failed b/SDK/src/NDK/LuaBinding_Math.cpp.save-failed new file mode 100644 index 000000000..6abec5c7b --- /dev/null +++ b/SDK/src/NDK/LuaBinding_Math.cpp.save-failed @@ -0,0 +1,908 @@ +// This file was automatically generated on 26 May 2014 at 01:05:31 + +#include +#include +#include +#include + +namespace Ndk +{ + /*! + * \brief Binds Math module to Lua + */ + + void LuaBinding::BindMath() + { + /*********************************** Nz::EulerAngles **********************************/ + eulerAngles.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* instance, std::size_t argumentCount) + { + std::size_t argCount = std::min(argumentCount, 1U); + + switch (argCount) + { + case 0: + Nz::PlacementNew(angles, Nz::EulerAnglesd::Zero()); + return true; + + case 1: + Nz::PlacementNew(angles, *static_cast(lua.CheckUserdata(1, "EulerAngles"))); + return true; + + case 3: + Nz::PlacementNew(angles, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3)); + return true; + } + + lua.Error("No matching overload for EulerAngles constructor"); + return false; + }); + + eulerAngles.BindMethod("__tostring", &Nz::EulerAnglesd::ToString); + + eulerAngles.SetGetter([] (Nz::LuaInstance& lua, Nz::EulerAnglesd& instance) + { + std::size_t length; + const char* ypr = lua.CheckString(2, &length); + + switch (length) + { + case 1: + { + switch (ypr[0]) + { + case 'p': + lua.Push(instance.pitch); + return true; + + case 'y': + lua.Push(instance.yaw); + return true; + + case 'r': + lua.Push(instance.roll); + return true; + } + break; + } + + case 3: + { + if (std::memcmp(ypr, "yaw", 3) != 0) + break; + + lua.Push(instance.yaw); + return true; + } + + case 4: + { + if (std::memcmp(ypr, "roll", 4) != 0) + break; + + lua.Push(instance.roll); + return true; + } + + case 5: + { + if (std::memcmp(ypr, "pitch", 5) != 0) + break; + + lua.Push(instance.pitch); + return true; + } + } + + return false; + }); + + eulerAngles.SetSetter([] (Nz::LuaInstance& lua, Nz::EulerAnglesd& instance) + { + std::size_t length; + const char* ypr = lua.CheckString(2, &length); + double value = lua.CheckNumber(3); + + switch (length) + { + case 1: + { + switch (ypr[0]) + { + case 'p': + instance.pitch = value; + return true; + + case 'y': + instance.yaw = value; + return true; + + case 'r': + instance.roll = value; + return true; + } + break; + } + + case 3: + { + if (std::memcmp(ypr, "yaw", 3) != 0) + break; + + instance.yaw = value; + return true; + } + + case 4: + { + if (std::memcmp(ypr, "roll", 4) != 0) + break; + + instance.roll = value; + return true; + } + + case 5: + { + if (std::memcmp(ypr, "pitch", 5) != 0) + break; + + instance.pitch = value; + return true; + } + } + + return false; + }); + + + /*********************************** Nz::Matrix4 **********************************/ + matrix4d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Matrix4d* matrix, std::size_t argumentCount) + { + std::size_t argCount = std::min(argumentCount, 3U); + + switch (argCount) + { + case 0: + Nz::PlacementNew(matrix, Nz::Matrix4d::Zero()); + return true; + + case 1: + if (lua.IsOfType(1, "Matrix4")) + Nz::PlacementNew(matrix, *static_cast(lua.ToUserdata(1))); + break; + + case 16: + { + double values[16]; + for (std::size_t i = 0; i < 16; ++i) + values[i] = lua.CheckNumber(i); + + Nz::PlacementNew(matrix, values); + + return true; + } + } + + lua.Error("No matching overload for constructor"); + return false; + }); + + matrix4d.BindMethod("ApplyRotation", &Nz::Matrix4d::ApplyRotation); + matrix4d.BindMethod("ApplyScale", &Nz::Matrix4d::ApplyScale); + matrix4d.BindMethod("ApplyTranslation", &Nz::Matrix4d::ApplyTranslation); + + matrix4d.BindMethod("Concatenate", &Nz::Matrix4d::Concatenate); + matrix4d.BindMethod("ConcatenateAffine", &Nz::Matrix4d::ConcatenateAffine); + + //matrix4d.BindMethod("GetColumn", &Nz::Matrix4d::GetColumn); + matrix4d.BindMethod("GetDeterminant", &Nz::Matrix4d::GetDeterminant); + matrix4d.BindMethod("GetDeterminantAffine", &Nz::Matrix4d::GetDeterminantAffine); + + matrix4d.BindMethod("GetInverse", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + { + Nz::Matrix4d result; + if (instance.GetInverse(&result)) + return lua.Push(true, result); + else + return lua.Push(false); + }); + + matrix4d.BindMethod("GetInverseAffine", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + { + Nz::Matrix4d result; + if (instance.GetInverseAffine(&result)) + return lua.Push(true, result); + else + return lua.Push(false); + }); + + matrix4d.BindMethod("GetRotation", &Nz::Matrix4d::GetRotation); + + //matrix4d.BindMethod("GetRow", &Nz::Matrix4d::GetRow); + matrix4d.BindMethod("GetScale", &Nz::Matrix4d::GetScale); + matrix4d.BindMethod("GetSquaredScale", &Nz::Matrix4d::GetSquaredScale); + matrix4d.BindMethod("GetTranslation", &Nz::Matrix4d::GetTranslation); + + matrix4d.BindMethod("GetTransposed", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + { + Nz::Matrix4d result; + instance.GetTransposed(&result); + + return lua.Push(result); + }); + + matrix4d.BindMethod("HasNegativeScale", &Nz::Matrix4d::HasNegativeScale); + matrix4d.BindMethod("HasScale", &Nz::Matrix4d::HasScale); + + matrix4d.BindMethod("Inverse", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + { + bool succeeded; + instance.Inverse(&succeeded); + + return lua.Push(succeeded); + }); + + matrix4d.BindMethod("InverseAffine", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + { + bool succeeded; + instance.InverseAffine(&succeeded); + + return lua.Push(succeeded); + }); + + matrix4d.BindMethod("IsAffine", &Nz::Matrix4d::IsAffine); + matrix4d.BindMethod("IsIdentity", &Nz::Matrix4d::IsIdentity); + + matrix4d.BindMethod("MakeIdentity", &Nz::Matrix4d::MakeIdentity); + matrix4d.BindMethod("MakeLookAt", &Nz::Matrix4d::MakeLookAt, Nz::Vector3d::Up()); + matrix4d.BindMethod("MakeOrtho", &Nz::Matrix4d::MakeOrtho, -1.0, 1.0); + matrix4d.BindMethod("MakePerspective", &Nz::Matrix4d::MakePerspective); + matrix4d.BindMethod("MakeRotation", &Nz::Matrix4d::MakeRotation); + matrix4d.BindMethod("MakeScale", &Nz::Matrix4d::MakeScale); + matrix4d.BindMethod("MakeTranslation", &Nz::Matrix4d::MakeTranslation); + matrix4d.BindMethod("MakeTransform", (Nz::Matrix4d&(Nz::Matrix4d::*)(const Nz::Vector3d&, const Nz::Quaterniond&, const Nz::Vector3d&)) &Nz::Matrix4d::MakeTransform, Nz::Vector3d::Unit()); + matrix4d.BindMethod("MakeViewMatrix", &Nz::Matrix4d::MakeViewMatrix); + matrix4d.BindMethod("MakeZero", &Nz::Matrix4d::MakeZero); + + matrix4d.BindMethod("Set", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t argumentCount) -> int + { + std::size_t argCount = std::min(argumentCount, 3U); + + int argIndex = 2; + switch (argCount) + { + case 1: + if (lua.IsOfType(argIndex, "Matrix4")) + instance.Set(*static_cast(lua.ToUserdata(argIndex))); + break; + + case 16: + { + double values[16]; + for (std::size_t i = 0; i < 16; ++i) + values[i] = lua.CheckNumber(argIndex++); + + instance.Set(values); + + return 0; + } + } + + lua.Error("No matching overload for method Set"); + return 0; + }); + + matrix4d.BindMethod("SetRotation", &Nz::Matrix4d::SetRotation); + matrix4d.BindMethod("SetScale", &Nz::Matrix4d::SetScale); + matrix4d.BindMethod("SetTranslation", &Nz::Matrix4d::SetTranslation); + + matrix4d.BindMethod("Transform", [] (Nz::LuaInstance& lua, Nz::Matrix4d& instance, std::size_t /*argumentCount*/) -> int + { + int argIndex = 2; + if (lua.IsOfType(argIndex, "Vector2")) + { + double z(lua.CheckNumber(argIndex+1, 0.0)); + double w(lua.CheckNumber(argIndex+2, 1.0)); + + return lua.Push(instance.Transform(*static_cast(lua.ToUserdata(argIndex)), z, w)); + } + else if (lua.IsOfType(argIndex, "Vector3")) + { + double w(lua.CheckNumber(argIndex+1, 1.0)); + + return lua.Push(instance.Transform(*static_cast(lua.ToUserdata(argIndex)), w)); + } + //else if (lua.IsOfType(2, "Vector4")) + // return lua.Push(instance.Transform(*static_cast(lua.ToUserdata(1)))); + + lua.Error("No matching overload for method Transform"); + return 0; + }); + + matrix4d.BindMethod("Transpose", &Nz::Matrix4d::Transpose); + + matrix4d.BindMethod("__tostring", &Nz::Matrix4d::ToString); + + matrix4d.BindStaticMethod("Concatenate", &Nz::Matrix4d::Concatenate); + matrix4d.BindStaticMethod("ConcatenateAffine", &Nz::Matrix4d::ConcatenateAffine); + matrix4d.BindStaticMethod("Identity", &Nz::Matrix4d::Identity); + matrix4d.BindStaticMethod("LookAt", &Nz::Matrix4d::LookAt, Nz::Vector3d::Up()); + matrix4d.BindStaticMethod("Ortho", &Nz::Matrix4d::Ortho, -1.0, 1.0); + matrix4d.BindStaticMethod("Perspective", &Nz::Matrix4d::Perspective); + matrix4d.BindStaticMethod("Rotate", &Nz::Matrix4d::Rotate); + matrix4d.BindStaticMethod("Scale", &Nz::Matrix4d::Scale); + matrix4d.BindStaticMethod("Translate", &Nz::Matrix4d::Translate); + matrix4d.BindStaticMethod("Transform", (Nz::Matrix4d(*)(const Nz::Vector3d&, const Nz::Quaterniond&, const Nz::Vector3d&)) &Nz::Matrix4d::Transform, Nz::Vector3d::Unit()); + matrix4d.BindStaticMethod("ViewMatrix", &Nz::Matrix4d::ViewMatrix); + matrix4d.BindStaticMethod("Zero", &Nz::Matrix4d::Zero); + + matrix4d.SetGetter([] (Nz::LuaInstance& lua, Nz::Matrix4d& instance) + { + bool succeeded = false; + std::size_t index = static_cast(lua.ToInteger(2, &succeeded)); + if (!succeeded || index < 1 || index > 16) + return false; + + lua.Push(instance[index - 1]); + return true; + }); + + matrix4d.SetSetter([] (Nz::LuaInstance& lua, Nz::Matrix4d& instance) + { + bool succeeded = false; + std::size_t index = static_cast(lua.ToInteger(2, &succeeded)); + if (!succeeded || index < 1 || index > 16) + return false; + + instance[index - 1] = lua.CheckNumber(3); + + return true; + }); + + /*********************************** Nz::Rect **********************************/ + rect.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* rect, std::size_t argumentCount) + { + std::size_t argCount = std::min(argumentCount, 4U); + + switch (argCount) + { + case 0: + case 4: + PlacementNew(rect, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0), lua.CheckNumber(4, 0.0)); + return true; + + case 1: + { + if (lua.IsOfType(1, "Rect")) + PlacementNew(rect, *static_cast(lua.ToUserdata(1))); + else if (lua.IsOfType(1, Nz::LuaType_Table)) + { + // TODO => Faire sans avoir à mettre de nom dans la table et prendre les éléments un à un pour créer le Rectd + PlacementNew(rect, lua.CheckField("x", 1), + lua.CheckField("y", 1), + lua.CheckField("width", 1), + lua.CheckField("height", 1)); + } + else if (lua.IsOfType(1, "Vector2")) + PlacementNew(rect, *static_cast(lua.ToUserdata(1))); + else + break; + + return true; + } + + case 2: + { + if (lua.IsOfType(1, Nz::LuaType_Number) && lua.IsOfType(2, Nz::LuaType_Number)) + PlacementNew(rect, lua.CheckNumber(1), lua.CheckNumber(2)); + else if (lua.IsOfType(1, "Vector2") && lua.IsOfType(2, "Vector2")) + PlacementNew(rect, *static_cast(lua.ToUserdata(1)), *static_cast(lua.ToUserdata(2))); + else + break; + + return true; + } + } + + lua.Error("No matching overload for Rect constructor"); + return false; + }); + + rect.BindMethod("__tostring", &Nz::Rectd::ToString); + + rect.SetGetter([] (Nz::LuaInstance& lua, Nz::Rectd& instance) + { + switch (lua.GetType(2)) + { + case Nz::LuaType_Number: + { + auto index = lua.CheckBoundInteger(2); + if (index < 1 || index > 4) + return false; + + lua.Push(instance[index - 1]); + return true; + } + + case Nz::LuaType_String: + { + std::size_t length; + const char* xywh = lua.CheckString(2, &length); + + if (length != 1) + break; + + switch (xywh[0]) + { + case 'x': + lua.Push(instance.x); + return true; + + case 'y': + lua.Push(instance.y); + return true; + + case 'w': + lua.Push(instance.width); + return true; + + case 'h': + lua.Push(instance.height); + return true; + + default: + break; + } + break; + } + + default: + break; + } + + return false; + }); + + rect.SetSetter([] (Nz::LuaInstance& lua, Nz::Rectd& instance) + { + switch (lua.GetType(2)) + { + case Nz::LuaType_Number: + { + auto index = lua.CheckBoundInteger(2); + if (index < 1 || index > 4) + return false; + + instance[index - 1] = lua.CheckNumber(2); + return true; + } + + case Nz::LuaType_String: + { + std::size_t length; + const char* xywh = lua.CheckString(2, &length); + + if (length != 1) + break; + + double value = lua.CheckNumber(3); + + switch (xywh[0]) + { + case 'x': + instance.x = value; + return true; + + case 'y': + instance.y = value; + return true; + + case 'w': + instance.width = value; + return true; + + case 'h': + instance.height = value; + return true; + } + break; + } + + default: + break; + } + + return false; + }); + + /*********************************** Nz::Quaternion **********************************/ + quaternion.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* quaternion, std::size_t argumentCount) + { + std::size_t argCount = std::min(argumentCount, 4U); + + switch (argCount) + { + case 0: + Nz::PlacementNew(quaternion, Nz::Quaterniond::Zero()); + return true; + + case 1: + { + if (lua.IsOfType(1, "EulerAngles")) + Nz::PlacementNew(quaternion, *static_cast(lua.ToUserdata(1))); + else if (lua.IsOfType(1, "Quaternion")) + Nz::PlacementNew(quaternion, *static_cast(lua.ToUserdata(1))); + else + break; + + return true; + } + + case 2: + Nz::PlacementNew(quaternion, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(2, "Vector3"))); + return true; + + case 4: + Nz::PlacementNew(quaternion, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3), lua.CheckNumber(4)); + return true; + + default: + break; + } + + lua.Error("No matching overload for Quaternion constructor"); + return false; + }); + + quaternion.BindMethod("__tostring", &Nz::Quaterniond::ToString); + + quaternion.SetGetter([] (Nz::LuaInstance& lua, Nz::Quaterniond& instance) + { + std::size_t length; + const char* wxyz = lua.CheckString(2, &length); + + if (length != 1) + return false; + + switch (wxyz[0]) + { + case 'w': + lua.Push(instance.w); + return true; + + case 'x': + lua.Push(instance.x); + return true; + + case 'y': + lua.Push(instance.y); + return true; + + case 'z': + lua.Push(instance.z); + return true; + } + + return false; + }); + + quaternion.SetSetter([] (Nz::LuaInstance& lua, Nz::Quaterniond& instance) + { + std::size_t length; + const char* wxyz = lua.CheckString(2, &length); + + if (length != 1) + return false; + + double value = lua.CheckNumber(3); + + switch (wxyz[0]) + { + case 'w': + instance.w = value; + return true; + + case 'x': + instance.x = value; + return true; + + case 'y': + instance.y = value; + return true; + + case 'z': + instance.z = value; + return true; + + default: + break; + } + + return false; + }); + + /*********************************** Nz::Vector2 **********************************/ + vector2d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector2d* vector, std::size_t argumentCount) + { + std::size_t argCount = std::min(argumentCount, 2U); + + switch (argCount) + { + case 0: + case 2: + Nz::PlacementNew(vector, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0)); + return true; + + case 1: + { + if (lua.IsOfType(1, Nz::LuaType_Number)) + Nz::PlacementNew(vector, lua.CheckNumber(1)); + else if (lua.IsOfType(1, "Vector2")) + Nz::PlacementNew(vector, *static_cast(lua.ToUserdata(1))); + else + break; + + return true; + } + } + + lua.Error("No matching overload for Vector2 constructor"); + return false; + }); + + vector2d.BindMethod("__tostring", &Nz::Vector2d::ToString); + + vector2d.SetGetter([](Nz::LuaInstance& lua, Nz::Vector2d& instance) + { + switch (lua.GetType(2)) + { + case Nz::LuaType_Number: + { + long long index = lua.CheckInteger(2); + if (index < 1 || index > 2) + return false; + + lua.Push(instance[index - 1]); + return true; + } + + case Nz::LuaType_String: + { + std::size_t length; + const char* xy = lua.CheckString(2, &length); + + if (length != 1) + break; + + switch (xy[0]) + { + case 'x': + lua.Push(instance.x); + return true; + + case 'y': + lua.Push(instance.y); + return true; + + default: + break; + } + break; + } + + default: + break; + } + + return false; + }); + + vector2d.SetSetter([](Nz::LuaInstance& lua, Nz::Vector2d& instance) + { + switch (lua.GetType(2)) + { + case Nz::LuaType_Number: + { + long long index = lua.CheckInteger(2); + if (index < 1 || index > 2) + return false; + + instance[index - 1] = lua.CheckNumber(3); + return true; + } + + case Nz::LuaType_String: + { + std::size_t length; + const char* xy = lua.CheckString(2, &length); + + if (length != 1) + break; + + double value = lua.CheckNumber(3); + + switch (xy[0]) + { + case 'x': + instance.x = value; + return true; + + case 'y': + instance.y = value; + return true; + + default: + break; + } + break; + } + + default: + break; + } + + return false; + }); + + /*********************************** Nz::Vector3 **********************************/ + vector3d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector3d* vector, std::size_t argumentCount) + { + std::size_t argCount = std::min(argumentCount, 3U); + + switch (argCount) + { + case 0: + case 3: + Nz::PlacementNew(vector, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0)); + return true; + + case 1: + { + if (lua.IsOfType(1, Nz::LuaType_Number)) + Nz::PlacementNew(vector, lua.CheckNumber(1)); + else if (lua.IsOfType(1, "Vector2")) + Nz::PlacementNew(vector, *static_cast(lua.ToUserdata(1))); + else if (lua.IsOfType(1, "Vector3")) + Nz::PlacementNew(vector, *static_cast(lua.ToUserdata(1))); + else + break; + + return true; + } + + case 2: + { + if (lua.IsOfType(1, Nz::LuaType_Number)) + Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(2, "Vector2"))); + else if (lua.IsOfType(1, "Vector2")) + Nz::PlacementNew(vector, *static_cast(lua.ToUserdata(1)), lua.CheckNumber(2)); + else + break; + + return true; + } + } + + lua.Error("No matching overload for constructor"); + return false; + }); + + vector3d.BindMethod("__tostring", &Nz::Vector3d::ToString); + + vector3d.SetGetter([] (Nz::LuaInstance& lua, Nz::Vector3d& instance) + { + switch (lua.GetType(2)) + { + case Nz::LuaType_Number: + { + long long index = lua.CheckInteger(2); + if (index < 1 || index > 3) + return false; + + lua.Push(instance[index - 1]); + return true; + } + + case Nz::LuaType_String: + { + std::size_t length; + const char* xyz = lua.CheckString(2, &length); + + if (length != 1) + break; + + switch (xyz[0]) + { + case 'x': + lua.Push(instance.x); + return true; + + case 'y': + lua.Push(instance.y); + return true; + + case 'z': + lua.Push(instance.z); + return true; + + default: + break; + } + break; + } + + default: + break; + } + + return false; + }); + + vector3d.SetSetter([] (Nz::LuaInstance& lua, Nz::Vector3d& instance) + { + switch (lua.GetType(2)) + { + case Nz::LuaType_Number: + { + long long index = lua.CheckInteger(2); + if (index < 1 || index > 3) + return false; + + instance[index - 1] = lua.CheckNumber(3); + return true; + } + + case Nz::LuaType_String: + { + std::size_t length; + const char* xyz = lua.CheckString(2, &length); + + if (length != 1) + break; + + double value = lua.CheckNumber(3); + + switch (xyz[0]) + { + case 'x': + instance.x = value; + return true; + + case 'y': + instance.y = value; + return true; + + case 'z': + instance.z = value; + return true; + + default: + break; + } + break; + } + + default: + break; + } + + return false; + }); + } + + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Math classes + */ + + void LuaBinding::RegisterMath(Nz::LuaInstance& instance) + { + eulerAngles.Register(instance); + matrix4d.Register(instance); + quaternion.Register(instance); + rect.Register(instance); + vector2d.Register(instance); + vector3d.Register(instance); + } +} diff --git a/SDK/src/NDK/LuaBinding_Network.cpp b/SDK/src/NDK/LuaBinding_Network.cpp index bd1105962..b51906481 100644 --- a/SDK/src/NDK/LuaBinding_Network.cpp +++ b/SDK/src/NDK/LuaBinding_Network.cpp @@ -21,7 +21,7 @@ namespace Ndk abstractSocket.BindMethod("QueryAvailableBytes", &Nz::AbstractSocket::QueryAvailableBytes); /*********************************** Nz::IpAddress **********************************/ - ipAddress.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* address, std::size_t argumentCount) + ipAddress.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* instance, std::size_t argumentCount) { std::size_t argCount = std::min(argumentCount, 9U); @@ -29,11 +29,11 @@ namespace Ndk switch (argCount) { case 0: - Nz::PlacementNew(address); + Nz::PlacementNew(instance); return true; case 1: - Nz::PlacementNew(address, lua.CheckString(argIndex)); + Nz::PlacementNew(instance, lua.CheckString(argIndex)); return true; case 4: @@ -45,7 +45,7 @@ namespace Ndk Nz::UInt8 d = lua.Check(&argIndex); Nz::UInt16 port = lua.Check(&argIndex, 0); - Nz::PlacementNew(address, a, b, c, d, port); + Nz::PlacementNew(instance, a, b, c, d, port); return true; } @@ -62,7 +62,7 @@ namespace Ndk Nz::UInt16 h = lua.Check(&argIndex); Nz::UInt16 port = lua.Check(&argIndex, 0); - Nz::PlacementNew(address, a, b, c, d, e, f, g, h, port); + Nz::PlacementNew(instance, a, b, c, d, e, f, g, h, port); return true; } } @@ -199,7 +199,7 @@ namespace Ndk instance.PushField("Unknown", Nz::ResolveError_Unknown); } instance.SetGlobal("ResolveError"); - + // Nz::SocketError static_assert(Nz::SocketError_Max + 1 == 15, "Nz::ResolveError has been updated but change was not reflected to Lua binding"); instance.PushTable(0, 15); diff --git a/SDK/src/NDK/LuaBinding_Renderer.cpp b/SDK/src/NDK/LuaBinding_Renderer.cpp index 8ffe76c69..1f1f9479f 100644 --- a/SDK/src/NDK/LuaBinding_Renderer.cpp +++ b/SDK/src/NDK/LuaBinding_Renderer.cpp @@ -13,14 +13,14 @@ namespace Ndk void LuaBinding::BindRenderer() { /*********************************** Nz::Texture ***********************************/ - texture.Inherit(abstractImage, [] (Nz::TextureRef* texture) -> Nz::AbstractImageRef* + texture.Inherit(abstractImage, [] (Nz::TextureRef* textureRef) -> Nz::AbstractImageRef* { - return reinterpret_cast(texture); //TODO: Make a ObjectRefCast + return reinterpret_cast(textureRef); //TODO: Make a ObjectRefCast }); - texture.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::TextureRef* texture, std::size_t /*argumentCount*/) + texture.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::TextureRef* instance, std::size_t /*argumentCount*/) { - Nz::PlacementNew(texture, Nz::Texture::New()); + Nz::PlacementNew(instance, Nz::Texture::New()); return true; }); @@ -28,7 +28,7 @@ namespace Ndk texture.BindMethod("Destroy", &Nz::Texture::Destroy); //texture.BindMethod("Download", &Nz::Texture::Download); - + texture.BindMethod("EnableMipmapping", &Nz::Texture::EnableMipmapping); texture.BindMethod("EnsureMipmapsUpdate", &Nz::Texture::EnsureMipmapsUpdate); texture.BindMethod("HasMipmaps", &Nz::Texture::HasMipmaps); @@ -73,4 +73,4 @@ namespace Ndk { texture.Register(instance); } -} \ No newline at end of file +} diff --git a/SDK/src/NDK/LuaBinding_SDK.cpp b/SDK/src/NDK/LuaBinding_SDK.cpp index 3046f2483..880e49064 100644 --- a/SDK/src/NDK/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/LuaBinding_SDK.cpp @@ -25,9 +25,9 @@ namespace Ndk application.BindMethod("IsFPSCounterEnabled", &Application::IsFPSCounterEnabled); #endif - application.BindMethod("AddWorld", [] (Nz::LuaInstance& instance, Application* application, std::size_t /*argumentCount*/) -> int + application.BindMethod("AddWorld", [] (Nz::LuaInstance& lua, Application* instance, std::size_t /*argumentCount*/) -> int { - instance.Push(application->AddWorld().CreateHandle()); + lua.Push(instance->AddWorld().CreateHandle()); return 1; }); @@ -59,7 +59,7 @@ namespace Ndk console.BindMethod("SetCharacterSize", &Console::SetCharacterSize); console.BindMethod("SetSize", &Console::SetSize); console.BindMethod("SetTextFont", &Console::SetTextFont); - + console.BindMethod("Show", &Console::Show, true); #endif @@ -139,7 +139,7 @@ namespace Ndk #ifndef NDK_SERVER /*********************************** Ndk::GraphicsComponent **********************************/ - graphicsComponent.BindMethod("Attach", [] (Nz::LuaInstance& lua, Ndk::GraphicsComponent *gfxComponent, std::size_t argumentCount) -> int + graphicsComponent.BindMethod("Attach", [] (Nz::LuaInstance& lua, Ndk::GraphicsComponent* instance, std::size_t argumentCount) -> int { /* void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0); @@ -153,7 +153,7 @@ namespace Ndk case 1: { int argIndex = 2; - gfxComponent->Attach(lua.Check(&argIndex)); + instance->Attach(lua.Check(&argIndex)); return 0; } @@ -166,13 +166,13 @@ namespace Ndk { int renderOrder = lua.Check(&argIndex); - gfxComponent->Attach(renderable, renderOrder); + instance->Attach(renderable, renderOrder); } else if (lua.IsOfType(argIndex, "Matrix4")) { Nz::Matrix4f localMatrix = lua.Check(&argIndex); - gfxComponent->Attach(renderable, localMatrix); + instance->Attach(renderable, localMatrix); } else break; @@ -187,7 +187,7 @@ namespace Ndk Nz::Matrix4f localMatrix = lua.Check(&argIndex); int renderOrder = lua.Check(&argIndex); - gfxComponent->Attach(renderable, localMatrix, renderOrder); + instance->Attach(renderable, localMatrix, renderOrder); return 0; } } diff --git a/SDK/src/NDK/LuaBinding_Utility.cpp b/SDK/src/NDK/LuaBinding_Utility.cpp index 5ae37f669..e693ce35c 100644 --- a/SDK/src/NDK/LuaBinding_Utility.cpp +++ b/SDK/src/NDK/LuaBinding_Utility.cpp @@ -25,20 +25,20 @@ namespace Ndk abstractImage.BindMethod("IsCompressed", &Nz::AbstractImage::IsCompressed); abstractImage.BindMethod("IsCubemap", &Nz::AbstractImage::IsCubemap); - abstractImage.BindMethod("GetMemoryUsage", [] (Nz::LuaInstance& lua, Nz::AbstractImage* abstractImage, std::size_t argumentCount) -> int + abstractImage.BindMethod("GetMemoryUsage", [] (Nz::LuaInstance& lua, Nz::AbstractImage* instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 1U); switch (argCount) { case 0: - return lua.Push(abstractImage->GetMemoryUsage()); + return lua.Push(instance->GetMemoryUsage()); case 1: { int argIndex = 2; Nz::UInt8 level(lua.Check(&argIndex)); - return lua.Push(abstractImage->GetMemoryUsage(level)); + return lua.Push(instance->GetMemoryUsage(level)); } } @@ -46,7 +46,7 @@ namespace Ndk return 0; }); - abstractImage.BindMethod("Update", [] (Nz::LuaInstance& lua, Nz::AbstractImage* abstractImage, std::size_t argumentCount) -> int + abstractImage.BindMethod("Update", [] (Nz::LuaInstance& lua, Nz::AbstractImage* instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 6U); int argIndex = 2; @@ -62,7 +62,7 @@ namespace Ndk Nz::UInt8 level = lua.Check(&argIndex, 0); ///TODO: Buffer checks (Nz::ByteBufferView ?) - return lua.Push(abstractImage->Update(pixels, srcWidth, srcHeight, level)); + return lua.Push(instance->Update(pixels, srcWidth, srcHeight, level)); } /* Disabled until Box and Rect have been ported else if (lua.IsOfType(2, "Box")) @@ -93,9 +93,9 @@ namespace Ndk }); /*********************************** Nz::Font **********************************/ - font.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::FontRef* font, std::size_t /*argumentCount*/) + font.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::FontRef* instance, std::size_t /*argumentCount*/) { - Nz::PlacementNew(font, Nz::Font::New()); + Nz::PlacementNew(instance, Nz::Font::New()); return true; }); @@ -199,29 +199,29 @@ namespace Ndk node.BindMethod("SetPosition", (void(Nz::Node::*)(const Nz::Vector3f&, Nz::CoordSys)) &Nz::Node::SetPosition, Nz::CoordSys_Local); node.BindMethod("SetRotation", (void(Nz::Node::*)(const Nz::Quaternionf&, Nz::CoordSys)) &Nz::Node::SetRotation, Nz::CoordSys_Local); - node.BindMethod("Move", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t /*argumentCount*/) -> int + node.BindMethod("Move", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; Nz::Vector3f offset = lua.Check(&argIndex); Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - node.Move(offset, coordSys); + instance.Move(offset, coordSys); return 0; }); - node.BindMethod("Rotate", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t /*argumentCount*/) -> int + node.BindMethod("Rotate", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t /*argumentCount*/) -> int { int argIndex = 2; Nz::Quaternionf rotation = lua.Check(&argIndex); Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - node.Rotate(rotation, coordSys); + instance.Rotate(rotation, coordSys); return 0; }); - node.BindMethod("Scale", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t argumentCount) -> int + node.BindMethod("Scale", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 4U); @@ -231,15 +231,15 @@ namespace Ndk case 1: { if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - node.Scale(lua.Check(&argIndex)); + instance.Scale(lua.Check(&argIndex)); else - node.Scale(lua.Check(&argIndex)); + instance.Scale(lua.Check(&argIndex)); return 0; } case 3: - node.Scale(lua.Check(&argIndex)); + instance.Scale(lua.Check(&argIndex)); return 0; } @@ -247,7 +247,7 @@ namespace Ndk return 0; }); - node.BindMethod("SetScale", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t argumentCount) -> int + node.BindMethod("SetScale", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 4U); @@ -261,10 +261,10 @@ namespace Ndk { float scale = lua.Check(&argIndex); Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - node.SetScale(scale, coordSys); + instance.SetScale(scale, coordSys); } else - node.SetScale(lua.Check(&argIndex)); + instance.SetScale(lua.Check(&argIndex)); return 0; } @@ -275,7 +275,7 @@ namespace Ndk Nz::Vector3f scale = lua.Check(&argIndex); Nz::CoordSys coordSys = lua.Check(&argIndex, Nz::CoordSys_Local); - node.SetScale(scale, coordSys); + instance.SetScale(scale, coordSys); return 0; } } @@ -284,7 +284,7 @@ namespace Ndk return 0; }); - node.BindMethod("SetInitialScale", [] (Nz::LuaInstance& lua, Nz::Node& node, std::size_t argumentCount) -> int + node.BindMethod("SetInitialScale", [] (Nz::LuaInstance& lua, Nz::Node& instance, std::size_t argumentCount) -> int { std::size_t argCount = std::min(argumentCount, 4U); @@ -294,16 +294,16 @@ namespace Ndk case 1: { if (lua.IsOfType(argIndex, Nz::LuaType_Number)) - node.SetInitialScale(lua.Check(&argIndex)); + instance.SetInitialScale(lua.Check(&argIndex)); else - node.SetInitialScale(lua.Check(&argIndex)); + instance.SetInitialScale(lua.Check(&argIndex)); return 0; } case 2: case 3: - node.SetInitialScale(lua.Check(&argIndex)); + instance.SetInitialScale(lua.Check(&argIndex)); return 0; } @@ -324,4 +324,4 @@ namespace Ndk font.Register(instance); node.Register(instance); } -} \ No newline at end of file +} diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl index 4473a8600..f8faa7b54 100644 --- a/include/Nazara/Graphics/TileMap.inl +++ b/include/Nazara/Graphics/TileMap.inl @@ -29,7 +29,7 @@ namespace Nz m_isometricModeEnabled(false) { NazaraAssert(m_tiles.size() != 0U, "Invalid map size"); - NazaraAssert(m_tileSize.x != 0U && m_tileSize.y != 0U, "Invalid tile size"); + NazaraAssert(m_tileSize.x > 0 && m_tileSize.y > 0, "Invalid tile size"); NazaraAssert(m_layers.size() != 0U, "Invalid material count"); for (Layer& layer : m_layers) @@ -175,7 +175,7 @@ namespace Nz * \param color The multiplicative color applied to the tile * \param materialIndex The material which will be used for rendering this tile * - * \remark The material at [materialIndex] must have a valid diffuse map before using this function, + * \remark The material at [materialIndex] must have a valid diffuse map before using this function, * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. * * \see EnableTiles @@ -253,7 +253,7 @@ namespace Nz Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height); EnableTiles(unnormalizedCoords, color, materialIndex); } - + /*! * \brief Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations * @@ -434,14 +434,14 @@ namespace Nz * * \param TileMap The other TileMap */ - inline TileMap& TileMap::operator=(const TileMap& TileMap) + inline TileMap& TileMap::operator=(const TileMap& tileMap) { - InstancedRenderable::operator=(TileMap); + InstancedRenderable::operator=(tileMap); - m_layers = TileMap.m_layers; - m_mapSize = TileMap.m_mapSize; - m_tiles = TileMap.m_tiles; - m_tileSize = TileMap.m_tileSize; + m_layers = tileMap.m_layers; + m_mapSize = tileMap.m_mapSize; + m_tiles = tileMap.m_tiles; + m_tileSize = tileMap.m_tileSize; // We do not copy final vertices because it's highly probable that our parameters are modified and they must be regenerated InvalidateBoundingVolume(); diff --git a/include/Nazara/Lua/LuaClass.inl b/include/Nazara/Lua/LuaClass.inl index daf7a632a..3168ba43d 100644 --- a/include/Nazara/Lua/LuaClass.inl +++ b/include/Nazara/Lua/LuaClass.inl @@ -129,7 +129,7 @@ namespace Nz BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int { - handler.ProcessArgs(lua); + handler.ProcessArguments(lua); return handler.Invoke(lua, object, func); }); @@ -143,7 +143,7 @@ namespace Nz BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int { - handler.ProcessArgs(lua); + handler.ProcessArguments(lua); return handler.Invoke(lua, object, func); }); @@ -157,7 +157,7 @@ namespace Nz BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int { - handler.ProcessArgs(lua); + handler.ProcessArguments(lua); return handler.Invoke(lua, object, func); }); @@ -171,7 +171,7 @@ namespace Nz BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int { - handler.ProcessArgs(lua); + handler.ProcessArguments(lua); return handler.Invoke(lua, object, func); }); @@ -203,7 +203,7 @@ namespace Nz BindStaticMethod(name, [func, handler] (LuaInstance& lua) -> int { - handler.ProcessArgs(lua); + handler.ProcessArguments(lua); return handler.Invoke(lua, func); }); @@ -335,7 +335,7 @@ namespace Nz NazaraWarning("Class \"" + m_info->name + "\" already registred in this instance"); { SetupFinalizer(lua); - + if (m_info->getter || !m_info->parentGetters.empty()) SetupGetter(lua, GetterProxy); else diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index 25f193675..9bc20c73a 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -59,7 +59,7 @@ namespace Nz m_memoryUsage = instance.m_memoryUsage; m_state = instance.m_state; m_timeLimit = instance.m_timeLimit; - + instance.m_state = nullptr; return *this; @@ -320,7 +320,7 @@ namespace Nz { } - void ProcessArgs(const LuaInstance& instance) const + void ProcessArguments(const LuaInstance& instance) const { m_index = 1; ProcessArgs<0, Args...>(instance); @@ -391,7 +391,7 @@ namespace Nz { } - void ProcessArgs(const LuaInstance& instance) const + void ProcessArguments(const LuaInstance& instance) const { m_index = 2; //< 1 being the instance ProcessArgs<0, Args...>(instance); @@ -714,7 +714,7 @@ namespace Nz PushFunction([func, handler] (LuaInstance& lua) -> int { - handler.ProcessArgs(lua); + handler.ProcessArguments(lua); return handler.Invoke(lua, func); }); diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index 021cb6378..f045ac28a 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -792,7 +792,7 @@ namespace Nz template bool Matrix4::IsAffine() const { - return m14 == F(0.0) && m24 == F(0.0) && m34 == F(0.0) && m44 == F(1.0); + return NumberEquals(m14, F(0.0)) && NumberEquals(m24, F(0.0)) && NumberEquals(m34, F(0.0)) && NumberEquals(m44, F(1.0)); } /*! diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index 555286024..604cbfb86 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -911,9 +911,9 @@ namespace Nz template bool Vector3::operator<(const Vector3& vec) const { - if (x == vec.x) + if (NumberEquals(x, vec.x)) { - if (y == vec.y) + if (NumberEquals(y, vec.y)) return z < vec.z; else return y < vec.y; @@ -931,10 +931,10 @@ namespace Nz template bool Vector3::operator<=(const Vector3& vec) const { - if (x == vec.x) + if (NumberEquals(x, vec.x)) { - if (y == vec.y) - return z <= vec.z; + if (NumberEquals(y, vec.y)) + return NumberEquals(z, vec.z) || z < vec.z; else return y < vec.y; } @@ -1371,7 +1371,7 @@ namespace std } }; } - + #undef F #include diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index 190d31b99..f3cad0a31 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -843,11 +843,11 @@ namespace Nz template bool Vector4::operator<(const Vector4& vec) const { - if (x == vec.x) + if (NumberEquals(x, vec.x)) { - if (y == vec.y) + if (NumberEquals(y, vec.y)) { - if (z == vec.z) + if (NumberEquals(z, vec.z)) return w < vec.w; else return z < vec.z; @@ -869,12 +869,12 @@ namespace Nz template bool Vector4::operator<=(const Vector4& vec) const { - if (x == vec.x) + if (NumberEquals(x, vec.x)) { - if (y == vec.y) + if (NumberEquals(y, vec.y)) { - if (z == vec.z) - return w <= vec.w; + if (NumberEquals(z, vec.z)) + return NumberEquals(w, vec.w) || w < vec.w; else return z < vec.z; } @@ -1144,7 +1144,7 @@ namespace std } }; } - + #undef F #include diff --git a/include/Nazara/Network/IpAddress.inl b/include/Nazara/Network/IpAddress.inl index 1eaef4341..ed06b1af7 100644 --- a/include/Nazara/Network/IpAddress.inl +++ b/include/Nazara/Network/IpAddress.inl @@ -380,7 +380,7 @@ namespace std // This is SDBM adapted for IP addresses, tested to generate the least collisions possible // (It doesn't mean it cannot be improved though) - std::size_t hash = 0; + std::size_t h = 0; switch (ip.GetProtocol()) { case Nz::NetProtocol_Any: @@ -389,20 +389,20 @@ namespace std case Nz::NetProtocol_IPv4: { - hash = ip.ToUInt32() + (hash << 6) + (hash << 16) - hash; + h = ip.ToUInt32() + (h << 6) + (h << 16) - h; break; } case Nz::NetProtocol_IPv6: { Nz::IpAddress::IPv6 v6 = ip.ToIPv6(); for (std::size_t i = 0; i < v6.size(); i++) - hash = v6[i] + (hash << 6) + (hash << 16) - hash; + h = v6[i] + (h << 6) + (h << 16) - h; break; } } - return ip.GetPort() + (hash << 6) + (hash << 16) - hash; + return ip.GetPort() + (h << 6) + (h << 16) - h; } }; } diff --git a/include/Nazara/Physics2D/ConfigCheck.hpp b/include/Nazara/Physics2D/ConfigCheck.hpp index 4689d6e68..3b3b90afc 100644 --- a/include/Nazara/Physics2D/ConfigCheck.hpp +++ b/include/Nazara/Physics2D/ConfigCheck.hpp @@ -10,9 +10,9 @@ /// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp // On force la valeur de MANAGE_MEMORY en mode debug -#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS_MANAGE_MEMORY - #undef NAZARA_PHYSICS_MANAGE_MEMORY - #define NAZARA_PHYSICS3D_MANAGE_MEMORY 0 +#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS2D_MANAGE_MEMORY + #undef NAZARA_PHYSICS2D_MANAGE_MEMORY + #define NAZARA_PHYSICS2D_MANAGE_MEMORY 0 #endif #endif // NAZARA_CONFIG_CHECK_PHYSICS_HPP diff --git a/include/Nazara/Physics2D/Debug.hpp b/include/Nazara/Physics2D/Debug.hpp index f9cebc624..729491e7c 100644 --- a/include/Nazara/Physics2D/Debug.hpp +++ b/include/Nazara/Physics2D/Debug.hpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#if NAZARA_PHYSICS_MANAGE_MEMORY +#include +#if NAZARA_PHYSICS2D_MANAGE_MEMORY #include #endif diff --git a/include/Nazara/Physics2D/DebugOff.hpp b/include/Nazara/Physics2D/DebugOff.hpp index dd95ffe34..ffbd0a25a 100644 --- a/include/Nazara/Physics2D/DebugOff.hpp +++ b/include/Nazara/Physics2D/DebugOff.hpp @@ -3,7 +3,7 @@ // 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 -#if NAZARA_PHYSICS_MANAGE_MEMORY +#if NAZARA_PHYSICS2D_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/Physics3D/ConfigCheck.hpp b/include/Nazara/Physics3D/ConfigCheck.hpp index 6b1c82073..012cc426c 100644 --- a/include/Nazara/Physics3D/ConfigCheck.hpp +++ b/include/Nazara/Physics3D/ConfigCheck.hpp @@ -10,8 +10,8 @@ /// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp // On force la valeur de MANAGE_MEMORY en mode debug -#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS_MANAGE_MEMORY - #undef NAZARA_PHYSICS_MANAGE_MEMORY +#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS3D_MANAGE_MEMORY + #undef NAZARA_PHYSICS3D_MANAGE_MEMORY #define NAZARA_PHYSICS3D_MANAGE_MEMORY 0 #endif diff --git a/include/Nazara/Physics3D/Debug.hpp b/include/Nazara/Physics3D/Debug.hpp index f70a8b570..ef111fb96 100644 --- a/include/Nazara/Physics3D/Debug.hpp +++ b/include/Nazara/Physics3D/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_PHYSICS_MANAGE_MEMORY +#if NAZARA_PHYSICS3D_MANAGE_MEMORY #include #endif diff --git a/include/Nazara/Physics3D/DebugOff.hpp b/include/Nazara/Physics3D/DebugOff.hpp index 595f0ad94..b8b84c240 100644 --- a/include/Nazara/Physics3D/DebugOff.hpp +++ b/include/Nazara/Physics3D/DebugOff.hpp @@ -3,7 +3,7 @@ // 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 -#if NAZARA_PHYSICS_MANAGE_MEMORY +#if NAZARA_PHYSICS3D_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/Physics3D/Enums.hpp b/include/Nazara/Physics3D/Enums.hpp index 1b8920cbc..b01c9bb83 100644 --- a/include/Nazara/Physics3D/Enums.hpp +++ b/include/Nazara/Physics3D/Enums.hpp @@ -25,6 +25,6 @@ namespace Nz ColliderType3D_Max = ColliderType3D_Tree }; -}; +} #endif // NAZARA_ENUMS_PHYSICS3D_HPP diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 131ceb7f3..1fd77546f 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -906,5 +906,5 @@ namespace Nz } return true; - }; + } } diff --git a/src/Nazara/Graphics/InstancedRenderable.cpp b/src/Nazara/Graphics/InstancedRenderable.cpp index ef5f62b96..e927e2d22 100644 --- a/src/Nazara/Graphics/InstancedRenderable.cpp +++ b/src/Nazara/Graphics/InstancedRenderable.cpp @@ -94,6 +94,7 @@ namespace Nz void InstancedRenderable::UpdateData(InstanceData* instanceData) const { NazaraAssert(instanceData, "Invalid instance data"); + NazaraUnused(instanceData); } InstancedRenderableLibrary::LibraryMap InstancedRenderable::s_library; diff --git a/src/Nazara/Network/NetPacket.cpp b/src/Nazara/Network/NetPacket.cpp index 0823f5258..dcac9e178 100644 --- a/src/Nazara/Network/NetPacket.cpp +++ b/src/Nazara/Network/NetPacket.cpp @@ -146,7 +146,7 @@ namespace Nz if (!m_buffer) m_buffer = std::make_unique(); - m_buffer->Resize(static_cast(cursorPos)); + m_buffer->Resize(minCapacity); m_memoryStream.SetBuffer(m_buffer.get(), openMode); m_memoryStream.SetCursorPos(cursorPos); diff --git a/src/Nazara/Network/TcpClient.cpp b/src/Nazara/Network/TcpClient.cpp index 1c84dc498..2be3d44cf 100644 --- a/src/Nazara/Network/TcpClient.cpp +++ b/src/Nazara/Network/TcpClient.cpp @@ -385,7 +385,7 @@ namespace Nz * \remark Produces a NazaraError because it is a special stream */ - bool TcpClient::SetCursorPos(UInt64 offset) + bool TcpClient::SetCursorPos(UInt64 /*offset*/) { NazaraError("SetCursorPos() cannot be used on sequential streams"); return false; diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 628d29807..5a02b4bae 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -437,6 +437,10 @@ namespace Nz return result; #else + NazaraUnused(fdarray); + NazaraUnused(nfds); + NazaraUnused(timeout); + if (error) *error = SocketError_NotSupported; diff --git a/src/Nazara/Physics2D/Debug/NewOverload.cpp b/src/Nazara/Physics2D/Debug/NewOverload.cpp index bd3153d1d..0c82acc94 100644 --- a/src/Nazara/Physics2D/Debug/NewOverload.cpp +++ b/src/Nazara/Physics2D/Debug/NewOverload.cpp @@ -2,8 +2,8 @@ // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#if NAZARA_PHYSICS_MANAGE_MEMORY +#include +#if NAZARA_PHYSICS2D_MANAGE_MEMORY #include #include // Nécessaire ? diff --git a/src/Nazara/Physics3D/Debug/NewOverload.cpp b/src/Nazara/Physics3D/Debug/NewOverload.cpp index 18092514c..b87984066 100644 --- a/src/Nazara/Physics3D/Debug/NewOverload.cpp +++ b/src/Nazara/Physics3D/Debug/NewOverload.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_PHYSICS_MANAGE_MEMORY +#if NAZARA_PHYSICS3D_MANAGE_MEMORY #include #include // Nécessaire ? diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp index 647b8ff91..d90ba5f1a 100644 --- a/src/Nazara/Renderer/RenderTexture.cpp +++ b/src/Nazara/Renderer/RenderTexture.cpp @@ -795,6 +795,7 @@ namespace Nz NazaraAssert(attachmentIndex < m_impl->attachments.size(), "Invalid attachment index"); NazaraAssert(!m_impl->attachments[attachmentIndex].isBuffer, "Invalid attachment state"); NazaraUnused(texture); + NazaraUnused(attachmentIndex); InvalidateTargets(); } diff --git a/src/Nazara/Utility/Formats/MTLParser.cpp b/src/Nazara/Utility/Formats/MTLParser.cpp index 1bbed892f..c3b60a6e5 100644 --- a/src/Nazara/Utility/Formats/MTLParser.cpp +++ b/src/Nazara/Utility/Formats/MTLParser.cpp @@ -331,19 +331,19 @@ namespace Nz Emit(mat.specular.b / 255.f); EmitLine(); - if (mat.alpha != 1.f) + if (!NumberEquals(mat.alpha, 1.f)) { Emit("d "); EmitLine(mat.alpha); } - if (mat.refractionIndex != 1.f) + if (!NumberEquals(mat.refractionIndex, 1.f)) { Emit("ni "); EmitLine(mat.refractionIndex); } - if (mat.shininess != 1.f) + if (!NumberEquals(mat.shininess, 1.f)) { Emit("ns "); EmitLine(mat.shininess); diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 3b03b7f78..eed0ee2b1 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -128,17 +128,17 @@ namespace Nz UInt32 faceReserve = 0; UInt32 vertexReserve = 0; unsigned int matCount = 0; - auto GetMaterial = [&] (const String& meshName, const String& matName) -> Mesh* + auto GetMaterial = [&] (const String& mesh, const String& mat) -> Mesh* { - auto& map = meshesByName[meshName]; - auto it = map.find(matName); + auto& map = meshesByName[mesh]; + auto it = map.find(mat); if (it == map.end()) - it = map.insert(std::make_pair(matName, MatPair(Mesh(), matCount++))).first; + it = map.insert(std::make_pair(mat, MatPair(Mesh(), matCount++))).first; - Mesh& mesh = it->second.first; + Mesh& meshData = it->second.first; - mesh.faces.reserve(faceReserve); - mesh.vertices.reserve(vertexReserve); + meshData.faces.reserve(faceReserve); + meshData.vertices.reserve(vertexReserve); faceReserve = 0; vertexReserve = 0; @@ -550,19 +550,19 @@ namespace Nz EmitLine(pair.second.size()); EmitLine(); - for (std::size_t meshIndex : pair.second) + for (std::size_t index : pair.second) { - const Mesh& mesh = m_meshes[meshIndex]; + const Mesh& mesh = m_meshes[index]; Emit("g "); EmitLine(mesh.name); EmitLine(); - + Emit("# face count: "); EmitLine(mesh.faces.size()); Emit("# vertex count: "); EmitLine(mesh.vertices.size()); - + for (const Face& face : mesh.faces) { Emit('f'); diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index 03a95f35a..0d06fa0ba 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -75,6 +75,7 @@ namespace Nz Font* SimpleTextDrawer::GetFont(std::size_t index) const { NazaraAssert(index == 0, "Font index out of range"); + NazaraUnused(index); return m_font; } diff --git a/src/Nazara/Utility/SoftwareBuffer.cpp b/src/Nazara/Utility/SoftwareBuffer.cpp index 081f0fda3..040017c1e 100644 --- a/src/Nazara/Utility/SoftwareBuffer.cpp +++ b/src/Nazara/Utility/SoftwareBuffer.cpp @@ -11,7 +11,7 @@ namespace Nz { - SoftwareBuffer::SoftwareBuffer(Buffer* /*parent*/, BufferType type) + SoftwareBuffer::SoftwareBuffer(Buffer* /*parent*/, BufferType /*type*/) { }