Fix many errors and warnings found out by MinGW

This commit is contained in:
Jérôme Leclercq 2016-11-04 18:14:52 +01:00
parent c7d011cd00
commit e087129d4a
38 changed files with 1126 additions and 211 deletions

View File

@ -373,9 +373,9 @@ namespace Ndk
{
}
inline Application::WindowInfo::WindowInfo(std::unique_ptr<Nz::Window>&& window) :
inline Application::WindowInfo::WindowInfo(std::unique_ptr<Nz::Window>&& windowPtr) :
renderTarget(nullptr),
window(std::move(window))
window(std::move(windowPtr))
{
}
#endif

View File

@ -73,12 +73,12 @@ 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)
{
}

View File

@ -223,7 +223,7 @@ namespace Nz
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Matrix4f* mat, TypeTag<Matrix4f>)
{
Matrix4d matDouble;
Matrix4d matDouble = Matrix4d::Identity();
unsigned int ret = LuaImplQueryArg(instance, index, &matDouble, TypeTag<Matrix4d>());
mat->Set(matDouble);

View File

@ -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;
});

View File

@ -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<Nz::Int64>(&argIndex, 0);
bool paused = lua.Check<bool>(&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<std::size_t>(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<Nz::String>(&argIndex));
Nz::PlacementNew(instance, lua.Check<Nz::String>(&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<std::size_t>(&argIndex);
std::unique_ptr<char[]> 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<std::size_t>(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<Nz::String>(&argIndex);
Nz::PlacementNew(file, filePath);
Nz::PlacementNew(instance, filePath);
return true;
}
@ -162,7 +162,7 @@ namespace Ndk
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&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<std::size_t>(argumentCount, 2U);
@ -210,13 +210,13 @@ namespace Ndk
{
case 0:
case 1:
return lua.Push(file.Open(lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen)));
return lua.Push(instance.Open(lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen)));
case 2:
{
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&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<std::size_t>(argumentCount, 2U);
@ -232,13 +232,13 @@ namespace Ndk
switch (argCount)
{
case 1:
return lua.Push(file.SetCursorPos(lua.Check<Nz::UInt64>(&argIndex)));
return lua.Push(instance.SetCursorPos(lua.Check<Nz::UInt64>(&argIndex)));
case 2:
{
Nz::CursorPosition curPos = lua.Check<Nz::CursorPosition>(&argIndex);
Nz::Int64 offset = lua.Check<Nz::Int64>(&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;
});
}

View File

@ -231,14 +231,14 @@ namespace Ndk
});
/*********************************** Nz::Model ***********************************/
model.Inherit<Nz::InstancedRenderableRef>(instancedRenderable, [] (Nz::ModelRef* model) -> Nz::InstancedRenderableRef*
model.Inherit<Nz::InstancedRenderableRef>(instancedRenderable, [] (Nz::ModelRef* modelRef) -> Nz::InstancedRenderableRef*
{
return reinterpret_cast<Nz::InstancedRenderableRef*>(model); //TODO: Make a ObjectRefCast
return reinterpret_cast<Nz::InstancedRenderableRef*>(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<Nz::InstancedRenderableRef>(instancedRenderable, [] (Nz::SpriteRef* sprite) -> Nz::InstancedRenderableRef*
sprite.Inherit<Nz::InstancedRenderableRef>(instancedRenderable, [] (Nz::SpriteRef* spriteRef) -> Nz::InstancedRenderableRef*
{
return reinterpret_cast<Nz::InstancedRenderableRef*>(sprite); //TODO: Make a ObjectRefCast
return reinterpret_cast<Nz::InstancedRenderableRef*>(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;
});

View File

@ -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<std::size_t>(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<Nz::EulerAnglesd*>(lua.CheckUserdata(1, "EulerAngles")));
Nz::PlacementNew(instance, *static_cast<Nz::EulerAnglesd*>(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;
}
@ -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<std::size_t>(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<Nz::Rectd*>(lua.ToUserdata(1)));
PlacementNew(instance, *static_cast<Nz::Rectd*>(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<double>("x", 1),
lua.CheckField<double>("y", 1),
lua.CheckField<double>("width", 1),
lua.CheckField<double>("height", 1));
PlacementNew(instance, lua.CheckField<double>("x", 1),
lua.CheckField<double>("y", 1),
lua.CheckField<double>("width", 1),
lua.CheckField<double>("height", 1));
}
else if (lua.IsOfType(1, "Vector2"))
PlacementNew(rect, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)));
PlacementNew(instance, *static_cast<Nz::Vector2d*>(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<Nz::Vector2d*>(lua.ToUserdata(1)), *static_cast<Nz::Vector2d*>(lua.ToUserdata(2)));
PlacementNew(instance, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)), *static_cast<Nz::Vector2d*>(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<std::size_t>(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<Nz::EulerAnglesd*>(lua.ToUserdata(1)));
Nz::PlacementNew(instance, *static_cast<Nz::EulerAnglesd*>(lua.ToUserdata(1)));
else if (lua.IsOfType(1, "Quaternion"))
Nz::PlacementNew(quaternion, *static_cast<Nz::Quaterniond*>(lua.ToUserdata(1)));
Nz::PlacementNew(instance, *static_cast<Nz::Quaterniond*>(lua.ToUserdata(1)));
else
break;
@ -539,11 +539,11 @@ namespace Ndk
}
case 2:
Nz::PlacementNew(quaternion, lua.CheckNumber(1), *static_cast<Nz::Vector3d*>(lua.CheckUserdata(2, "Vector3")));
Nz::PlacementNew(instance, lua.CheckNumber(1), *static_cast<Nz::Vector3d*>(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:

View File

@ -0,0 +1,908 @@
// This file was automatically generated on 26 May 2014 at 01:05:31
#include <NDK/LuaBinding.hpp>
#include <Nazara/Core/MemoryHelper.hpp>
#include <NDK/LuaAPI.hpp>
#include <cstring>
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<std::size_t>(argumentCount, 1U);
switch (argCount)
{
case 0:
Nz::PlacementNew(angles, Nz::EulerAnglesd::Zero());
return true;
case 1:
Nz::PlacementNew(angles, *static_cast<Nz::EulerAnglesd*>(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<std::size_t>(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<Nz::Matrix4d*>(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<std::size_t>(argumentCount, 3U);
int argIndex = 2;
switch (argCount)
{
case 1:
if (lua.IsOfType(argIndex, "Matrix4"))
instance.Set(*static_cast<Nz::Matrix4d*>(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<Nz::Vector2d*>(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<Nz::Vector3d*>(lua.ToUserdata(argIndex)), w));
}
//else if (lua.IsOfType(2, "Vector4"))
// return lua.Push(instance.Transform(*static_cast<Nz::Vector4d*>(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<std::size_t>(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<std::size_t>(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<std::size_t>(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<Nz::Rectd*>(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<double>("x", 1),
lua.CheckField<double>("y", 1),
lua.CheckField<double>("width", 1),
lua.CheckField<double>("height", 1));
}
else if (lua.IsOfType(1, "Vector2"))
PlacementNew(rect, *static_cast<Nz::Vector2d*>(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<Nz::Vector2d*>(lua.ToUserdata(1)), *static_cast<Nz::Vector2d*>(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<std::size_t>(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<std::size_t>(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<std::size_t>(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<Nz::EulerAnglesd*>(lua.ToUserdata(1)));
else if (lua.IsOfType(1, "Quaternion"))
Nz::PlacementNew(quaternion, *static_cast<Nz::Quaterniond*>(lua.ToUserdata(1)));
else
break;
return true;
}
case 2:
Nz::PlacementNew(quaternion, lua.CheckNumber(1), *static_cast<Nz::Vector3d*>(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<std::size_t>(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<Nz::Vector2d*>(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<std::size_t>(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<Nz::Vector2d*>(lua.ToUserdata(1)));
else if (lua.IsOfType(1, "Vector3"))
Nz::PlacementNew(vector, *static_cast<Nz::Vector3d*>(lua.ToUserdata(1)));
else
break;
return true;
}
case 2:
{
if (lua.IsOfType(1, Nz::LuaType_Number))
Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast<Nz::Vector2d*>(lua.CheckUserdata(2, "Vector2")));
else if (lua.IsOfType(1, "Vector2"))
Nz::PlacementNew(vector, *static_cast<Nz::Vector2d*>(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);
}
}

View File

@ -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<std::size_t>(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<Nz::UInt8>(&argIndex);
Nz::UInt16 port = lua.Check<Nz::UInt16>(&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<Nz::UInt16>(&argIndex);
Nz::UInt16 port = lua.Check<Nz::UInt16>(&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;
}
}

View File

@ -13,14 +13,14 @@ namespace Ndk
void LuaBinding::BindRenderer()
{
/*********************************** Nz::Texture ***********************************/
texture.Inherit<Nz::AbstractImageRef>(abstractImage, [] (Nz::TextureRef* texture) -> Nz::AbstractImageRef*
texture.Inherit<Nz::AbstractImageRef>(abstractImage, [] (Nz::TextureRef* textureRef) -> Nz::AbstractImageRef*
{
return reinterpret_cast<Nz::AbstractImageRef*>(texture); //TODO: Make a ObjectRefCast
return reinterpret_cast<Nz::AbstractImageRef*>(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;
});

View File

@ -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;
});
@ -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<Nz::InstancedRenderableRef>(&argIndex));
instance->Attach(lua.Check<Nz::InstancedRenderableRef>(&argIndex));
return 0;
}
@ -166,13 +166,13 @@ namespace Ndk
{
int renderOrder = lua.Check<int>(&argIndex);
gfxComponent->Attach(renderable, renderOrder);
instance->Attach(renderable, renderOrder);
}
else if (lua.IsOfType(argIndex, "Matrix4"))
{
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&argIndex);
gfxComponent->Attach(renderable, localMatrix);
instance->Attach(renderable, localMatrix);
}
else
break;
@ -187,7 +187,7 @@ namespace Ndk
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&argIndex);
int renderOrder = lua.Check<int>(&argIndex);
gfxComponent->Attach(renderable, localMatrix, renderOrder);
instance->Attach(renderable, localMatrix, renderOrder);
return 0;
}
}

View File

@ -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<std::size_t>(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<Nz::UInt8>(&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<std::size_t>(argumentCount, 6U);
int argIndex = 2;
@ -62,7 +62,7 @@ namespace Ndk
Nz::UInt8 level = lua.Check<Nz::UInt8>(&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<Nz::Vector3f>(&argIndex);
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&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<Nz::Quaternionf>(&argIndex);
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&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<std::size_t>(argumentCount, 4U);
@ -231,15 +231,15 @@ namespace Ndk
case 1:
{
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
node.Scale(lua.Check<float>(&argIndex));
instance.Scale(lua.Check<float>(&argIndex));
else
node.Scale(lua.Check<Nz::Vector3f>(&argIndex));
instance.Scale(lua.Check<Nz::Vector3f>(&argIndex));
return 0;
}
case 3:
node.Scale(lua.Check<Nz::Vector3f>(&argIndex));
instance.Scale(lua.Check<Nz::Vector3f>(&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<std::size_t>(argumentCount, 4U);
@ -261,10 +261,10 @@ namespace Ndk
{
float scale = lua.Check<float>(&argIndex);
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
node.SetScale(scale, coordSys);
instance.SetScale(scale, coordSys);
}
else
node.SetScale(lua.Check<Nz::Vector3f>(&argIndex));
instance.SetScale(lua.Check<Nz::Vector3f>(&argIndex));
return 0;
}
@ -275,7 +275,7 @@ namespace Ndk
Nz::Vector3f scale = lua.Check<Nz::Vector3f>(&argIndex);
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&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<std::size_t>(argumentCount, 4U);
@ -294,16 +294,16 @@ namespace Ndk
case 1:
{
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
node.SetInitialScale(lua.Check<float>(&argIndex));
instance.SetInitialScale(lua.Check<float>(&argIndex));
else
node.SetInitialScale(lua.Check<Nz::Vector2f>(&argIndex));
instance.SetInitialScale(lua.Check<Nz::Vector2f>(&argIndex));
return 0;
}
case 2:
case 3:
node.SetInitialScale(lua.Check<Nz::Vector3f>(&argIndex));
instance.SetInitialScale(lua.Check<Nz::Vector3f>(&argIndex));
return 0;
}

View File

@ -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)
@ -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();

View File

@ -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);
});

View File

@ -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);
});

View File

@ -792,7 +792,7 @@ namespace Nz
template<typename T>
bool Matrix4<T>::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));
}
/*!

View File

@ -911,9 +911,9 @@ namespace Nz
template<typename T>
bool Vector3<T>::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<typename T>
bool Vector3<T>::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;
}

View File

@ -843,11 +843,11 @@ namespace Nz
template<typename T>
bool Vector4<T>::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<typename T>
bool Vector4<T>::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;
}

View File

@ -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;
}
};
}

View File

@ -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

View File

@ -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 <Nazara/Physics3D/Config.hpp>
#if NAZARA_PHYSICS_MANAGE_MEMORY
#include <Nazara/Physics2D/Config.hpp>
#if NAZARA_PHYSICS2D_MANAGE_MEMORY
#include <Nazara/Core/Debug/NewRedefinition.hpp>
#endif

View File

@ -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

View File

@ -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

View File

@ -3,6 +3,6 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Physics3D/Config.hpp>
#if NAZARA_PHYSICS_MANAGE_MEMORY
#if NAZARA_PHYSICS3D_MANAGE_MEMORY
#include <Nazara/Core/Debug/NewRedefinition.hpp>
#endif

View File

@ -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

View File

@ -25,6 +25,6 @@ namespace Nz
ColliderType3D_Max = ColliderType3D_Tree
};
};
}
#endif // NAZARA_ENUMS_PHYSICS3D_HPP

View File

@ -906,5 +906,5 @@ namespace Nz
}
return true;
};
}
}

View File

@ -94,6 +94,7 @@ namespace Nz
void InstancedRenderable::UpdateData(InstanceData* instanceData) const
{
NazaraAssert(instanceData, "Invalid instance data");
NazaraUnused(instanceData);
}
InstancedRenderableLibrary::LibraryMap InstancedRenderable::s_library;

View File

@ -146,7 +146,7 @@ namespace Nz
if (!m_buffer)
m_buffer = std::make_unique<ByteArray>();
m_buffer->Resize(static_cast<std::size_t>(cursorPos));
m_buffer->Resize(minCapacity);
m_memoryStream.SetBuffer(m_buffer.get(), openMode);
m_memoryStream.SetCursorPos(cursorPos);

View File

@ -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;

View File

@ -437,6 +437,10 @@ namespace Nz
return result;
#else
NazaraUnused(fdarray);
NazaraUnused(nfds);
NazaraUnused(timeout);
if (error)
*error = SocketError_NotSupported;

View File

@ -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 <Nazara/Physics3D/Config.hpp>
#if NAZARA_PHYSICS_MANAGE_MEMORY
#include <Nazara/Physics2D/Config.hpp>
#if NAZARA_PHYSICS2D_MANAGE_MEMORY
#include <Nazara/Core/MemoryManager.hpp>
#include <new> // Nécessaire ?

View File

@ -3,7 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Physics3D/Config.hpp>
#if NAZARA_PHYSICS_MANAGE_MEMORY
#if NAZARA_PHYSICS3D_MANAGE_MEMORY
#include <Nazara/Core/MemoryManager.hpp>
#include <new> // Nécessaire ?

View File

@ -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();
}

View File

@ -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);

View File

@ -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,9 +550,9 @@ 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);

View File

@ -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;
}

View File

@ -11,7 +11,7 @@
namespace Nz
{
SoftwareBuffer::SoftwareBuffer(Buffer* /*parent*/, BufferType type)
SoftwareBuffer::SoftwareBuffer(Buffer* /*parent*/, BufferType /*type*/)
{
}