Fix many errors and warnings found out by MinGW
This commit is contained in:
parent
c7d011cd00
commit
e087129d4a
|
|
@ -59,7 +59,7 @@ namespace Ndk
|
||||||
* \param args Arguments used to create the window
|
* \param args Arguments used to create the window
|
||||||
*/
|
*/
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
template<typename T, typename... Args>
|
template<typename T, typename... Args>
|
||||||
T& Application::AddWindow(Args&&... args)
|
T& Application::AddWindow(Args&&... args)
|
||||||
{
|
{
|
||||||
static_assert(std::is_base_of<Nz::Window, T>::value, "Type must inherit Window");
|
static_assert(std::is_base_of<Nz::Window, T>::value, "Type must inherit Window");
|
||||||
|
|
@ -82,7 +82,7 @@ namespace Ndk
|
||||||
* \param args Arguments used to create the world
|
* \param args Arguments used to create the world
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
World& Application::AddWorld(Args&&... args)
|
World& Application::AddWorld(Args&&... args)
|
||||||
{
|
{
|
||||||
m_worlds.emplace_back(std::forward<Args>(args)...);
|
m_worlds.emplace_back(std::forward<Args>(args)...);
|
||||||
|
|
@ -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),
|
renderTarget(nullptr),
|
||||||
window(std::move(window))
|
window(std::move(windowPtr))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -73,19 +73,19 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderable(Renderable&& renderable) noexcept :
|
Renderable(Renderable&& rhs) noexcept :
|
||||||
renderableInvalidationSlot(std::move(renderable.renderableInvalidationSlot)),
|
renderableInvalidationSlot(std::move(rhs.renderableInvalidationSlot)),
|
||||||
renderableReleaseSlot(std::move(renderable.renderableReleaseSlot)),
|
renderableReleaseSlot(std::move(rhs.renderableReleaseSlot)),
|
||||||
data(std::move(renderable.data)),
|
data(std::move(rhs.data)),
|
||||||
renderable(std::move(renderable.renderable)),
|
renderable(std::move(rhs.renderable)),
|
||||||
dataUpdated(renderable.dataUpdated)
|
dataUpdated(rhs.dataUpdated)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~Renderable()
|
~Renderable()
|
||||||
{
|
{
|
||||||
// Disconnect release slot before releasing instanced renderable reference
|
// Disconnect release slot before releasing instanced renderable reference
|
||||||
renderableReleaseSlot.Disconnect();
|
renderableReleaseSlot.Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderable& operator=(Renderable&& r) noexcept
|
Renderable& operator=(Renderable&& r) noexcept
|
||||||
|
|
@ -118,4 +118,4 @@ namespace Ndk
|
||||||
#include <NDK/Components/GraphicsComponent.inl>
|
#include <NDK/Components/GraphicsComponent.inl>
|
||||||
|
|
||||||
#endif // NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP
|
#endif // NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP
|
||||||
#endif // NDK_SERVER
|
#endif // NDK_SERVER
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ namespace Nz
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Matrix4f* mat, TypeTag<Matrix4f>)
|
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>());
|
unsigned int ret = LuaImplQueryArg(instance, index, &matDouble, TypeTag<Matrix4d>());
|
||||||
|
|
||||||
mat->Set(matDouble);
|
mat->Set(matDouble);
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,12 @@ namespace Ndk
|
||||||
music.BindMethod("Stop", &Nz::Music::Stop);
|
music.BindMethod("Stop", &Nz::Music::Stop);
|
||||||
|
|
||||||
// Manual
|
// 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(");
|
Nz::StringStream ss("Music(");
|
||||||
stream << music.GetFilePath() << ')';
|
ss << instance.GetFilePath() << ')';
|
||||||
|
|
||||||
lua.PushString(stream);
|
lua.PushString(ss);
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -65,15 +65,15 @@ namespace Ndk
|
||||||
sound.BindMethod("SetPlayingOffset", &Nz::Sound::SetPlayingOffset);
|
sound.BindMethod("SetPlayingOffset", &Nz::Sound::SetPlayingOffset);
|
||||||
|
|
||||||
// Manual
|
// 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(");
|
Nz::StringStream ss("Sound(");
|
||||||
if (const Nz::SoundBuffer* buffer = sound.GetBuffer())
|
if (const Nz::SoundBuffer* buffer = instance.GetBuffer())
|
||||||
stream << buffer;
|
ss << buffer;
|
||||||
|
|
||||||
stream << ')';
|
ss << ')';
|
||||||
|
|
||||||
lua.PushString(stream);
|
lua.PushString(ss);
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -124,18 +124,18 @@ namespace Ndk
|
||||||
|
|
||||||
soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance, std::size_t /*argumentCount*/) -> int
|
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())
|
if (instance->IsValid())
|
||||||
{
|
{
|
||||||
Nz::String filePath = instance->GetFilePath();
|
Nz::String filePath = instance->GetFilePath();
|
||||||
if (!filePath.IsEmpty())
|
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;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@ namespace Ndk
|
||||||
void LuaBinding::BindCore()
|
void LuaBinding::BindCore()
|
||||||
{
|
{
|
||||||
/*********************************** Nz::Clock **********************************/
|
/*********************************** 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;
|
int argIndex = 2;
|
||||||
Nz::Int64 startingValue = lua.Check<Nz::Int64>(&argIndex, 0);
|
Nz::Int64 startingValue = lua.Check<Nz::Int64>(&argIndex, 0);
|
||||||
bool paused = lua.Check<bool>(&argIndex, false);
|
bool paused = lua.Check<bool>(&argIndex, false);
|
||||||
|
|
||||||
Nz::PlacementNew(clock, startingValue, paused);
|
Nz::PlacementNew(instance, startingValue, paused);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -32,19 +32,19 @@ namespace Ndk
|
||||||
clock.BindMethod("Unpause", &Nz::Clock::Unpause);
|
clock.BindMethod("Unpause", &Nz::Clock::Unpause);
|
||||||
|
|
||||||
// Manual
|
// Manual
|
||||||
clock.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& clock, std::size_t /*argumentCount*/) -> int {
|
clock.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Clock& instance, std::size_t /*argumentCount*/) -> int {
|
||||||
Nz::StringStream stream("Clock(Elapsed: ");
|
Nz::StringStream ss("Clock(Elapsed: ");
|
||||||
stream << clock.GetSeconds();
|
ss << instance.GetSeconds();
|
||||||
stream << "s, Paused: ";
|
ss << "s, Paused: ";
|
||||||
stream << clock.IsPaused();
|
ss << instance.IsPaused();
|
||||||
stream << ')';
|
ss << ')';
|
||||||
|
|
||||||
lua.PushString(stream);
|
lua.PushString(ss);
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
/********************************* Nz::Directory ********************************/
|
/********************************* 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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||||
|
|
||||||
|
|
@ -52,11 +52,11 @@ namespace Ndk
|
||||||
switch (argCount)
|
switch (argCount)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
Nz::PlacementNew(directory);
|
Nz::PlacementNew(instance);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
Nz::PlacementNew(directory, lua.Check<Nz::String>(&argIndex));
|
Nz::PlacementNew(instance, lua.Check<Nz::String>(&argIndex));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,12 +85,12 @@ namespace Ndk
|
||||||
directory.BindStaticMethod("SetCurrent", Nz::Directory::SetCurrent);
|
directory.BindStaticMethod("SetCurrent", Nz::Directory::SetCurrent);
|
||||||
|
|
||||||
// Manual
|
// Manual
|
||||||
directory.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Directory& directory, std::size_t /*argumentCount*/) -> int {
|
directory.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::Directory& instance, std::size_t /*argumentCount*/) -> int {
|
||||||
Nz::StringStream stream("Directory(");
|
Nz::StringStream ss("Directory(");
|
||||||
stream << directory.GetPath();
|
ss << instance.GetPath();
|
||||||
stream << ')';
|
ss << ')';
|
||||||
|
|
||||||
lua.PushString(stream);
|
lua.PushString(ss);
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -110,35 +110,35 @@ namespace Ndk
|
||||||
stream.BindMethod("IsWritable", &Nz::Stream::IsWritable);
|
stream.BindMethod("IsWritable", &Nz::Stream::IsWritable);
|
||||||
stream.BindMethod("SetCursorPos", &Nz::Stream::SetCursorPos);
|
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;
|
int argIndex = 2;
|
||||||
|
|
||||||
std::size_t length = lua.Check<std::size_t>(&argIndex);
|
std::size_t length = lua.Check<std::size_t>(&argIndex);
|
||||||
|
|
||||||
std::unique_ptr<char[]> buffer(new char[length]);
|
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));
|
lua.PushString(Nz::String(buffer.get(), readLength));
|
||||||
return 1;
|
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;
|
int argIndex = 2;
|
||||||
|
|
||||||
std::size_t bufferSize = 0;
|
std::size_t bufferSize = 0;
|
||||||
const char* buffer = lua.CheckString(argIndex, &bufferSize);
|
const char* buffer = lua.CheckString(argIndex, &bufferSize);
|
||||||
|
|
||||||
if (stream.IsTextModeEnabled())
|
if (instance.IsTextModeEnabled())
|
||||||
lua.Push(stream.Write(Nz::String(buffer, bufferSize)));
|
lua.Push(instance.Write(Nz::String(buffer, bufferSize)));
|
||||||
else
|
else
|
||||||
lua.Push(stream.Write(buffer, bufferSize));
|
lua.Push(instance.Write(buffer, bufferSize));
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
/*********************************** Nz::File ***********************************/
|
/*********************************** Nz::File ***********************************/
|
||||||
file.Inherit(stream);
|
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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||||
|
|
||||||
|
|
@ -146,14 +146,14 @@ namespace Ndk
|
||||||
switch (argCount)
|
switch (argCount)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
Nz::PlacementNew(file);
|
Nz::PlacementNew(instance);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
||||||
|
|
||||||
Nz::PlacementNew(file, filePath);
|
Nz::PlacementNew(instance, filePath);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ namespace Ndk
|
||||||
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
||||||
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&argIndex);
|
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&argIndex);
|
||||||
|
|
||||||
Nz::PlacementNew(file, filePath, openMode);
|
Nz::PlacementNew(instance, filePath, openMode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -201,7 +201,7 @@ namespace Ndk
|
||||||
file.BindStaticMethod("Rename", &Nz::File::Rename);
|
file.BindStaticMethod("Rename", &Nz::File::Rename);
|
||||||
|
|
||||||
// Manual
|
// 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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||||
|
|
||||||
|
|
@ -210,13 +210,13 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
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:
|
case 2:
|
||||||
{
|
{
|
||||||
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
||||||
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&argIndex, Nz::OpenMode_NotOpen);
|
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;
|
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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
|
||||||
|
|
||||||
|
|
@ -232,13 +232,13 @@ namespace Ndk
|
||||||
switch (argCount)
|
switch (argCount)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return lua.Push(file.SetCursorPos(lua.Check<Nz::UInt64>(&argIndex)));
|
return lua.Push(instance.SetCursorPos(lua.Check<Nz::UInt64>(&argIndex)));
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
Nz::CursorPosition curPos = lua.Check<Nz::CursorPosition>(&argIndex);
|
Nz::CursorPosition curPos = lua.Check<Nz::CursorPosition>(&argIndex);
|
||||||
Nz::Int64 offset = lua.Check<Nz::Int64>(&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;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
file.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& file, std::size_t /*argumentCount*/) -> int {
|
file.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::File& instance, std::size_t /*argumentCount*/) -> int {
|
||||||
Nz::StringStream stream("File(");
|
Nz::StringStream ss("File(");
|
||||||
if (file.IsOpen())
|
if (instance.IsOpen())
|
||||||
stream << "Path: " << file.GetPath();
|
ss << "Path: " << instance.GetPath();
|
||||||
|
|
||||||
stream << ')';
|
ss << ')';
|
||||||
|
|
||||||
lua.PushString(stream);
|
lua.PushString(ss);
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -231,14 +231,14 @@ namespace Ndk
|
||||||
});
|
});
|
||||||
|
|
||||||
/*********************************** Nz::Model ***********************************/
|
/*********************************** 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;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -260,14 +260,14 @@ namespace Ndk
|
||||||
model.BindMethod("SetSkinCount", &Nz::Model::SetSkinCount);
|
model.BindMethod("SetSkinCount", &Nz::Model::SetSkinCount);
|
||||||
|
|
||||||
/*********************************** Nz::Sprite ***********************************/
|
/*********************************** 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;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,22 +14,22 @@ namespace Ndk
|
||||||
void LuaBinding::BindMath()
|
void LuaBinding::BindMath()
|
||||||
{
|
{
|
||||||
/*********************************** Nz::EulerAngles **********************************/
|
/*********************************** 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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||||
|
|
||||||
switch (argCount)
|
switch (argCount)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
Nz::PlacementNew(angles, Nz::EulerAnglesd::Zero());
|
Nz::PlacementNew(instance, Nz::EulerAnglesd::Zero());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 1:
|
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;
|
return true;
|
||||||
|
|
||||||
case 3:
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,7 +154,7 @@ namespace Ndk
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/*********************************** Nz::Matrix4 **********************************/
|
/*********************************** Nz::Matrix4 **********************************/
|
||||||
matrix4d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Matrix4d* matrix, std::size_t argumentCount)
|
matrix4d.SetConstructor([] (Nz::LuaInstance& lua, Nz::Matrix4d* matrix, std::size_t argumentCount)
|
||||||
{
|
{
|
||||||
|
|
@ -227,7 +227,7 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
Nz::Matrix4d result;
|
Nz::Matrix4d result;
|
||||||
instance.GetTransposed(&result);
|
instance.GetTransposed(&result);
|
||||||
|
|
||||||
return lua.Push(result);
|
return lua.Push(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -360,7 +360,7 @@ namespace Ndk
|
||||||
});
|
});
|
||||||
|
|
||||||
/*********************************** Nz::Rect **********************************/
|
/*********************************** 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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||||
|
|
||||||
|
|
@ -368,23 +368,23 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
case 4:
|
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;
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
if (lua.IsOfType(1, "Rect"))
|
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))
|
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
|
// 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),
|
PlacementNew(instance, lua.CheckField<double>("x", 1),
|
||||||
lua.CheckField<double>("y", 1),
|
lua.CheckField<double>("y", 1),
|
||||||
lua.CheckField<double>("width", 1),
|
lua.CheckField<double>("width", 1),
|
||||||
lua.CheckField<double>("height", 1));
|
lua.CheckField<double>("height", 1));
|
||||||
}
|
}
|
||||||
else if (lua.IsOfType(1, "Vector2"))
|
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
|
else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -394,9 +394,9 @@ namespace Ndk
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
if (lua.IsOfType(1, Nz::LuaType_Number) && lua.IsOfType(2, Nz::LuaType_Number))
|
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"))
|
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
|
else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -516,22 +516,22 @@ namespace Ndk
|
||||||
});
|
});
|
||||||
|
|
||||||
/*********************************** Nz::Quaternion **********************************/
|
/*********************************** 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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||||
|
|
||||||
switch (argCount)
|
switch (argCount)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
Nz::PlacementNew(quaternion, Nz::Quaterniond::Zero());
|
Nz::PlacementNew(instance, Nz::Quaterniond::Zero());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
if (lua.IsOfType(1, "EulerAngles"))
|
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"))
|
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
|
else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -539,11 +539,11 @@ namespace Ndk
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2:
|
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;
|
return true;
|
||||||
|
|
||||||
case 4:
|
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;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Ndk
|
||||||
abstractSocket.BindMethod("QueryAvailableBytes", &Nz::AbstractSocket::QueryAvailableBytes);
|
abstractSocket.BindMethod("QueryAvailableBytes", &Nz::AbstractSocket::QueryAvailableBytes);
|
||||||
|
|
||||||
/*********************************** Nz::IpAddress **********************************/
|
/*********************************** 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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 9U);
|
||||||
|
|
||||||
|
|
@ -29,11 +29,11 @@ namespace Ndk
|
||||||
switch (argCount)
|
switch (argCount)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
Nz::PlacementNew(address);
|
Nz::PlacementNew(instance);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
Nz::PlacementNew(address, lua.CheckString(argIndex));
|
Nz::PlacementNew(instance, lua.CheckString(argIndex));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
|
|
@ -45,7 +45,7 @@ namespace Ndk
|
||||||
Nz::UInt8 d = lua.Check<Nz::UInt8>(&argIndex);
|
Nz::UInt8 d = lua.Check<Nz::UInt8>(&argIndex);
|
||||||
Nz::UInt16 port = lua.Check<Nz::UInt16>(&argIndex, 0);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ namespace Ndk
|
||||||
Nz::UInt16 h = lua.Check<Nz::UInt16>(&argIndex);
|
Nz::UInt16 h = lua.Check<Nz::UInt16>(&argIndex);
|
||||||
Nz::UInt16 port = lua.Check<Nz::UInt16>(&argIndex, 0);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -199,7 +199,7 @@ namespace Ndk
|
||||||
instance.PushField("Unknown", Nz::ResolveError_Unknown);
|
instance.PushField("Unknown", Nz::ResolveError_Unknown);
|
||||||
}
|
}
|
||||||
instance.SetGlobal("ResolveError");
|
instance.SetGlobal("ResolveError");
|
||||||
|
|
||||||
// Nz::SocketError
|
// Nz::SocketError
|
||||||
static_assert(Nz::SocketError_Max + 1 == 15, "Nz::ResolveError has been updated but change was not reflected to Lua binding");
|
static_assert(Nz::SocketError_Max + 1 == 15, "Nz::ResolveError has been updated but change was not reflected to Lua binding");
|
||||||
instance.PushTable(0, 15);
|
instance.PushTable(0, 15);
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,14 @@ namespace Ndk
|
||||||
void LuaBinding::BindRenderer()
|
void LuaBinding::BindRenderer()
|
||||||
{
|
{
|
||||||
/*********************************** Nz::Texture ***********************************/
|
/*********************************** 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;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Ndk
|
||||||
texture.BindMethod("Destroy", &Nz::Texture::Destroy);
|
texture.BindMethod("Destroy", &Nz::Texture::Destroy);
|
||||||
|
|
||||||
//texture.BindMethod("Download", &Nz::Texture::Download);
|
//texture.BindMethod("Download", &Nz::Texture::Download);
|
||||||
|
|
||||||
texture.BindMethod("EnableMipmapping", &Nz::Texture::EnableMipmapping);
|
texture.BindMethod("EnableMipmapping", &Nz::Texture::EnableMipmapping);
|
||||||
texture.BindMethod("EnsureMipmapsUpdate", &Nz::Texture::EnsureMipmapsUpdate);
|
texture.BindMethod("EnsureMipmapsUpdate", &Nz::Texture::EnsureMipmapsUpdate);
|
||||||
texture.BindMethod("HasMipmaps", &Nz::Texture::HasMipmaps);
|
texture.BindMethod("HasMipmaps", &Nz::Texture::HasMipmaps);
|
||||||
|
|
@ -73,4 +73,4 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
texture.Register(instance);
|
texture.Register(instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ namespace Ndk
|
||||||
application.BindMethod("IsFPSCounterEnabled", &Application::IsFPSCounterEnabled);
|
application.BindMethod("IsFPSCounterEnabled", &Application::IsFPSCounterEnabled);
|
||||||
#endif
|
#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;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ namespace Ndk
|
||||||
console.BindMethod("SetCharacterSize", &Console::SetCharacterSize);
|
console.BindMethod("SetCharacterSize", &Console::SetCharacterSize);
|
||||||
console.BindMethod("SetSize", &Console::SetSize);
|
console.BindMethod("SetSize", &Console::SetSize);
|
||||||
console.BindMethod("SetTextFont", &Console::SetTextFont);
|
console.BindMethod("SetTextFont", &Console::SetTextFont);
|
||||||
|
|
||||||
console.BindMethod("Show", &Console::Show, true);
|
console.BindMethod("Show", &Console::Show, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -139,7 +139,7 @@ namespace Ndk
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
/*********************************** Ndk::GraphicsComponent **********************************/
|
/*********************************** 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);
|
void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
|
||||||
|
|
@ -153,7 +153,7 @@ namespace Ndk
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
int argIndex = 2;
|
int argIndex = 2;
|
||||||
gfxComponent->Attach(lua.Check<Nz::InstancedRenderableRef>(&argIndex));
|
instance->Attach(lua.Check<Nz::InstancedRenderableRef>(&argIndex));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -166,13 +166,13 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
int renderOrder = lua.Check<int>(&argIndex);
|
int renderOrder = lua.Check<int>(&argIndex);
|
||||||
|
|
||||||
gfxComponent->Attach(renderable, renderOrder);
|
instance->Attach(renderable, renderOrder);
|
||||||
}
|
}
|
||||||
else if (lua.IsOfType(argIndex, "Matrix4"))
|
else if (lua.IsOfType(argIndex, "Matrix4"))
|
||||||
{
|
{
|
||||||
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&argIndex);
|
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&argIndex);
|
||||||
|
|
||||||
gfxComponent->Attach(renderable, localMatrix);
|
instance->Attach(renderable, localMatrix);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -187,7 +187,7 @@ namespace Ndk
|
||||||
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&argIndex);
|
Nz::Matrix4f localMatrix = lua.Check<Nz::Matrix4f>(&argIndex);
|
||||||
int renderOrder = lua.Check<int>(&argIndex);
|
int renderOrder = lua.Check<int>(&argIndex);
|
||||||
|
|
||||||
gfxComponent->Attach(renderable, localMatrix, renderOrder);
|
instance->Attach(renderable, localMatrix, renderOrder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,20 +25,20 @@ namespace Ndk
|
||||||
abstractImage.BindMethod("IsCompressed", &Nz::AbstractImage::IsCompressed);
|
abstractImage.BindMethod("IsCompressed", &Nz::AbstractImage::IsCompressed);
|
||||||
abstractImage.BindMethod("IsCubemap", &Nz::AbstractImage::IsCubemap);
|
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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
|
||||||
switch (argCount)
|
switch (argCount)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return lua.Push(abstractImage->GetMemoryUsage());
|
return lua.Push(instance->GetMemoryUsage());
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
int argIndex = 2;
|
int argIndex = 2;
|
||||||
Nz::UInt8 level(lua.Check<Nz::UInt8>(&argIndex));
|
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;
|
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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 6U);
|
||||||
int argIndex = 2;
|
int argIndex = 2;
|
||||||
|
|
@ -62,7 +62,7 @@ namespace Ndk
|
||||||
Nz::UInt8 level = lua.Check<Nz::UInt8>(&argIndex, 0);
|
Nz::UInt8 level = lua.Check<Nz::UInt8>(&argIndex, 0);
|
||||||
|
|
||||||
///TODO: Buffer checks (Nz::ByteBufferView ?)
|
///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
|
/* Disabled until Box and Rect have been ported
|
||||||
else if (lua.IsOfType(2, "Box"))
|
else if (lua.IsOfType(2, "Box"))
|
||||||
|
|
@ -93,9 +93,9 @@ namespace Ndk
|
||||||
});
|
});
|
||||||
|
|
||||||
/*********************************** Nz::Font **********************************/
|
/*********************************** 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;
|
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("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("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;
|
int argIndex = 2;
|
||||||
|
|
||||||
Nz::Vector3f offset = lua.Check<Nz::Vector3f>(&argIndex);
|
Nz::Vector3f offset = lua.Check<Nz::Vector3f>(&argIndex);
|
||||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||||
node.Move(offset, coordSys);
|
instance.Move(offset, coordSys);
|
||||||
|
|
||||||
return 0;
|
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;
|
int argIndex = 2;
|
||||||
|
|
||||||
Nz::Quaternionf rotation = lua.Check<Nz::Quaternionf>(&argIndex);
|
Nz::Quaternionf rotation = lua.Check<Nz::Quaternionf>(&argIndex);
|
||||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||||
node.Rotate(rotation, coordSys);
|
instance.Rotate(rotation, coordSys);
|
||||||
|
|
||||||
return 0;
|
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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||||
|
|
||||||
|
|
@ -231,15 +231,15 @@ namespace Ndk
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||||
node.Scale(lua.Check<float>(&argIndex));
|
instance.Scale(lua.Check<float>(&argIndex));
|
||||||
else
|
else
|
||||||
node.Scale(lua.Check<Nz::Vector3f>(&argIndex));
|
instance.Scale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
node.Scale(lua.Check<Nz::Vector3f>(&argIndex));
|
instance.Scale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,7 +247,7 @@ namespace Ndk
|
||||||
return 0;
|
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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||||
|
|
||||||
|
|
@ -261,10 +261,10 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
float scale = lua.Check<float>(&argIndex);
|
float scale = lua.Check<float>(&argIndex);
|
||||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||||
node.SetScale(scale, coordSys);
|
instance.SetScale(scale, coordSys);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
node.SetScale(lua.Check<Nz::Vector3f>(&argIndex));
|
instance.SetScale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -275,7 +275,7 @@ namespace Ndk
|
||||||
Nz::Vector3f scale = lua.Check<Nz::Vector3f>(&argIndex);
|
Nz::Vector3f scale = lua.Check<Nz::Vector3f>(&argIndex);
|
||||||
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
Nz::CoordSys coordSys = lua.Check<Nz::CoordSys>(&argIndex, Nz::CoordSys_Local);
|
||||||
|
|
||||||
node.SetScale(scale, coordSys);
|
instance.SetScale(scale, coordSys);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -284,7 +284,7 @@ namespace Ndk
|
||||||
return 0;
|
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);
|
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
|
||||||
|
|
||||||
|
|
@ -294,16 +294,16 @@ namespace Ndk
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
if (lua.IsOfType(argIndex, Nz::LuaType_Number))
|
||||||
node.SetInitialScale(lua.Check<float>(&argIndex));
|
instance.SetInitialScale(lua.Check<float>(&argIndex));
|
||||||
else
|
else
|
||||||
node.SetInitialScale(lua.Check<Nz::Vector2f>(&argIndex));
|
instance.SetInitialScale(lua.Check<Nz::Vector2f>(&argIndex));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
node.SetInitialScale(lua.Check<Nz::Vector3f>(&argIndex));
|
instance.SetInitialScale(lua.Check<Nz::Vector3f>(&argIndex));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,4 +324,4 @@ namespace Ndk
|
||||||
font.Register(instance);
|
font.Register(instance);
|
||||||
node.Register(instance);
|
node.Register(instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Nz
|
||||||
m_isometricModeEnabled(false)
|
m_isometricModeEnabled(false)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_tiles.size() != 0U, "Invalid map size");
|
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");
|
NazaraAssert(m_layers.size() != 0U, "Invalid material count");
|
||||||
|
|
||||||
for (Layer& layer : m_layers)
|
for (Layer& layer : m_layers)
|
||||||
|
|
@ -175,7 +175,7 @@ namespace Nz
|
||||||
* \param color The multiplicative color applied to the tile
|
* \param color The multiplicative color applied to the tile
|
||||||
* \param materialIndex The material which will be used for rendering this 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.
|
* as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
|
||||||
*
|
*
|
||||||
* \see EnableTiles
|
* \see EnableTiles
|
||||||
|
|
@ -253,7 +253,7 @@ namespace Nz
|
||||||
Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height);
|
Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height);
|
||||||
EnableTiles(unnormalizedCoords, color, materialIndex);
|
EnableTiles(unnormalizedCoords, color, materialIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations
|
* \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
|
* \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_layers = tileMap.m_layers;
|
||||||
m_mapSize = TileMap.m_mapSize;
|
m_mapSize = tileMap.m_mapSize;
|
||||||
m_tiles = TileMap.m_tiles;
|
m_tiles = tileMap.m_tiles;
|
||||||
m_tileSize = TileMap.m_tileSize;
|
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
|
// We do not copy final vertices because it's highly probable that our parameters are modified and they must be regenerated
|
||||||
InvalidateBoundingVolume();
|
InvalidateBoundingVolume();
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ namespace Nz
|
||||||
|
|
||||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object, std::size_t /*argumentCount*/) -> int
|
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);
|
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
|
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);
|
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
|
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);
|
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
|
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);
|
return handler.Invoke(lua, object, func);
|
||||||
});
|
});
|
||||||
|
|
@ -203,7 +203,7 @@ namespace Nz
|
||||||
|
|
||||||
BindStaticMethod(name, [func, handler] (LuaInstance& lua) -> int
|
BindStaticMethod(name, [func, handler] (LuaInstance& lua) -> int
|
||||||
{
|
{
|
||||||
handler.ProcessArgs(lua);
|
handler.ProcessArguments(lua);
|
||||||
|
|
||||||
return handler.Invoke(lua, func);
|
return handler.Invoke(lua, func);
|
||||||
});
|
});
|
||||||
|
|
@ -335,7 +335,7 @@ namespace Nz
|
||||||
NazaraWarning("Class \"" + m_info->name + "\" already registred in this instance");
|
NazaraWarning("Class \"" + m_info->name + "\" already registred in this instance");
|
||||||
{
|
{
|
||||||
SetupFinalizer(lua);
|
SetupFinalizer(lua);
|
||||||
|
|
||||||
if (m_info->getter || !m_info->parentGetters.empty())
|
if (m_info->getter || !m_info->parentGetters.empty())
|
||||||
SetupGetter(lua, GetterProxy);
|
SetupGetter(lua, GetterProxy);
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ namespace Nz
|
||||||
m_memoryUsage = instance.m_memoryUsage;
|
m_memoryUsage = instance.m_memoryUsage;
|
||||||
m_state = instance.m_state;
|
m_state = instance.m_state;
|
||||||
m_timeLimit = instance.m_timeLimit;
|
m_timeLimit = instance.m_timeLimit;
|
||||||
|
|
||||||
instance.m_state = nullptr;
|
instance.m_state = nullptr;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
|
@ -320,7 +320,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessArgs(const LuaInstance& instance) const
|
void ProcessArguments(const LuaInstance& instance) const
|
||||||
{
|
{
|
||||||
m_index = 1;
|
m_index = 1;
|
||||||
ProcessArgs<0, Args...>(instance);
|
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
|
m_index = 2; //< 1 being the instance
|
||||||
ProcessArgs<0, Args...>(instance);
|
ProcessArgs<0, Args...>(instance);
|
||||||
|
|
@ -714,7 +714,7 @@ namespace Nz
|
||||||
|
|
||||||
PushFunction([func, handler] (LuaInstance& lua) -> int
|
PushFunction([func, handler] (LuaInstance& lua) -> int
|
||||||
{
|
{
|
||||||
handler.ProcessArgs(lua);
|
handler.ProcessArguments(lua);
|
||||||
|
|
||||||
return handler.Invoke(lua, func);
|
return handler.Invoke(lua, func);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -792,7 +792,7 @@ namespace Nz
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool Matrix4<T>::IsAffine() const
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -911,9 +911,9 @@ namespace Nz
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool Vector3<T>::operator<(const Vector3& vec) const
|
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;
|
return z < vec.z;
|
||||||
else
|
else
|
||||||
return y < vec.y;
|
return y < vec.y;
|
||||||
|
|
@ -931,10 +931,10 @@ namespace Nz
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool Vector3<T>::operator<=(const Vector3& vec) const
|
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;
|
return NumberEquals(z, vec.z) || z < vec.z;
|
||||||
else
|
else
|
||||||
return y < vec.y;
|
return y < vec.y;
|
||||||
}
|
}
|
||||||
|
|
@ -1371,7 +1371,7 @@ namespace std
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef F
|
#undef F
|
||||||
|
|
||||||
#include <Nazara/Core/DebugOff.hpp>
|
#include <Nazara/Core/DebugOff.hpp>
|
||||||
|
|
|
||||||
|
|
@ -843,11 +843,11 @@ namespace Nz
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool Vector4<T>::operator<(const Vector4& vec) const
|
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;
|
return w < vec.w;
|
||||||
else
|
else
|
||||||
return z < vec.z;
|
return z < vec.z;
|
||||||
|
|
@ -869,12 +869,12 @@ namespace Nz
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool Vector4<T>::operator<=(const Vector4& vec) const
|
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;
|
return NumberEquals(w, vec.w) || w < vec.w;
|
||||||
else
|
else
|
||||||
return z < vec.z;
|
return z < vec.z;
|
||||||
}
|
}
|
||||||
|
|
@ -1144,7 +1144,7 @@ namespace std
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef F
|
#undef F
|
||||||
|
|
||||||
#include <Nazara/Core/DebugOff.hpp>
|
#include <Nazara/Core/DebugOff.hpp>
|
||||||
|
|
|
||||||
|
|
@ -380,7 +380,7 @@ namespace std
|
||||||
|
|
||||||
// This is SDBM adapted for IP addresses, tested to generate the least collisions possible
|
// This is SDBM adapted for IP addresses, tested to generate the least collisions possible
|
||||||
// (It doesn't mean it cannot be improved though)
|
// (It doesn't mean it cannot be improved though)
|
||||||
std::size_t hash = 0;
|
std::size_t h = 0;
|
||||||
switch (ip.GetProtocol())
|
switch (ip.GetProtocol())
|
||||||
{
|
{
|
||||||
case Nz::NetProtocol_Any:
|
case Nz::NetProtocol_Any:
|
||||||
|
|
@ -389,20 +389,20 @@ namespace std
|
||||||
|
|
||||||
case Nz::NetProtocol_IPv4:
|
case Nz::NetProtocol_IPv4:
|
||||||
{
|
{
|
||||||
hash = ip.ToUInt32() + (hash << 6) + (hash << 16) - hash;
|
h = ip.ToUInt32() + (h << 6) + (h << 16) - h;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Nz::NetProtocol_IPv6:
|
case Nz::NetProtocol_IPv6:
|
||||||
{
|
{
|
||||||
Nz::IpAddress::IPv6 v6 = ip.ToIPv6();
|
Nz::IpAddress::IPv6 v6 = ip.ToIPv6();
|
||||||
for (std::size_t i = 0; i < v6.size(); i++)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ip.GetPort() + (hash << 6) + (hash << 16) - hash;
|
return ip.GetPort() + (h << 6) + (h << 16) - h;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@
|
||||||
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
|
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
|
||||||
|
|
||||||
// On force la valeur de MANAGE_MEMORY en mode debug
|
// On force la valeur de MANAGE_MEMORY en mode debug
|
||||||
#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS_MANAGE_MEMORY
|
#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS2D_MANAGE_MEMORY
|
||||||
#undef NAZARA_PHYSICS_MANAGE_MEMORY
|
#undef NAZARA_PHYSICS2D_MANAGE_MEMORY
|
||||||
#define NAZARA_PHYSICS3D_MANAGE_MEMORY 0
|
#define NAZARA_PHYSICS2D_MANAGE_MEMORY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // NAZARA_CONFIG_CHECK_PHYSICS_HPP
|
#endif // NAZARA_CONFIG_CHECK_PHYSICS_HPP
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// This file is part of the "Nazara Engine - Physics 2D module"
|
// This file is part of the "Nazara Engine - Physics 2D module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Physics3D/Config.hpp>
|
#include <Nazara/Physics2D/Config.hpp>
|
||||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
#if NAZARA_PHYSICS2D_MANAGE_MEMORY
|
||||||
#include <Nazara/Core/Debug/NewRedefinition.hpp>
|
#include <Nazara/Core/Debug/NewRedefinition.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
|
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
|
||||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
#if NAZARA_PHYSICS2D_MANAGE_MEMORY
|
||||||
#undef delete
|
#undef delete
|
||||||
#undef new
|
#undef new
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
|
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
|
||||||
|
|
||||||
// On force la valeur de MANAGE_MEMORY en mode debug
|
// On force la valeur de MANAGE_MEMORY en mode debug
|
||||||
#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS_MANAGE_MEMORY
|
#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS3D_MANAGE_MEMORY
|
||||||
#undef NAZARA_PHYSICS_MANAGE_MEMORY
|
#undef NAZARA_PHYSICS3D_MANAGE_MEMORY
|
||||||
#define NAZARA_PHYSICS3D_MANAGE_MEMORY 0
|
#define NAZARA_PHYSICS3D_MANAGE_MEMORY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Physics3D/Config.hpp>
|
#include <Nazara/Physics3D/Config.hpp>
|
||||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
#if NAZARA_PHYSICS3D_MANAGE_MEMORY
|
||||||
#include <Nazara/Core/Debug/NewRedefinition.hpp>
|
#include <Nazara/Core/Debug/NewRedefinition.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
|
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
|
||||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
#if NAZARA_PHYSICS3D_MANAGE_MEMORY
|
||||||
#undef delete
|
#undef delete
|
||||||
#undef new
|
#undef new
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,6 @@ namespace Nz
|
||||||
|
|
||||||
ColliderType3D_Max = ColliderType3D_Tree
|
ColliderType3D_Max = ColliderType3D_Tree
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif // NAZARA_ENUMS_PHYSICS3D_HPP
|
#endif // NAZARA_ENUMS_PHYSICS3D_HPP
|
||||||
|
|
|
||||||
|
|
@ -906,5 +906,5 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ namespace Nz
|
||||||
void InstancedRenderable::UpdateData(InstanceData* instanceData) const
|
void InstancedRenderable::UpdateData(InstanceData* instanceData) const
|
||||||
{
|
{
|
||||||
NazaraAssert(instanceData, "Invalid instance data");
|
NazaraAssert(instanceData, "Invalid instance data");
|
||||||
|
NazaraUnused(instanceData);
|
||||||
}
|
}
|
||||||
|
|
||||||
InstancedRenderableLibrary::LibraryMap InstancedRenderable::s_library;
|
InstancedRenderableLibrary::LibraryMap InstancedRenderable::s_library;
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ namespace Nz
|
||||||
if (!m_buffer)
|
if (!m_buffer)
|
||||||
m_buffer = std::make_unique<ByteArray>();
|
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.SetBuffer(m_buffer.get(), openMode);
|
||||||
m_memoryStream.SetCursorPos(cursorPos);
|
m_memoryStream.SetCursorPos(cursorPos);
|
||||||
|
|
|
||||||
|
|
@ -385,7 +385,7 @@ namespace Nz
|
||||||
* \remark Produces a NazaraError because it is a special stream
|
* \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");
|
NazaraError("SetCursorPos() cannot be used on sequential streams");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -437,6 +437,10 @@ namespace Nz
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
#else
|
#else
|
||||||
|
NazaraUnused(fdarray);
|
||||||
|
NazaraUnused(nfds);
|
||||||
|
NazaraUnused(timeout);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = SocketError_NotSupported;
|
*error = SocketError_NotSupported;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
// This file is part of the "Nazara Engine - Physics 2D module"
|
// This file is part of the "Nazara Engine - Physics 2D module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Physics3D/Config.hpp>
|
#include <Nazara/Physics2D/Config.hpp>
|
||||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
#if NAZARA_PHYSICS2D_MANAGE_MEMORY
|
||||||
|
|
||||||
#include <Nazara/Core/MemoryManager.hpp>
|
#include <Nazara/Core/MemoryManager.hpp>
|
||||||
#include <new> // Nécessaire ?
|
#include <new> // Nécessaire ?
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Physics3D/Config.hpp>
|
#include <Nazara/Physics3D/Config.hpp>
|
||||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
#if NAZARA_PHYSICS3D_MANAGE_MEMORY
|
||||||
|
|
||||||
#include <Nazara/Core/MemoryManager.hpp>
|
#include <Nazara/Core/MemoryManager.hpp>
|
||||||
#include <new> // Nécessaire ?
|
#include <new> // Nécessaire ?
|
||||||
|
|
|
||||||
|
|
@ -795,6 +795,7 @@ namespace Nz
|
||||||
NazaraAssert(attachmentIndex < m_impl->attachments.size(), "Invalid attachment index");
|
NazaraAssert(attachmentIndex < m_impl->attachments.size(), "Invalid attachment index");
|
||||||
NazaraAssert(!m_impl->attachments[attachmentIndex].isBuffer, "Invalid attachment state");
|
NazaraAssert(!m_impl->attachments[attachmentIndex].isBuffer, "Invalid attachment state");
|
||||||
NazaraUnused(texture);
|
NazaraUnused(texture);
|
||||||
|
NazaraUnused(attachmentIndex);
|
||||||
|
|
||||||
InvalidateTargets();
|
InvalidateTargets();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -331,19 +331,19 @@ namespace Nz
|
||||||
Emit(mat.specular.b / 255.f);
|
Emit(mat.specular.b / 255.f);
|
||||||
EmitLine();
|
EmitLine();
|
||||||
|
|
||||||
if (mat.alpha != 1.f)
|
if (!NumberEquals(mat.alpha, 1.f))
|
||||||
{
|
{
|
||||||
Emit("d ");
|
Emit("d ");
|
||||||
EmitLine(mat.alpha);
|
EmitLine(mat.alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mat.refractionIndex != 1.f)
|
if (!NumberEquals(mat.refractionIndex, 1.f))
|
||||||
{
|
{
|
||||||
Emit("ni ");
|
Emit("ni ");
|
||||||
EmitLine(mat.refractionIndex);
|
EmitLine(mat.refractionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mat.shininess != 1.f)
|
if (!NumberEquals(mat.shininess, 1.f))
|
||||||
{
|
{
|
||||||
Emit("ns ");
|
Emit("ns ");
|
||||||
EmitLine(mat.shininess);
|
EmitLine(mat.shininess);
|
||||||
|
|
|
||||||
|
|
@ -128,17 +128,17 @@ namespace Nz
|
||||||
UInt32 faceReserve = 0;
|
UInt32 faceReserve = 0;
|
||||||
UInt32 vertexReserve = 0;
|
UInt32 vertexReserve = 0;
|
||||||
unsigned int matCount = 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& map = meshesByName[mesh];
|
||||||
auto it = map.find(matName);
|
auto it = map.find(mat);
|
||||||
if (it == map.end())
|
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);
|
meshData.faces.reserve(faceReserve);
|
||||||
mesh.vertices.reserve(vertexReserve);
|
meshData.vertices.reserve(vertexReserve);
|
||||||
faceReserve = 0;
|
faceReserve = 0;
|
||||||
vertexReserve = 0;
|
vertexReserve = 0;
|
||||||
|
|
||||||
|
|
@ -550,19 +550,19 @@ namespace Nz
|
||||||
EmitLine(pair.second.size());
|
EmitLine(pair.second.size());
|
||||||
EmitLine();
|
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 ");
|
Emit("g ");
|
||||||
EmitLine(mesh.name);
|
EmitLine(mesh.name);
|
||||||
EmitLine();
|
EmitLine();
|
||||||
|
|
||||||
Emit("# face count: ");
|
Emit("# face count: ");
|
||||||
EmitLine(mesh.faces.size());
|
EmitLine(mesh.faces.size());
|
||||||
Emit("# vertex count: ");
|
Emit("# vertex count: ");
|
||||||
EmitLine(mesh.vertices.size());
|
EmitLine(mesh.vertices.size());
|
||||||
|
|
||||||
for (const Face& face : mesh.faces)
|
for (const Face& face : mesh.faces)
|
||||||
{
|
{
|
||||||
Emit('f');
|
Emit('f');
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ namespace Nz
|
||||||
Font* SimpleTextDrawer::GetFont(std::size_t index) const
|
Font* SimpleTextDrawer::GetFont(std::size_t index) const
|
||||||
{
|
{
|
||||||
NazaraAssert(index == 0, "Font index out of range");
|
NazaraAssert(index == 0, "Font index out of range");
|
||||||
|
NazaraUnused(index);
|
||||||
|
|
||||||
return m_font;
|
return m_font;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
SoftwareBuffer::SoftwareBuffer(Buffer* /*parent*/, BufferType type)
|
SoftwareBuffer::SoftwareBuffer(Buffer* /*parent*/, BufferType /*type*/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue