Merge branch 'master' into vulkan
Former-commit-id: fd9f2f119e959847d4d9eabece7b678243b26bde
This commit is contained in:
commit
1742fa9457
|
|
@ -24,6 +24,8 @@ namespace Ndk
|
|||
LuaAPI() = delete;
|
||||
~LuaAPI() = delete;
|
||||
|
||||
static inline LuaBinding* GetBinding();
|
||||
|
||||
static bool Initialize();
|
||||
|
||||
static void RegisterClasses(Nz::LuaInstance& instance);
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@
|
|||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Lua/LuaInstance.hpp>
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
#include <Nazara/Utility/Font.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <NDK/Application.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
|
|
@ -21,6 +24,14 @@
|
|||
#include <NDK/Console.hpp>
|
||||
#endif
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
inline LuaBinding* LuaAPI::GetBinding()
|
||||
{
|
||||
return s_binding;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Color* color, TypeTag<Color>)
|
||||
|
|
@ -46,9 +57,9 @@ namespace Nz
|
|||
default:
|
||||
{
|
||||
if (instance.IsOfType(index, "EulerAngles"))
|
||||
angles->Set(*(*static_cast<EulerAnglesd**>(instance.ToUserdata(index))));
|
||||
angles->Set(*static_cast<EulerAnglesd*>(instance.ToUserdata(index)));
|
||||
else
|
||||
angles->Set(*(*static_cast<Quaterniond**>(instance.CheckUserdata(index, "Quaternion"))));
|
||||
angles->Set(*static_cast<Quaterniond*>(instance.CheckUserdata(index, "Quaternion")));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -66,7 +77,7 @@ namespace Nz
|
|||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontRef* fontRef, TypeTag<FontRef>)
|
||||
{
|
||||
*fontRef = *(*static_cast<FontRef**>(instance.CheckUserdata(index, "Font")));
|
||||
*fontRef = *static_cast<FontRef*>(instance.CheckUserdata(index, "Font"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -91,6 +102,36 @@ namespace Nz
|
|||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectd* rect, TypeTag<Rectd>)
|
||||
{
|
||||
instance.CheckType(index, LuaType_Table);
|
||||
|
||||
rect->x = instance.CheckField<double>("x", index);
|
||||
rect->y = instance.CheckField<double>("y", index);
|
||||
rect->width = instance.CheckField<double>("width", index);
|
||||
rect->height = instance.CheckField<double>("height", index);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectf* rect, TypeTag<Rectf>)
|
||||
{
|
||||
Rectd rectDouble;
|
||||
unsigned int ret = LuaImplQueryArg(instance, index, &rectDouble, TypeTag<Rectd>());
|
||||
|
||||
rect->Set(rectDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectui* rect, TypeTag<Rectui>)
|
||||
{
|
||||
Rectd rectDouble;
|
||||
unsigned int ret = LuaImplQueryArg(instance, index, &rectDouble, TypeTag<Rectd>());
|
||||
|
||||
rect->Set(rectDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Quaterniond* quat, TypeTag<Quaterniond>)
|
||||
{
|
||||
switch (instance.GetType(index))
|
||||
|
|
@ -102,9 +143,9 @@ namespace Nz
|
|||
default:
|
||||
{
|
||||
if (instance.IsOfType(index, "EulerAngles"))
|
||||
quat->Set(*(*static_cast<EulerAnglesd**>(instance.ToUserdata(index))));
|
||||
quat->Set(*static_cast<EulerAnglesd*>(instance.ToUserdata(index)));
|
||||
else
|
||||
quat->Set(*(*static_cast<Quaterniond**>(instance.CheckUserdata(index, "Quaternion"))));
|
||||
quat->Set(*static_cast<Quaterniond*>(instance.CheckUserdata(index, "Quaternion")));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -150,7 +191,7 @@ namespace Nz
|
|||
return 1;
|
||||
|
||||
default:
|
||||
vec->Set(*(*static_cast<Vector2d**>(instance.CheckUserdata(index, "Vector2"))));
|
||||
vec->Set(*static_cast<Vector2d*>(instance.CheckUserdata(index, "Vector2")));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -189,7 +230,7 @@ namespace Nz
|
|||
return 1;
|
||||
|
||||
default:
|
||||
vec->Set(*(*static_cast<Vector3d**>(instance.CheckUserdata(index, "Vector3"))));
|
||||
vec->Set(*static_cast<Vector3d*>(instance.CheckUserdata(index, "Vector3")));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -212,13 +253,27 @@ namespace Nz
|
|||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::EntityHandle* handle, TypeTag<Ndk::EntityHandle>)
|
||||
{
|
||||
*handle = std::move(*static_cast<Ndk::EntityHandle*>(instance.CheckUserdata(index, "Entity")));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::WorldHandle* handle, TypeTag<Ndk::WorldHandle>)
|
||||
{
|
||||
*handle = std::move(*static_cast<Ndk::WorldHandle*>(instance.CheckUserdata(index, "World")));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, InstancedRenderableRef* renderable, TypeTag<InstancedRenderableRef>)
|
||||
{
|
||||
if (instance.IsOfType(index, "InstancedRenderable"))
|
||||
*renderable = *(*static_cast<InstancedRenderableRef**>(instance.CheckUserdata(index, "InstancedRenderable")));
|
||||
*renderable = *static_cast<InstancedRenderableRef*>(instance.CheckUserdata(index, "InstancedRenderable"));
|
||||
else
|
||||
*renderable = *(*static_cast<InstancedRenderableRef**>(instance.CheckUserdata(index, "Model")));
|
||||
*renderable = *static_cast<InstancedRenderableRef*>(instance.CheckUserdata(index, "Model"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -269,25 +324,25 @@ namespace Nz
|
|||
|
||||
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesd val, TypeTag<EulerAnglesd>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesd&& val, TypeTag<EulerAnglesd>)
|
||||
{
|
||||
instance.PushInstance<EulerAnglesd>("EulerAngles", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesf val, TypeTag<EulerAnglesf>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesf&& val, TypeTag<EulerAnglesf>)
|
||||
{
|
||||
instance.PushInstance<EulerAnglesd>("EulerAngles", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, FontRef val, TypeTag<FontRef>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, FontRef&& val, TypeTag<FontRef>)
|
||||
{
|
||||
instance.PushInstance<FontRef>("Font", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Font::SizeInfo val, TypeTag<Font::SizeInfo>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Font::SizeInfo&& val, TypeTag<Font::SizeInfo>)
|
||||
{
|
||||
instance.PushTable();
|
||||
instance.PushField("LineHeight", val.lineHeight);
|
||||
|
|
@ -298,55 +353,73 @@ namespace Nz
|
|||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Quaterniond val, TypeTag<Quaterniond>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Quaterniond&& val, TypeTag<Quaterniond>)
|
||||
{
|
||||
instance.PushInstance<Quaterniond>("Quaternion", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Quaternionf val, TypeTag<Quaternionf>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Quaternionf&& val, TypeTag<Quaternionf>)
|
||||
{
|
||||
instance.PushInstance<Quaterniond>("Quaternion", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, IpAddress val, TypeTag<IpAddress>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, IpAddress&& val, TypeTag<IpAddress>)
|
||||
{
|
||||
instance.PushInstance<IpAddress>("IpAddress", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2d val, TypeTag<Vector2d>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Rectd&& val, TypeTag<Rectf>)
|
||||
{
|
||||
instance.PushInstance<Rectd>("Rect", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Rectf&& val, TypeTag<Rectf>)
|
||||
{
|
||||
instance.PushInstance<Rectd>("Rect", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Rectui&& val, TypeTag<Rectui>)
|
||||
{
|
||||
instance.PushInstance<Rectd>("Rect", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2d&& val, TypeTag<Vector2d>)
|
||||
{
|
||||
instance.PushInstance<Vector2d>("Vector2", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2f val, TypeTag<Vector2f>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2f&& val, TypeTag<Vector2f>)
|
||||
{
|
||||
instance.PushInstance<Vector2d>("Vector2", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2ui val, TypeTag<Vector2ui>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2ui&& val, TypeTag<Vector2ui>)
|
||||
{
|
||||
instance.PushInstance<Vector2d>("Vector2", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3d val, TypeTag<Vector3d>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3d&& val, TypeTag<Vector3d>)
|
||||
{
|
||||
instance.PushInstance<Vector3d>("Vector3", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3f val, TypeTag<Vector3f>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3f&& val, TypeTag<Vector3f>)
|
||||
{
|
||||
instance.PushInstance<Vector3d>("Vector3", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3ui val, TypeTag<Vector3ui>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3ui&& val, TypeTag<Vector3ui>)
|
||||
{
|
||||
instance.PushInstance<Vector3d>("Vector3", val);
|
||||
return 1;
|
||||
|
|
@ -364,19 +437,19 @@ namespace Nz
|
|||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::EntityHandle handle, TypeTag<Ndk::EntityHandle>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::EntityHandle&& handle, TypeTag<Ndk::EntityHandle>)
|
||||
{
|
||||
instance.PushInstance<Ndk::EntityHandle>("Entity", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::NodeComponentHandle handle, TypeTag<Ndk::NodeComponentHandle>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::NodeComponentHandle&& handle, TypeTag<Ndk::NodeComponentHandle>)
|
||||
{
|
||||
instance.PushInstance<Ndk::NodeComponentHandle>("NodeComponent", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::VelocityComponentHandle handle, TypeTag<Ndk::VelocityComponentHandle>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::VelocityComponentHandle&& handle, TypeTag<Ndk::VelocityComponentHandle>)
|
||||
{
|
||||
instance.PushInstance<Ndk::VelocityComponentHandle>("VelocityComponent", handle);
|
||||
return 1;
|
||||
|
|
@ -388,20 +461,20 @@ namespace Nz
|
|||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::WorldHandle handle, TypeTag<Ndk::WorldHandle>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::WorldHandle&& handle, TypeTag<Ndk::WorldHandle>)
|
||||
{
|
||||
instance.PushInstance<Ndk::WorldHandle>("World", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::ConsoleHandle handle, TypeTag<Ndk::ConsoleHandle>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::ConsoleHandle&& handle, TypeTag<Ndk::ConsoleHandle>)
|
||||
{
|
||||
instance.PushInstance<Ndk::ConsoleHandle>("Console", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::GraphicsComponentHandle handle, TypeTag<Ndk::GraphicsComponentHandle>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::GraphicsComponentHandle&& handle, TypeTag<Ndk::GraphicsComponentHandle>)
|
||||
{
|
||||
instance.PushInstance<Ndk::GraphicsComponentHandle>("GraphicsComponent", handle);
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ namespace Ndk
|
|||
// Math
|
||||
Nz::LuaClass<Nz::EulerAnglesd> eulerAnglesClass;
|
||||
Nz::LuaClass<Nz::Quaterniond> quaternionClass;
|
||||
Nz::LuaClass<Nz::Rectd> rectClass;
|
||||
Nz::LuaClass<Nz::Vector2d> vector2dClass;
|
||||
Nz::LuaClass<Nz::Vector3d> vector3dClass;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ namespace Ndk
|
|||
class State
|
||||
{
|
||||
public:
|
||||
State();
|
||||
~State();
|
||||
State() = default;
|
||||
~State() = default;
|
||||
|
||||
virtual void Enter(StateMachine& fsm) = 0;
|
||||
virtual void Leave(StateMachine& fsm) = 0;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace Ndk
|
|||
// Math
|
||||
eulerAnglesClass("EulerAngles"),
|
||||
quaternionClass("Quaternion"),
|
||||
rectClass("Rect"),
|
||||
vector2dClass("Vector2"),
|
||||
vector3dClass("Vector3"),
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// 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>
|
||||
|
||||
namespace Ndk
|
||||
|
|
@ -10,10 +11,7 @@ namespace Ndk
|
|||
/*********************************** Nz::Music **********************************/
|
||||
musicClass.Inherit(soundEmitter);
|
||||
|
||||
musicClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::Music*
|
||||
{
|
||||
return new Nz::Music;
|
||||
});
|
||||
musicClass.BindDefaultConstructor();
|
||||
|
||||
//musicClass.SetMethod("Create", &Nz::Music::Create);
|
||||
//musicClass.SetMethod("Destroy", &Nz::Music::Destroy);
|
||||
|
|
@ -51,10 +49,7 @@ namespace Ndk
|
|||
/*********************************** Nz::Sound **********************************/
|
||||
soundClass.Inherit(soundEmitter);
|
||||
|
||||
soundClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::Sound*
|
||||
{
|
||||
return new Nz::Sound;
|
||||
});
|
||||
soundClass.BindDefaultConstructor();
|
||||
|
||||
soundClass.BindMethod("GetBuffer", &Nz::Sound::GetBuffer);
|
||||
|
||||
|
|
@ -79,9 +74,10 @@ namespace Ndk
|
|||
});
|
||||
|
||||
/*********************************** Nz::SoundBuffer **********************************/
|
||||
soundBuffer.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::SoundBufferRef*
|
||||
soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance)
|
||||
{
|
||||
return new Nz::SoundBufferRef(new Nz::SoundBuffer);
|
||||
Nz::PlacementNew(instance, Nz::SoundBuffer::New());
|
||||
return true;
|
||||
});
|
||||
|
||||
soundBuffer.BindMethod("Destroy", &Nz::SoundBuffer::Destroy);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// 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>
|
||||
|
||||
namespace Ndk
|
||||
|
|
@ -8,10 +9,14 @@ namespace Ndk
|
|||
void LuaBinding::BindCore()
|
||||
{
|
||||
/*********************************** Nz::Clock **********************************/
|
||||
clockClass.SetConstructor([](Nz::LuaInstance& lua) -> Nz::Clock*
|
||||
clockClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* clock)
|
||||
{
|
||||
int argIndex = 1;
|
||||
return new Nz::Clock(lua.Check<Nz::Int64>(&argIndex, 0), lua.Check<bool>(&argIndex, false));
|
||||
Nz::Int64 startingValue = lua.Check<Nz::Int64>(&argIndex, 0);
|
||||
bool paused = lua.Check<bool>(&argIndex, false);
|
||||
|
||||
Nz::PlacementNew(clock, startingValue, paused);
|
||||
return true;
|
||||
});
|
||||
|
||||
clockClass.BindMethod("GetMicroseconds", &Nz::Clock::GetMicroseconds);
|
||||
|
|
@ -35,7 +40,7 @@ namespace Ndk
|
|||
});
|
||||
|
||||
/********************************* Nz::Directory ********************************/
|
||||
directoryClass.SetConstructor([](Nz::LuaInstance& lua) -> Nz::Directory*
|
||||
directoryClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Directory* directory)
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 1U);
|
||||
|
||||
|
|
@ -43,13 +48,15 @@ namespace Ndk
|
|||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
return new Nz::Directory;
|
||||
Nz::PlacementNew(directory);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
return new Nz::Directory(lua.Check<Nz::String>(&argIndex));
|
||||
Nz::PlacementNew(directory, lua.Check<Nz::String>(&argIndex));
|
||||
return true;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return false;
|
||||
});
|
||||
|
||||
directoryClass.BindMethod("Close", &Nz::Directory::Close);
|
||||
|
|
@ -127,7 +134,7 @@ namespace Ndk
|
|||
/*********************************** Nz::File ***********************************/
|
||||
fileClass.Inherit(streamClass);
|
||||
|
||||
fileClass.SetConstructor([](Nz::LuaInstance& lua) -> Nz::File*
|
||||
fileClass.SetConstructor([](Nz::LuaInstance& lua, Nz::File* file)
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 2U);
|
||||
|
||||
|
|
@ -135,20 +142,29 @@ namespace Ndk
|
|||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
return new Nz::File;
|
||||
Nz::PlacementNew(file);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
return new Nz::File(lua.Check<Nz::String>(&argIndex));
|
||||
{
|
||||
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
||||
|
||||
Nz::PlacementNew(file, filePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
Nz::String filePath = lua.Check<Nz::String>(&argIndex);
|
||||
Nz::UInt32 openMode = lua.Check<Nz::UInt32>(&argIndex);
|
||||
return new Nz::File(filePath, openMode);
|
||||
|
||||
Nz::PlacementNew(file, filePath, openMode);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
lua.Error("No matching overload for File constructor");
|
||||
return false;
|
||||
});
|
||||
|
||||
fileClass.BindMethod("Close", &Nz::File::Close);
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ namespace Ndk
|
|||
return reinterpret_cast<Nz::InstancedRenderableRef*>(model); //TODO: Make a ObjectRefCast
|
||||
});
|
||||
|
||||
modelClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::ModelRef*
|
||||
modelClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::ModelRef* model)
|
||||
{
|
||||
return new Nz::ModelRef(new Nz::Model);
|
||||
Nz::PlacementNew(model, Nz::Model::New());
|
||||
return true;
|
||||
});
|
||||
|
||||
//modelClass.SetMethod("GetMaterial", &Nz::Model::GetMaterial);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// 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>
|
||||
|
||||
|
|
@ -9,23 +10,26 @@ namespace Ndk
|
|||
void LuaBinding::BindMath()
|
||||
{
|
||||
/*********************************** Nz::EulerAngles **********************************/
|
||||
eulerAnglesClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::EulerAnglesd*
|
||||
eulerAnglesClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* angles)
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 3U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
return new Nz::EulerAnglesd(0.0, 0.0, 0.0);
|
||||
Nz::PlacementNew(angles, Nz::EulerAnglesd::Zero());
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
return new Nz::EulerAnglesd(*(*static_cast<Nz::EulerAnglesd**>(lua.CheckUserdata(1, "EulerAngles"))));
|
||||
Nz::PlacementNew(angles, *static_cast<Nz::EulerAnglesd*>(lua.CheckUserdata(1, "EulerAngles")));
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
return new Nz::EulerAnglesd(lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3));
|
||||
Nz::PlacementNew(angles, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3));
|
||||
return true;
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for EulerAngles constructor");
|
||||
return nullptr;
|
||||
return false;
|
||||
});
|
||||
|
||||
eulerAnglesClass.BindMethod("__tostring", &Nz::EulerAnglesd::ToString);
|
||||
|
|
@ -145,32 +149,185 @@ namespace Ndk
|
|||
return false;
|
||||
});
|
||||
|
||||
/*********************************** Nz::Quaternion **********************************/
|
||||
quaternionClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::Quaterniond*
|
||||
/*********************************** Nz::Rect **********************************/
|
||||
rectClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* rect)
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 4U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
return new Nz::Quaterniond(1.0, 0.0, 0.0, 0.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;
|
||||
});
|
||||
|
||||
rectClass.BindMethod("__tostring", &Nz::Rectd::ToString);
|
||||
|
||||
rectClass.SetGetter([] (Nz::LuaInstance& lua, Nz::Rectd& instance)
|
||||
{
|
||||
switch (lua.GetType(1))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
long long index = lua.CheckInteger(1);
|
||||
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(1, &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;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
rectClass.SetSetter([] (Nz::LuaInstance& lua, Nz::Rectd& instance)
|
||||
{
|
||||
switch (lua.GetType(1))
|
||||
{
|
||||
case Nz::LuaType_Number:
|
||||
{
|
||||
long long index = lua.CheckInteger(1);
|
||||
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(1, &length);
|
||||
|
||||
if (length != 1)
|
||||
break;
|
||||
|
||||
double value = lua.CheckNumber(2);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/*********************************** Nz::Quaternion **********************************/
|
||||
quaternionClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* quaternion)
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 4U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
Nz::PlacementNew(quaternion, Nz::Quaterniond::Zero());
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(1, "EulerAngles"))
|
||||
return new Nz::Quaterniond(*(*static_cast<Nz::EulerAnglesd**>(lua.ToUserdata(1))));
|
||||
Nz::PlacementNew(quaternion, *static_cast<Nz::EulerAnglesd*>(lua.ToUserdata(1)));
|
||||
else if (lua.IsOfType(1, "Quaternion"))
|
||||
return new Nz::Quaterniond(*(*static_cast<Nz::Quaterniond**>(lua.ToUserdata(1))));
|
||||
Nz::PlacementNew(quaternion, *static_cast<Nz::Quaterniond*>(lua.ToUserdata(1)));
|
||||
else
|
||||
break;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case 2:
|
||||
return new Nz::Quaterniond(lua.CheckNumber(1), *(*static_cast<Nz::Vector3d**>(lua.CheckUserdata(2, "Vector3"))));
|
||||
Nz::PlacementNew(quaternion, lua.CheckNumber(1), *static_cast<Nz::Vector3d*>(lua.CheckUserdata(2, "Vector3")));
|
||||
return true;
|
||||
|
||||
case 4:
|
||||
return new Nz::Quaterniond(lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3), lua.CheckNumber(4));
|
||||
Nz::PlacementNew(quaternion, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3), lua.CheckNumber(4));
|
||||
return true;
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for Quaternion constructor");
|
||||
return nullptr;
|
||||
return false;
|
||||
});
|
||||
|
||||
quaternionClass.BindMethod("__tostring", &Nz::Quaterniond::ToString);
|
||||
|
|
@ -238,28 +395,31 @@ namespace Ndk
|
|||
});
|
||||
|
||||
/*********************************** Nz::Vector2 **********************************/
|
||||
vector2dClass.SetConstructor([](Nz::LuaInstance& lua) -> Nz::Vector2d*
|
||||
vector2dClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Vector2d* vector)
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 2U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
case 2:
|
||||
return new Nz::Vector2d(lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0));
|
||||
Nz::PlacementNew(vector, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0));
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(1, Nz::LuaType_Number))
|
||||
return new Nz::Vector2d(lua.CheckNumber(1));
|
||||
Nz::PlacementNew(vector, lua.CheckNumber(1));
|
||||
else if (lua.IsOfType(1, "Vector2"))
|
||||
return new Nz::Vector2d(*(*static_cast<Nz::Vector2d**>(lua.ToUserdata(1))));
|
||||
Nz::PlacementNew(vector, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)));
|
||||
else
|
||||
break;
|
||||
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for Vector2 constructor");
|
||||
return nullptr;
|
||||
return false;
|
||||
});
|
||||
|
||||
vector2dClass.BindMethod("__tostring", &Nz::Vector2d::ToString);
|
||||
|
|
@ -345,40 +505,44 @@ namespace Ndk
|
|||
});
|
||||
|
||||
/*********************************** Nz::Vector3 **********************************/
|
||||
vector3dClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::Vector3d*
|
||||
vector3dClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector3d* vector)
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 3U);
|
||||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
case 3:
|
||||
return new Nz::Vector3d(lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0));
|
||||
Nz::PlacementNew(vector, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0));
|
||||
|
||||
case 1:
|
||||
{
|
||||
if (lua.IsOfType(1, Nz::LuaType_Number))
|
||||
return new Nz::Vector3d(lua.CheckNumber(1), *(*static_cast<Nz::Vector2d**>(lua.ToUserdata(1))));
|
||||
Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)));
|
||||
else if (lua.IsOfType(1, "Vector2"))
|
||||
return new Nz::Vector3d(*(*static_cast<Nz::Vector2d**>(lua.ToUserdata(1))));
|
||||
Nz::PlacementNew(vector, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)));
|
||||
else if (lua.IsOfType(1, "Vector3"))
|
||||
return new Nz::Vector3d(*(*static_cast<Nz::Vector3d**>(lua.ToUserdata(1))));
|
||||
Nz::PlacementNew(vector, *static_cast<Nz::Vector3d*>(lua.ToUserdata(1)));
|
||||
else
|
||||
break;
|
||||
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
if (lua.IsOfType(1, Nz::LuaType_Number))
|
||||
return new Nz::Vector3d(lua.CheckNumber(1), *(*static_cast<Nz::Vector2d**>(lua.CheckUserdata(1, "Vector2"))));
|
||||
Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast<Nz::Vector2d*>(lua.CheckUserdata(1, "Vector2")));
|
||||
else if (lua.IsOfType(1, "Vector2"))
|
||||
return new Nz::Vector3d(*(*static_cast<Nz::Vector2d**>(lua.ToUserdata(1))), lua.CheckNumber(2));
|
||||
Nz::PlacementNew(vector, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)), lua.CheckNumber(2));
|
||||
else
|
||||
break;
|
||||
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
lua.Error("No matching overload for constructor");
|
||||
return nullptr;
|
||||
return false;
|
||||
});
|
||||
|
||||
vector3dClass.BindMethod("__tostring", &Nz::Vector3d::ToString);
|
||||
|
|
@ -476,6 +640,7 @@ namespace Ndk
|
|||
{
|
||||
eulerAnglesClass.Register(instance);
|
||||
quaternionClass.Register(instance);
|
||||
rectClass.Register(instance);
|
||||
vector2dClass.Register(instance);
|
||||
vector3dClass.Register(instance);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Ndk
|
|||
abstractSocketClass.BindMethod("QueryAvailableBytes", &Nz::AbstractSocket::QueryAvailableBytes);
|
||||
|
||||
/*********************************** Nz::IpAddress **********************************/
|
||||
ipAddressClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::IpAddress*
|
||||
ipAddressClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* address)
|
||||
{
|
||||
unsigned int argCount = std::min(lua.GetStackTop(), 9U);
|
||||
|
||||
|
|
@ -25,30 +25,54 @@ namespace Ndk
|
|||
switch (argCount)
|
||||
{
|
||||
case 0:
|
||||
return new Nz::IpAddress;
|
||||
Nz::PlacementNew(address);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
return new Nz::IpAddress(lua.CheckString(argIndex));
|
||||
Nz::PlacementNew(address, lua.CheckString(argIndex));
|
||||
return true;
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
return new Nz::IpAddress(lua.Check<Nz::UInt8>(&argIndex), lua.Check<Nz::UInt8>(&argIndex), lua.Check<Nz::UInt8>(&argIndex), lua.Check<Nz::UInt8>(&argIndex), lua.Check<Nz::UInt16>(&argIndex, 0));
|
||||
{
|
||||
Nz::UInt8 a = lua.Check<Nz::UInt8>(&argIndex);
|
||||
Nz::UInt8 b = lua.Check<Nz::UInt8>(&argIndex);
|
||||
Nz::UInt8 c = lua.Check<Nz::UInt8>(&argIndex);
|
||||
Nz::UInt8 d = lua.Check<Nz::UInt8>(&argIndex);
|
||||
Nz::UInt16 port = lua.Check<Nz::UInt16>(&argIndex, 0);
|
||||
|
||||
Nz::PlacementNew(address, a, b, c, d, port);
|
||||
return true;
|
||||
}
|
||||
|
||||
case 8:
|
||||
case 9:
|
||||
return new Nz::IpAddress(lua.Check<Nz::UInt16>(&argIndex), lua.Check<Nz::UInt16>(&argIndex), lua.Check<Nz::UInt16>(&argIndex), lua.Check<Nz::UInt16>(&argIndex),
|
||||
lua.Check<Nz::UInt16>(&argIndex), lua.Check<Nz::UInt16>(&argIndex), lua.Check<Nz::UInt16>(&argIndex), lua.Check<Nz::UInt16>(&argIndex), lua.Check<Nz::UInt16>(&argIndex, 0));
|
||||
{
|
||||
Nz::UInt16 a = lua.Check<Nz::UInt16>(&argIndex);
|
||||
Nz::UInt16 b = lua.Check<Nz::UInt16>(&argIndex);
|
||||
Nz::UInt16 c = lua.Check<Nz::UInt16>(&argIndex);
|
||||
Nz::UInt16 d = lua.Check<Nz::UInt16>(&argIndex);
|
||||
Nz::UInt16 e = lua.Check<Nz::UInt16>(&argIndex);
|
||||
Nz::UInt16 f = lua.Check<Nz::UInt16>(&argIndex);
|
||||
Nz::UInt16 g = lua.Check<Nz::UInt16>(&argIndex);
|
||||
Nz::UInt16 h = lua.Check<Nz::UInt16>(&argIndex);
|
||||
Nz::UInt16 port = lua.Check<Nz::UInt16>(&argIndex, 0);
|
||||
|
||||
Nz::PlacementNew(address, a, b, c, d, e, f, g, h, port);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
lua.Error("No matching overload for constructor");
|
||||
return false;
|
||||
});
|
||||
|
||||
ipAddressClass.BindMethod("GetPort", &Nz::IpAddress::GetPort);
|
||||
ipAddressClass.BindMethod("GetPort", &Nz::IpAddress::GetPort);
|
||||
ipAddressClass.BindMethod("GetProtocol", &Nz::IpAddress::GetProtocol);
|
||||
ipAddressClass.BindMethod("IsLoopback", &Nz::IpAddress::IsLoopback);
|
||||
ipAddressClass.BindMethod("IsValid", &Nz::IpAddress::IsValid);
|
||||
ipAddressClass.BindMethod("ToUInt32", &Nz::IpAddress::ToUInt32);
|
||||
ipAddressClass.BindMethod("__tostring", &Nz::IpAddress::ToString);
|
||||
ipAddressClass.BindMethod("IsLoopback", &Nz::IpAddress::IsLoopback);
|
||||
ipAddressClass.BindMethod("IsValid", &Nz::IpAddress::IsValid);
|
||||
ipAddressClass.BindMethod("ToUInt32", &Nz::IpAddress::ToUInt32);
|
||||
ipAddressClass.BindMethod("__tostring", &Nz::IpAddress::ToString);
|
||||
|
||||
ipAddressClass.BindStaticMethod("ResolveAddress", [] (Nz::LuaInstance& instance) -> int
|
||||
{
|
||||
|
|
@ -79,7 +103,7 @@ namespace Ndk
|
|||
int argIndex = 1;
|
||||
Nz::NetProtocol protocol = instance.Check<Nz::NetProtocol>(&argIndex);
|
||||
Nz::String hostname = instance.Check<Nz::String>(&argIndex);
|
||||
Nz::String service = instance.Check<Nz::String>(&argIndex, "http");
|
||||
Nz::String service = instance.Check<Nz::String>(&argIndex, "http");
|
||||
|
||||
std::vector<Nz::HostnameInfo> addresses = Nz::IpAddress::ResolveHostname(protocol, hostname, service, &error);
|
||||
if (error == Nz::ResolveError_NoError)
|
||||
|
|
|
|||
|
|
@ -89,9 +89,10 @@ namespace Ndk
|
|||
});
|
||||
|
||||
/*********************************** Nz::Font **********************************/
|
||||
fontClass.SetConstructor([] (Nz::LuaInstance& lua) -> Nz::FontRef*
|
||||
fontClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::FontRef* font)
|
||||
{
|
||||
return new Nz::FontRef(new Nz::Font);
|
||||
Nz::PlacementNew(font, Nz::Font::New());
|
||||
return true;
|
||||
});
|
||||
|
||||
fontClass.BindMethod("ClearGlyphCache", &Nz::Font::ClearGlyphCache);
|
||||
|
|
|
|||
|
|
@ -243,12 +243,17 @@ function NazaraBuild:Execute()
|
|||
|
||||
-- Tools
|
||||
for k, toolTable in ipairs(self.OrderedTools) do
|
||||
project("Nazara" .. toolTable.Name)
|
||||
local prefix = "Nazara"
|
||||
if (toolTable.Kind == "plugin") then
|
||||
prefix = "Plugin"
|
||||
end
|
||||
|
||||
project(prefix .. toolTable.Name)
|
||||
|
||||
location(_ACTION .. "/tools")
|
||||
targetdir(toolTable.Directory)
|
||||
|
||||
if (toolTable.Kind == "library") then
|
||||
if (toolTable.Kind == "plugin" or toolTable.Kind == "library") then
|
||||
kind("SharedLib")
|
||||
elseif (toolTable.Kind == "consoleapp") then
|
||||
debugdir(toolTable.Directory)
|
||||
|
|
@ -257,7 +262,7 @@ function NazaraBuild:Execute()
|
|||
debugdir(toolTable.Directory)
|
||||
kind("WindowedApp")
|
||||
else
|
||||
assert(false, "wut")
|
||||
assert(false, "Invalid tool Kind")
|
||||
end
|
||||
|
||||
includedirs({
|
||||
|
|
@ -280,6 +285,8 @@ function NazaraBuild:Execute()
|
|||
libdirs("../lib/" .. makeLibDir .. "/x86")
|
||||
if (toolTable.Kind == "library") then
|
||||
targetdir("../lib/" .. makeLibDir .. "/x86")
|
||||
elseif (toolTable.Kind == "plugin") then
|
||||
targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x32")
|
||||
end
|
||||
|
||||
configuration({"codeblocks or codelite or gmake", "x64"})
|
||||
|
|
@ -287,6 +294,8 @@ function NazaraBuild:Execute()
|
|||
libdirs("../lib/" .. makeLibDir .. "/x64")
|
||||
if (toolTable.Kind == "library") then
|
||||
targetdir("../lib/" .. makeLibDir .. "/x64")
|
||||
elseif (toolTable.Kind == "plugin") then
|
||||
targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x64")
|
||||
end
|
||||
|
||||
configuration({"vs*", "x32"})
|
||||
|
|
@ -294,6 +303,8 @@ function NazaraBuild:Execute()
|
|||
libdirs("../lib/msvc/x86")
|
||||
if (toolTable.Kind == "library") then
|
||||
targetdir("../lib/msvc/x86")
|
||||
elseif (toolTable.Kind == "plugin") then
|
||||
targetdir("../plugins/" .. toolTable.Name .. "/lib/msvc/x86")
|
||||
end
|
||||
|
||||
configuration({"vs*", "x64"})
|
||||
|
|
@ -301,6 +312,8 @@ function NazaraBuild:Execute()
|
|||
libdirs("../lib/msvc/x64")
|
||||
if (toolTable.Kind == "library") then
|
||||
targetdir("../lib/msvc/x64")
|
||||
elseif (toolTable.Kind == "plugin") then
|
||||
targetdir("../plugins/" .. toolTable.Name .. "/lib/msvc/x64")
|
||||
end
|
||||
|
||||
configuration({"xcode3 or xcode4", "x32"})
|
||||
|
|
@ -308,6 +321,8 @@ function NazaraBuild:Execute()
|
|||
libdirs("../lib/xcode/x86")
|
||||
if (toolTable.Kind == "library") then
|
||||
targetdir("../lib/xcode/x86")
|
||||
elseif (toolTable.Kind == "plugin") then
|
||||
targetdir("../plugins/" .. toolTable.Name .. "/lib/xcode/x86")
|
||||
end
|
||||
|
||||
configuration({"xcode3 or xcode4", "x64"})
|
||||
|
|
@ -315,9 +330,11 @@ function NazaraBuild:Execute()
|
|||
libdirs("../lib/xcode/x64")
|
||||
if (toolTable.Kind == "library") then
|
||||
targetdir("../lib/xcode/x64")
|
||||
elseif (toolTable.Kind == "plugin") then
|
||||
targetdir("../plugins/" .. toolTable.Name .. "/lib/xcode/x64")
|
||||
end
|
||||
|
||||
if (toolTable.Kind == "library") then
|
||||
if (toolTable.Kind == "library" or toolTable.Kind == "plugin") then
|
||||
configuration("*Static")
|
||||
kind("StaticLib")
|
||||
|
||||
|
|
@ -719,7 +736,7 @@ function NazaraBuild:RegisterTool(toolTable)
|
|||
end
|
||||
|
||||
local lowerCaseKind = toolTable.Kind:lower()
|
||||
if (lowerCaseKind == "library" or lowerCaseKind == "consoleapp" or lowerCaseKind == "windowapp") then
|
||||
if (lowerCaseKind == "library" or lowerCaseKind == "plugin" or lowerCaseKind == "consoleapp" or lowerCaseKind == "windowapp") then
|
||||
toolTable.Kind = lowerCaseKind
|
||||
else
|
||||
return false, "Invalid tool type"
|
||||
|
|
@ -787,6 +804,23 @@ function NazaraBuild:Process(infoTable)
|
|||
end
|
||||
infoTable.Libraries = libraries
|
||||
|
||||
for platform, defineTable in pairs(infoTable.OsDefines) do
|
||||
platform = string.lower(platform)
|
||||
if (platform == "posix") then
|
||||
local osname = os.get()
|
||||
if (PosixOSes[osname]) then
|
||||
platform = osname
|
||||
end
|
||||
end
|
||||
|
||||
if (os.is(platform)) then
|
||||
for k,v in ipairs(defineTable) do
|
||||
table.insert(infoTable.Defines, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
infoTable.OsDefines = nil
|
||||
|
||||
for platform, fileTable in pairs(infoTable.OsFiles) do
|
||||
platform = string.lower(platform)
|
||||
if (platform == "posix") then
|
||||
|
|
@ -838,6 +872,7 @@ function NazaraBuild:SetupInfoTable(infoTable)
|
|||
infoTable.Flags = {}
|
||||
infoTable.Includes = {}
|
||||
infoTable.Libraries = {}
|
||||
infoTable.OsDefines = {}
|
||||
infoTable.OsFiles = {}
|
||||
infoTable.OsLibraries = {}
|
||||
end
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
TOOL.Name = "Assimp"
|
||||
|
||||
TOOL.Directory = "../SDK/lib"
|
||||
TOOL.Kind = "Plugin"
|
||||
|
||||
TOOL.Includes = {
|
||||
"../include",
|
||||
"../plugins/Assimp"
|
||||
}
|
||||
|
||||
TOOL.Files = {
|
||||
"../plugins/Assimp/**.hpp",
|
||||
"../plugins/Assimp/**.inl",
|
||||
"../plugins/Assimp/**.cpp"
|
||||
}
|
||||
|
||||
TOOL.Libraries = {
|
||||
"NazaraCore",
|
||||
"NazaraUtility",
|
||||
"assimp"
|
||||
}
|
||||
|
|
@ -79,7 +79,8 @@ namespace Nz
|
|||
|
||||
OpenMode_Append = 0x01, // Disable writing on existing parts and put the cursor at the end
|
||||
OpenMode_Lock = 0x02, // Disable modifying the file before it is open
|
||||
OpenMode_ReadOnly = 0x04, // Open in read only
|
||||
OpenMode_MustExit = 0x04, // Fail if the file doesn't exists, even if opened in write mode
|
||||
OpenMode_ReadOnly = 0x08, // Open in read only
|
||||
OpenMode_Text = 0x10, // Open in text mod
|
||||
OpenMode_Truncate = 0x20, // Create the file if it doesn't exist and empty it if it exists
|
||||
OpenMode_WriteOnly = 0x40, // Open in write only, create the file if it doesn't exist
|
||||
|
|
@ -105,7 +106,8 @@ namespace Nz
|
|||
enum Plugin
|
||||
{
|
||||
Plugin_Assimp,
|
||||
Plugin_FreeType
|
||||
|
||||
Plugin_Count
|
||||
};
|
||||
|
||||
enum PrimitiveType
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ namespace Nz
|
|||
bool SetCursorPos(CursorPosition pos, Int64 offset = 0);
|
||||
bool SetCursorPos(UInt64 offset) override;
|
||||
bool SetFile(const String& filePath);
|
||||
bool SetSize(UInt64 size);
|
||||
|
||||
File& operator=(const String& filePath);
|
||||
File& operator=(const File&) = delete;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Nz
|
|||
void* OperatorNew(std::size_t size);
|
||||
|
||||
template<typename T, typename... Args>
|
||||
T* PlacementNew(void* ptr, Args&&... args);
|
||||
T* PlacementNew(T* ptr, Args&&... args);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/MemoryHelper.inl>
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace Nz
|
|||
* \param args Arguments for the constructor
|
||||
*/
|
||||
template<typename T, typename... Args>
|
||||
T* PlacementNew(void* ptr, Args&&... args)
|
||||
T* PlacementNew(T* ptr, Args&&... args)
|
||||
{
|
||||
return new (ptr) T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ namespace Nz
|
|||
inline T* MemoryPool::New(Args&&... args)
|
||||
{
|
||||
T* object = static_cast<T*>(Allocate(sizeof(T)));
|
||||
PlacementNew<T>(object, std::forward<Args>(args)...);
|
||||
PlacementNew(object, std::forward<Args>(args)...);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Nz
|
|||
public:
|
||||
using ClassFunc = std::function<int(LuaInstance& lua, T& instance)>;
|
||||
using ClassIndexFunc = std::function<bool(LuaInstance& lua, T& instance)>;
|
||||
using ConstructorFunc = std::function<T*(LuaInstance& lua)>;
|
||||
using ConstructorFunc = std::function<bool(LuaInstance& lua, T* instance)>;
|
||||
template<typename P> using ConvertToParent = std::function<P*(T*)>;
|
||||
using FinalizerFunc = std::function<bool(LuaInstance& lua, T& instance)>;
|
||||
using StaticIndexFunc = std::function<bool(LuaInstance& lua)>;
|
||||
|
|
@ -36,6 +36,8 @@ namespace Nz
|
|||
|
||||
LuaClass(const String& name);
|
||||
|
||||
void BindDefaultConstructor();
|
||||
|
||||
void BindMethod(const String& name, ClassFunc method);
|
||||
template<typename R, typename P, typename... Args, typename... DefArgs> std::enable_if_t<std::is_base_of<P, T>::value> BindMethod(const String& name, R(P::*func)(Args...), DefArgs&&... defArgs);
|
||||
template<typename R, typename P, typename... Args, typename... DefArgs> std::enable_if_t<std::is_base_of<P, T>::value> BindMethod(const String& name, R(P::*func)(Args...) const, DefArgs&&... defArgs);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,16 @@ namespace Nz
|
|||
m_info->name = name;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void LuaClass<T>::BindDefaultConstructor()
|
||||
{
|
||||
SetConstructor([] (Nz::LuaInstance& lua, T* instance)
|
||||
{
|
||||
PlacementNew(instance);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template<class P>
|
||||
inline void LuaClass<T>::Inherit(LuaClass<P>& parent)
|
||||
|
|
@ -36,7 +46,7 @@ namespace Nz
|
|||
|
||||
parentInfo->instanceGetters[m_info->name] = [info = m_info, convertFunc] (LuaInstance& lua) -> P*
|
||||
{
|
||||
return convertFunc(*static_cast<T**>(lua.CheckUserdata(1, info->name)));
|
||||
return convertFunc(static_cast<T*>(lua.CheckUserdata(1, info->name)));
|
||||
};
|
||||
|
||||
m_info->parentGetters.emplace_back([parentInfo, convertFunc] (LuaInstance& lua, T* instance)
|
||||
|
|
@ -54,8 +64,8 @@ namespace Nz
|
|||
// cette UserData disposera d'un finalizer qui libérera le ClassInfo
|
||||
// Ainsi c'est Lua qui va s'occuper de la destruction pour nous :-)
|
||||
// De même, l'utilisation d'un shared_ptr permet de garder la structure en vie même si l'instance est libérée avant le LuaClass
|
||||
void* info = lua.PushUserdata(sizeof(std::shared_ptr<ClassInfo>));
|
||||
PlacementNew<std::shared_ptr<ClassInfo>>(info, m_info);
|
||||
std::shared_ptr<ClassInfo>* info = static_cast<std::shared_ptr<ClassInfo>*>(lua.PushUserdata(sizeof(std::shared_ptr<ClassInfo>)));
|
||||
PlacementNew(info, m_info);
|
||||
|
||||
// On créé la table qui contiendra une méthode (Le finalizer) pour libérer le ClassInfo
|
||||
lua.PushTable(0, 1);
|
||||
|
|
@ -124,7 +134,7 @@ namespace Nz
|
|||
|
||||
m_info->instanceGetters[m_info->name] = [info = m_info] (LuaInstance& lua)
|
||||
{
|
||||
return *static_cast<T**>(lua.CheckUserdata(1, info->name));
|
||||
return static_cast<T*>(lua.CheckUserdata(1, info->name));
|
||||
};
|
||||
}
|
||||
lua.Pop(); // On pop la metatable
|
||||
|
|
@ -322,14 +332,15 @@ namespace Nz
|
|||
|
||||
lua.Remove(1); // On enlève l'argument "table" du stack
|
||||
|
||||
T* instance = constructor(lua);
|
||||
if (!instance)
|
||||
T* instance = static_cast<T*>(lua.PushUserdata(sizeof(T)));
|
||||
|
||||
if (!constructor(lua, instance))
|
||||
{
|
||||
lua.Error("Constructor failed");
|
||||
return 0; // Normalement jamais exécuté (l'erreur provoquant une exception)
|
||||
}
|
||||
|
||||
lua.PushInstance(info->name.GetConstBuffer(), instance);
|
||||
lua.SetMetatable(info->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -341,11 +352,11 @@ namespace Nz
|
|||
std::shared_ptr<ClassInfo>& info = *static_cast<std::shared_ptr<ClassInfo>*>(lua.ToUserdata(lua.GetIndexOfUpValue(1)));
|
||||
const FinalizerFunc& finalizer = info->finalizer;
|
||||
|
||||
T* instance = *static_cast<T**>(lua.CheckUserdata(1, info->name));
|
||||
T* instance = static_cast<T*>(lua.CheckUserdata(1, info->name));
|
||||
lua.Remove(1); //< Remove the instance from the Lua stack
|
||||
|
||||
if (!finalizer || finalizer(lua, *instance))
|
||||
delete instance;
|
||||
instance->~T();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -399,7 +410,7 @@ namespace Nz
|
|||
|
||||
std::shared_ptr<ClassInfo>& info = *static_cast<std::shared_ptr<ClassInfo>*>(lua.ToUserdata(lua.GetIndexOfUpValue(1)));
|
||||
|
||||
T* instance = *static_cast<T**>(lua.CheckUserdata(1, info->name));
|
||||
T* instance = static_cast<T*>(lua.CheckUserdata(1, info->name));
|
||||
lua.Remove(1); //< Remove the instance from the Lua stack
|
||||
|
||||
Get(info, lua, instance);
|
||||
|
|
@ -448,7 +459,7 @@ namespace Nz
|
|||
std::shared_ptr<ClassInfo>& info = *static_cast<std::shared_ptr<ClassInfo>*>(lua.ToUserdata(lua.GetIndexOfUpValue(1)));
|
||||
const ClassIndexFunc& setter = info->setter;
|
||||
|
||||
T& instance = *(*static_cast<T**>(lua.CheckUserdata(1, info->name)));
|
||||
T& instance = *static_cast<T*>(lua.CheckUserdata(1, info->name));
|
||||
lua.Remove(1); //< Remove the instance from the Lua stack
|
||||
|
||||
if (!setter(lua, instance))
|
||||
|
|
|
|||
|
|
@ -131,7 +131,8 @@ namespace Nz
|
|||
template<typename R, typename... Args, typename... DefArgs> void PushFunction(R(*func)(Args...), DefArgs&&... defArgs) const;
|
||||
template<typename T> void PushGlobal(const char* name, T&& arg);
|
||||
template<typename T> void PushGlobal(const String& name, T&& arg);
|
||||
template<typename T> void PushInstance(const char* tname, T* instance) const;
|
||||
template<typename T> void PushInstance(const char* tname, const T& instance) const;
|
||||
template<typename T> void PushInstance(const char* tname, T&& instance) const;
|
||||
template<typename T, typename... Args> void PushInstance(const char* tname, Args&&... args) const;
|
||||
void PushInteger(long long value) const;
|
||||
void PushLightUserdata(void* value) const;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <Nazara/Lua/LuaInstance.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
|
@ -156,21 +157,21 @@ namespace Nz
|
|||
return LuaImplReplyVal(instance, val, TypeTag<T>());
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, std::string val, TypeTag<std::string>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, std::string&& val, TypeTag<std::string>)
|
||||
{
|
||||
instance.PushString(val.c_str(), val.size());
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, std::vector<T> valContainer, TypeTag<std::vector<T>>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, std::vector<T>&& valContainer, TypeTag<std::vector<T>>)
|
||||
{
|
||||
std::size_t index = 1;
|
||||
instance.PushTable(valContainer.size());
|
||||
for (const T& val : valContainer)
|
||||
for (T& val : valContainer)
|
||||
{
|
||||
instance.PushInteger(index++);
|
||||
if (LuaImplReplyVal(instance, val, TypeTag<T>()) != 1)
|
||||
if (LuaImplReplyVal(instance, std::move(val), TypeTag<T>()) != 1)
|
||||
{
|
||||
instance.Error("Couldn't create table: type need more than one place to store");
|
||||
return 0;
|
||||
|
|
@ -181,20 +182,20 @@ namespace Nz
|
|||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, ByteArray val, TypeTag<ByteArray>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, ByteArray&& val, TypeTag<ByteArray>)
|
||||
{
|
||||
instance.PushString(reinterpret_cast<const char*>(val.GetConstBuffer()), val.GetSize());
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, String val, TypeTag<String>)
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, String&& val, TypeTag<String>)
|
||||
{
|
||||
instance.PushString(std::move(val));
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<typename T1, typename T2>
|
||||
int LuaImplReplyVal(const LuaInstance& instance, std::pair<T1, T2> val, TypeTag<std::pair<T1, T2>>)
|
||||
int LuaImplReplyVal(const LuaInstance& instance, std::pair<T1, T2>&& val, TypeTag<std::pair<T1, T2>>)
|
||||
{
|
||||
int retVal = 0;
|
||||
|
||||
|
|
@ -593,24 +594,37 @@ namespace Nz
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
void LuaInstance::PushInstance(const char* tname, T* instance) const
|
||||
void LuaInstance::PushInstance(const char* tname, const T& instance) const
|
||||
{
|
||||
T** userdata = static_cast<T**>(PushUserdata(sizeof(T*)));
|
||||
*userdata = instance;
|
||||
T* userdata = static_cast<T*>(PushUserdata(sizeof(T*)));
|
||||
PlacementNew(userdata, instance);
|
||||
|
||||
SetMetatable(tname);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void LuaInstance::PushInstance(const char* tname, T&& instance) const
|
||||
{
|
||||
T* userdata = static_cast<T*>(PushUserdata(sizeof(T*)));
|
||||
PlacementNew(userdata, std::move(instance));
|
||||
|
||||
SetMetatable(tname);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
void LuaInstance::PushInstance(const char* tname, Args&&... args) const
|
||||
{
|
||||
PushInstance(tname, new T(std::forward<Args>(args)...));
|
||||
T* userdata = static_cast<T*>(PushUserdata(sizeof(T*)));
|
||||
PlacementNew(userdata, std::forward<Args>(args)...);
|
||||
|
||||
SetMetatable(tname);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T LuaInstance::CheckBounds(int index, long long value) const
|
||||
{
|
||||
long long minBounds = std::numeric_limits<T>::min();
|
||||
long long maxBounds = std::numeric_limits<T>::max();
|
||||
constexpr long long minBounds = std::numeric_limits<T>::min();
|
||||
constexpr long long maxBounds = std::numeric_limits<T>::max();
|
||||
if (value < minBounds || value > maxBounds)
|
||||
{
|
||||
Nz::StringStream stream;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,140 @@
|
|||
// Copyright (C) 2016 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Assimp Plugin"
|
||||
// For conditions of distribution and use, see copyright notice in Plugin.cpp
|
||||
|
||||
#include <CustomStream.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <assimp/cfileio.h>
|
||||
#include <assimp/cimport.h>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
using namespace Nz;
|
||||
|
||||
void StreamFlush(aiFile* file)
|
||||
{
|
||||
Stream* stream = reinterpret_cast<Stream*>(file->UserData);
|
||||
stream->Flush();
|
||||
}
|
||||
|
||||
size_t StreamRead(aiFile* file, char* buffer, size_t size, size_t count)
|
||||
{
|
||||
Stream* stream = reinterpret_cast<Stream*>(file->UserData);
|
||||
return stream->Read(buffer, size * count);
|
||||
}
|
||||
|
||||
aiReturn StreamSeek(aiFile* file, size_t offset, aiOrigin origin)
|
||||
{
|
||||
Stream* stream = reinterpret_cast<Stream*>(file->UserData);
|
||||
switch (origin)
|
||||
{
|
||||
case aiOrigin_CUR:
|
||||
return (stream->SetCursorPos(stream->GetCursorPos() + offset)) ? aiReturn_SUCCESS : aiReturn_FAILURE;
|
||||
|
||||
case aiOrigin_END:
|
||||
return (stream->SetCursorPos(stream->GetSize() - offset)) ? aiReturn_SUCCESS : aiReturn_FAILURE;
|
||||
|
||||
case aiOrigin_SET:
|
||||
return (stream->SetCursorPos(offset)) ? aiReturn_SUCCESS : aiReturn_FAILURE;
|
||||
}
|
||||
|
||||
NazaraWarning("Unhandled aiOrigin enum (value: 0x" + String(origin, 16) + ')');
|
||||
return aiReturn_FAILURE;
|
||||
}
|
||||
|
||||
size_t StreamSize(aiFile* file)
|
||||
{
|
||||
Stream* stream = reinterpret_cast<Stream*>(file->UserData);
|
||||
return static_cast<std::size_t>(stream->GetSize());
|
||||
}
|
||||
|
||||
size_t StreamTell(aiFile* file)
|
||||
{
|
||||
Stream* stream = reinterpret_cast<Stream*>(file->UserData);
|
||||
return static_cast<std::size_t>(stream->GetCursorPos());
|
||||
}
|
||||
|
||||
size_t StreamWrite(aiFile* file, const char* buffer, size_t size, size_t count)
|
||||
{
|
||||
Stream* stream = reinterpret_cast<Stream*>(file->UserData);
|
||||
return stream->Write(buffer, size * count);
|
||||
}
|
||||
|
||||
aiFile* StreamOpener(aiFileIO* fileIO, const char* filePath, const char* openMode)
|
||||
{
|
||||
FileIOUserdata* fileIOUserdata = reinterpret_cast<FileIOUserdata*>(fileIO->UserData);
|
||||
|
||||
bool isOriginalStream = (std::strcmp(filePath, fileIOUserdata->originalFilePath) == 0);
|
||||
if (!isOriginalStream && strstr(filePath, StreamPath) != 0)
|
||||
return nullptr;
|
||||
|
||||
aiUserData stream;
|
||||
if (isOriginalStream)
|
||||
stream = reinterpret_cast<aiUserData>(fileIOUserdata->originalStream);
|
||||
else
|
||||
{
|
||||
ErrorFlags errFlags(ErrorFlag_ThrowExceptionDisabled, true);
|
||||
|
||||
///TODO: Move to File::DecodeOpenMode
|
||||
UInt32 openModeEnum = 0;
|
||||
|
||||
if (std::strchr(openMode, 'r'))
|
||||
{
|
||||
openModeEnum |= OpenMode_ReadOnly;
|
||||
if (std::strchr(openMode, '+'))
|
||||
openModeEnum |= OpenMode_ReadWrite | OpenMode_MustExit;
|
||||
}
|
||||
else if (std::strchr(openMode, 'w'))
|
||||
{
|
||||
openModeEnum |= OpenMode_WriteOnly | OpenMode_Truncate;
|
||||
if (std::strchr(openMode, '+'))
|
||||
openModeEnum |= OpenMode_ReadOnly;
|
||||
}
|
||||
else if (std::strchr(openMode, 'a'))
|
||||
{
|
||||
openModeEnum |= OpenMode_WriteOnly | OpenMode_Append;
|
||||
if (std::strchr(openMode, '+'))
|
||||
openModeEnum |= OpenMode_ReadOnly;
|
||||
}
|
||||
else
|
||||
{
|
||||
NazaraError(String("Unhandled/Invalid openmode: ") + openMode + String(" for file ") + filePath);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!std::strchr(openMode, 'b'))
|
||||
openModeEnum |= OpenMode_Text;
|
||||
|
||||
std::unique_ptr<File> file = std::make_unique<File>();
|
||||
if (!file->Open(filePath, openModeEnum))
|
||||
return nullptr;
|
||||
|
||||
stream = reinterpret_cast<char*>(file.release());
|
||||
}
|
||||
|
||||
std::unique_ptr<aiFile> file = std::make_unique<aiFile>();
|
||||
file->FileSizeProc = StreamSize;
|
||||
file->FlushProc = StreamFlush;
|
||||
file->ReadProc = StreamRead;
|
||||
file->SeekProc = StreamSeek;
|
||||
file->TellProc = StreamTell;
|
||||
file->WriteProc = StreamWrite;
|
||||
file->UserData = stream;
|
||||
|
||||
return file.release();
|
||||
}
|
||||
|
||||
void StreamCloser(aiFileIO* fileIO, aiFile* file)
|
||||
{
|
||||
FileIOUserdata* fileIOUserdata = reinterpret_cast<FileIOUserdata*>(fileIO->UserData);
|
||||
Stream* fileUserdata = reinterpret_cast<Stream*>(file->UserData);
|
||||
|
||||
if (fileUserdata != fileIOUserdata->originalStream)
|
||||
delete reinterpret_cast<File*>(file->UserData);
|
||||
|
||||
delete file;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2016 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Assimp Plugin"
|
||||
// For conditions of distribution and use, see copyright notice in Plugin.cpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ASSIMP_CUSTOM_STREAM_HPP
|
||||
#define NAZARA_ASSIMP_CUSTOM_STREAM_HPP
|
||||
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <assimp/cfileio.h>
|
||||
|
||||
constexpr const char StreamPath[] = "<Nazara:Stream>";
|
||||
|
||||
void StreamFlush(aiFile* file);
|
||||
size_t StreamRead(aiFile* file, char* buffer, size_t size, size_t count);
|
||||
aiReturn StreamSeek(aiFile* file, size_t offset, aiOrigin origin);
|
||||
size_t StreamSize(aiFile* file);
|
||||
size_t StreamTell(aiFile* file);
|
||||
size_t StreamWrite(aiFile* file, const char* buffer, size_t size, size_t count);
|
||||
|
||||
struct FileIOUserdata
|
||||
{
|
||||
Nz::Stream* originalStream;
|
||||
const char* originalFilePath;
|
||||
};
|
||||
|
||||
aiFile* StreamOpener(aiFileIO* fileIO, const char* filePath, const char* openMode);
|
||||
void StreamCloser(aiFileIO* fileIO, aiFile* file);
|
||||
|
||||
#endif // NAZARA_ASSIMP_CUSTOM_STREAM_HPP
|
||||
|
|
@ -0,0 +1,250 @@
|
|||
/*
|
||||
Nazara Engine - Assimp Plugin
|
||||
|
||||
Copyright (C) 2015 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <CustomStream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <Nazara/Utility/IndexIterator.hpp>
|
||||
#include <Nazara/Utility/IndexMapper.hpp>
|
||||
#include <Nazara/Utility/StaticMesh.hpp>
|
||||
#include <assimp/cfileio.h>
|
||||
#include <assimp/cimport.h>
|
||||
#include <assimp/config.h>
|
||||
#include <assimp/mesh.h>
|
||||
#include <assimp/postprocess.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <set>
|
||||
|
||||
using namespace Nz;
|
||||
|
||||
void ProcessJoints(aiNode* node, Skeleton* skeleton, const std::set<Nz::String>& joints)
|
||||
{
|
||||
Nz::String jointName(node->mName.data, node->mName.length);
|
||||
if (joints.count(jointName))
|
||||
{
|
||||
Joint* joint = skeleton->GetJoint(jointName);
|
||||
if (joint)
|
||||
{
|
||||
if (node->mParent)
|
||||
joint->SetParent(skeleton->GetJoint(node->mParent->mName.C_Str()));
|
||||
|
||||
Matrix4f transformMatrix(node->mTransformation.a1, node->mTransformation.a2, node->mTransformation.a3, node->mTransformation.a4,
|
||||
node->mTransformation.b1, node->mTransformation.b2, node->mTransformation.b3, node->mTransformation.b4,
|
||||
node->mTransformation.c1, node->mTransformation.c2, node->mTransformation.c3, node->mTransformation.c4,
|
||||
node->mTransformation.d1, node->mTransformation.d2, node->mTransformation.d3, node->mTransformation.d4);
|
||||
|
||||
transformMatrix.InverseAffine();
|
||||
|
||||
joint->SetInverseBindMatrix(transformMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < node->mNumChildren; ++i)
|
||||
ProcessJoints(node->mChildren[i], skeleton, joints);
|
||||
}
|
||||
|
||||
bool IsSupported(const String& extension)
|
||||
{
|
||||
String dotExt = '.' + extension;
|
||||
return (aiIsExtensionSupported(dotExt.GetConstBuffer()) == AI_TRUE);
|
||||
}
|
||||
|
||||
Ternary Check(Stream& stream, const MeshParams& parameters)
|
||||
{
|
||||
bool skip;
|
||||
if (parameters.custom.GetBooleanParameter("SkipAssimpLoader", &skip) && skip)
|
||||
return Ternary_False;
|
||||
|
||||
return Ternary_Unknown;
|
||||
}
|
||||
|
||||
bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters)
|
||||
{
|
||||
Nz::String streamPath = stream.GetPath();
|
||||
|
||||
FileIOUserdata userdata;
|
||||
userdata.originalFilePath = (!streamPath.IsEmpty()) ? streamPath.GetConstBuffer() : StreamPath;
|
||||
userdata.originalStream = &stream;
|
||||
|
||||
aiFileIO fileIO;
|
||||
fileIO.CloseProc = StreamCloser;
|
||||
fileIO.OpenProc = StreamOpener;
|
||||
fileIO.UserData = reinterpret_cast<char*>(&userdata);
|
||||
|
||||
unsigned int postProcess = aiProcess_CalcTangentSpace | aiProcess_JoinIdenticalVertices
|
||||
| aiProcess_MakeLeftHanded | aiProcess_Triangulate
|
||||
| aiProcess_RemoveComponent | aiProcess_GenSmoothNormals
|
||||
| aiProcess_SplitLargeMeshes | aiProcess_LimitBoneWeights
|
||||
| aiProcess_ImproveCacheLocality | aiProcess_RemoveRedundantMaterials
|
||||
| aiProcess_FixInfacingNormals | aiProcess_SortByPType
|
||||
| aiProcess_FindInvalidData | aiProcess_GenUVCoords
|
||||
| aiProcess_TransformUVCoords | aiProcess_OptimizeMeshes
|
||||
| aiProcess_OptimizeGraph | aiProcess_FlipWindingOrder
|
||||
| aiProcess_Debone;
|
||||
|
||||
if (!parameters.flipUVs)
|
||||
postProcess |= aiProcess_FlipUVs;
|
||||
|
||||
if (parameters.optimizeIndexBuffers)
|
||||
postProcess |= aiProcess_ImproveCacheLocality;
|
||||
|
||||
float smoothingAngle = 80.f;
|
||||
parameters.custom.GetFloatParameter("AssimpLoader_SmoothingAngle", &smoothingAngle);
|
||||
|
||||
int triangleLimit = 1'000'000;
|
||||
parameters.custom.GetIntegerParameter("AssimpLoader_TriangleLimit", &triangleLimit);
|
||||
|
||||
int vertexLimit = 1'000'000;
|
||||
parameters.custom.GetIntegerParameter("AssimpLoader_VertexLimit", &vertexLimit);
|
||||
|
||||
aiPropertyStore* properties = aiCreatePropertyStore();
|
||||
aiSetImportPropertyFloat(properties, AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE, smoothingAngle);
|
||||
aiSetImportPropertyInteger(properties, AI_CONFIG_PP_LBW_MAX_WEIGHTS, 4);
|
||||
aiSetImportPropertyInteger(properties, AI_CONFIG_PP_SBP_REMOVE, ~aiPrimitiveType_TRIANGLE); //< We only want triangles
|
||||
aiSetImportPropertyInteger(properties, AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, triangleLimit);
|
||||
aiSetImportPropertyInteger(properties, AI_CONFIG_PP_SLM_VERTEX_LIMIT, vertexLimit);
|
||||
aiSetImportPropertyInteger(properties, AI_CONFIG_PP_RVC_FLAGS, aiComponent_COLORS);
|
||||
|
||||
const aiScene* scene = aiImportFileExWithProperties(userdata.originalFilePath, postProcess, &fileIO, properties);
|
||||
aiReleasePropertyStore(properties);
|
||||
|
||||
std::set<Nz::String> joints;
|
||||
|
||||
bool animatedMesh = false;
|
||||
if (parameters.animated)
|
||||
{
|
||||
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
||||
{
|
||||
aiMesh* mesh = scene->mMeshes[i];
|
||||
if (mesh->HasBones()) // Inline functions can be safely called
|
||||
{
|
||||
animatedMesh = true;
|
||||
for (unsigned int j = 0; j < mesh->mNumBones; ++j)
|
||||
joints.insert(mesh->mBones[j]->mName.C_Str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (animatedMesh)
|
||||
{
|
||||
mesh->CreateSkeletal(joints.size());
|
||||
|
||||
Skeleton* skeleton = mesh->GetSkeleton();
|
||||
|
||||
// First, assign names
|
||||
unsigned int jointIndex = 0;
|
||||
for (const Nz::String& jointName : joints)
|
||||
skeleton->GetJoint(jointIndex++)->SetName(jointName);
|
||||
|
||||
ProcessJoints(scene->mRootNode, skeleton, joints);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh->CreateStatic();
|
||||
|
||||
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
||||
{
|
||||
aiMesh* iMesh = scene->mMeshes[i];
|
||||
if (!iMesh->HasBones()) // Don't process skeletal meshs
|
||||
{
|
||||
unsigned int indexCount = iMesh->mNumFaces * 3;
|
||||
unsigned int vertexCount = iMesh->mNumVertices;
|
||||
|
||||
// Index buffer
|
||||
bool largeIndices = (vertexCount > std::numeric_limits<UInt16>::max());
|
||||
|
||||
IndexBufferRef indexBuffer = IndexBuffer::New(largeIndices, indexCount, parameters.storage);
|
||||
|
||||
IndexMapper indexMapper(indexBuffer, BufferAccess_DiscardAndWrite);
|
||||
IndexIterator index = indexMapper.begin();
|
||||
|
||||
for (unsigned int j = 0; j < iMesh->mNumFaces; ++j)
|
||||
{
|
||||
aiFace& face = iMesh->mFaces[j];
|
||||
if (face.mNumIndices != 3)
|
||||
NazaraWarning("Assimp plugin: This face is not a triangle!");
|
||||
|
||||
*index++ = face.mIndices[0];
|
||||
*index++ = face.mIndices[1];
|
||||
*index++ = face.mIndices[2];
|
||||
}
|
||||
indexMapper.Unmap();
|
||||
|
||||
// Vertex buffer
|
||||
VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), vertexCount, parameters.storage);
|
||||
BufferMapper<VertexBuffer> vertexMapper(vertexBuffer, BufferAccess_WriteOnly);
|
||||
|
||||
MeshVertex* vertex = static_cast<MeshVertex*>(vertexMapper.GetPointer());
|
||||
for (unsigned int j = 0; j < vertexCount; ++j)
|
||||
{
|
||||
aiVector3D position = iMesh->mVertices[j];
|
||||
aiVector3D normal = iMesh->mNormals[j];
|
||||
aiVector3D tangent = iMesh->mTangents[j];
|
||||
aiVector3D uv = iMesh->mTextureCoords[0][j];
|
||||
|
||||
vertex->position = parameters.scale * Vector3f(position.x, position.y, position.z);
|
||||
vertex->normal.Set(normal.x, normal.y, normal.z);
|
||||
vertex->tangent.Set(tangent.x, tangent.y, tangent.z);
|
||||
vertex->uv.Set(uv.x, uv.y);
|
||||
vertex++;
|
||||
}
|
||||
|
||||
vertexMapper.Unmap();
|
||||
|
||||
// Submesh
|
||||
StaticMeshRef subMesh = StaticMesh::New(mesh);
|
||||
subMesh->Create(vertexBuffer);
|
||||
|
||||
subMesh->SetIndexBuffer(indexBuffer);
|
||||
subMesh->GenerateAABB();
|
||||
subMesh->SetMaterialIndex(iMesh->mMaterialIndex);
|
||||
|
||||
mesh->AddSubMesh(subMesh);
|
||||
}
|
||||
}
|
||||
|
||||
if (parameters.center)
|
||||
mesh->Recenter();
|
||||
}
|
||||
|
||||
aiReleaseImport(scene);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
NAZARA_EXPORT int PluginLoad()
|
||||
{
|
||||
Nz::MeshLoader::RegisterLoader(IsSupported, Check, Load);
|
||||
return 1;
|
||||
}
|
||||
|
||||
NAZARA_EXPORT void PluginUnload()
|
||||
{
|
||||
Nz::MeshLoader::UnregisterLoader(IsSupported, Check, Load);
|
||||
}
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ namespace Nz
|
|||
{
|
||||
std::unique_ptr<Stream> stream(new MemoryStream(byteArray, openMode));
|
||||
|
||||
SetStream(m_ownedStream.get());
|
||||
SetStream(stream.get());
|
||||
// SetStream reset our smart pointer, set it after calling it
|
||||
m_ownedStream = std::move(stream);
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ namespace Nz
|
|||
{
|
||||
std::unique_ptr<Stream> stream(new MemoryView(ptr, size));
|
||||
|
||||
SetStream(m_ownedStream.get());
|
||||
SetStream(stream.get());
|
||||
// SetStream reset our smart pointer, set it after calling it
|
||||
m_ownedStream = std::move(stream);
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ namespace Nz
|
|||
{
|
||||
std::unique_ptr<Stream> stream(new MemoryView(ptr, size));
|
||||
|
||||
SetStream(m_ownedStream.get());
|
||||
SetStream(stream.get());
|
||||
// SetStream reset our smart pointer, set it after calling it
|
||||
m_ownedStream = std::move(stream);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -454,6 +454,25 @@ namespace Nz
|
|||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the size of the file
|
||||
* \return true if the file size has correctly changed
|
||||
*
|
||||
* \param size The size the file should have after this call
|
||||
*
|
||||
* \remark The cursor position is not affected by this call
|
||||
* \remark The file must be open in write mode
|
||||
*/
|
||||
bool File::SetSize(UInt64 size)
|
||||
{
|
||||
NazaraLock(m_mutex)
|
||||
|
||||
NazaraAssert(IsOpen(), "File is not open");
|
||||
NazaraAssert(IsWritable(), "File is not writable");
|
||||
|
||||
return m_impl->SetSize(size);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the file path
|
||||
* \return A reference to this
|
||||
|
|
|
|||
|
|
@ -449,7 +449,7 @@ namespace Nz
|
|||
Parameter& parameter = CreateValue(name);
|
||||
parameter.type = ParameterType_String;
|
||||
|
||||
PlacementNew<String>(¶meter.value.stringVal, value);
|
||||
PlacementNew(¶meter.value.stringVal, value);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -464,7 +464,7 @@ namespace Nz
|
|||
Parameter& parameter = CreateValue(name);
|
||||
parameter.type = ParameterType_String;
|
||||
|
||||
PlacementNew<String>(¶meter.value.stringVal, value);
|
||||
PlacementNew(¶meter.value.stringVal, value);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -565,7 +565,7 @@ namespace Nz
|
|||
case ParameterType_String:
|
||||
parameter.type = ParameterType_String;
|
||||
|
||||
PlacementNew<String>(¶meter.value.stringVal, it->second.value.stringVal);
|
||||
PlacementNew(¶meter.value.stringVal, it->second.value.stringVal);
|
||||
break;
|
||||
|
||||
case ParameterType_Userdata:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Win32/FileImpl.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Win32/Time.hpp>
|
||||
#include <memory>
|
||||
|
|
@ -64,7 +65,7 @@ namespace Nz
|
|||
{
|
||||
access |= GENERIC_READ;
|
||||
|
||||
if ((mode & OpenMode_WriteOnly) == 0)
|
||||
if (mode & OpenMode_MustExit || (mode & OpenMode_WriteOnly) == 0)
|
||||
openMode |= OPEN_EXISTING;
|
||||
}
|
||||
|
||||
|
|
@ -77,6 +78,8 @@ namespace Nz
|
|||
|
||||
if (mode & OpenMode_Truncate)
|
||||
openMode |= CREATE_ALWAYS;
|
||||
else if (mode & OpenMode_MustExit)
|
||||
openMode |= OPEN_EXISTING;
|
||||
else
|
||||
openMode |= OPEN_ALWAYS;
|
||||
}
|
||||
|
|
@ -156,6 +159,31 @@ namespace Nz
|
|||
return SetFilePointerEx(m_handle, distance, nullptr, moveMethod) != 0;
|
||||
}
|
||||
|
||||
bool FileImpl::SetSize(UInt64 size)
|
||||
{
|
||||
UInt64 cursorPos = GetCursorPos();
|
||||
|
||||
CallOnExit resetCursor([this, cursorPos] ()
|
||||
{
|
||||
if (!SetCursorPos(CursorPosition_AtBegin, cursorPos))
|
||||
NazaraWarning("Failed to reset cursor position to previous position: " + Error::GetLastSystemError());
|
||||
});
|
||||
|
||||
if (!SetCursorPos(CursorPosition_AtBegin, size))
|
||||
{
|
||||
NazaraError("Failed to set file size: failed to move cursor position: " + Error::GetLastSystemError());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SetEndOfFile(m_handle))
|
||||
{
|
||||
NazaraError("Failed to set file size: " + Error::GetLastSystemError());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::size_t FileImpl::Write(const void* buffer, std::size_t size)
|
||||
{
|
||||
DWORD written = 0;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ namespace Nz
|
|||
bool Open(const String& filePath, UInt32 mode);
|
||||
std::size_t Read(void* buffer, std::size_t size);
|
||||
bool SetCursorPos(CursorPosition pos, Int64 offset);
|
||||
bool SetSize(UInt64 size);
|
||||
std::size_t Write(const void* buffer, std::size_t size);
|
||||
|
||||
FileImpl& operator=(const FileImpl&) = delete;
|
||||
|
|
|
|||
|
|
@ -634,7 +634,7 @@ namespace Nz
|
|||
void LuaInstance::PushFunction(LuaFunction func) const
|
||||
{
|
||||
LuaFunction* luaFunc = static_cast<LuaFunction*>(lua_newuserdata(m_state, sizeof(LuaFunction)));
|
||||
PlacementNew<LuaFunction>(luaFunc, std::move(func));
|
||||
PlacementNew(luaFunc, std::move(func));
|
||||
|
||||
lua_pushcclosure(m_state, ProxyFunc, 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -359,13 +359,10 @@ namespace Nz
|
|||
if (!s_defaultFont)
|
||||
{
|
||||
FontRef cabin = Font::New();
|
||||
if (!cabin->OpenFromMemory(r_cabinRegular, sizeof(r_cabinRegular)))
|
||||
{
|
||||
if (cabin->OpenFromMemory(r_cabinRegular, sizeof(r_cabinRegular)))
|
||||
s_defaultFont = cabin;
|
||||
else
|
||||
NazaraError("Failed to open default font");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
s_defaultFont = cabin;
|
||||
}
|
||||
|
||||
return s_defaultFont;
|
||||
|
|
|
|||
Loading…
Reference in New Issue