Merge branch 'master' into physics3d-material
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <Lua/lualib.h>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
@@ -35,7 +36,6 @@ namespace Nz
|
||||
m_state = lua_newstate(MemoryAllocator, this);
|
||||
lua_atpanic(m_state, AtPanic);
|
||||
lua_sethook(m_state, TimeLimiter, LUA_MASKCOUNT, 1000);
|
||||
luaL_openlibs(m_state);
|
||||
}
|
||||
|
||||
LuaInstance::LuaInstance(LuaInstance&& instance) :
|
||||
@@ -60,6 +60,48 @@ namespace Nz
|
||||
lua_close(m_state);
|
||||
}
|
||||
|
||||
void LuaInstance::LoadLibraries(LuaLibFlags libFlags)
|
||||
{
|
||||
// From luaL_openlibs
|
||||
std::array<luaL_Reg, LuaLib_Max + 1> libs;
|
||||
std::size_t libCount = 0;
|
||||
|
||||
libs[libCount++] = { "_G", luaopen_base };
|
||||
|
||||
if (libFlags & LuaLib_Coroutine)
|
||||
libs[libCount++] = { LUA_COLIBNAME, luaopen_coroutine };
|
||||
|
||||
if (libFlags & LuaLib_Debug)
|
||||
libs[libCount++] = { LUA_DBLIBNAME, luaopen_debug };
|
||||
|
||||
if (libFlags & LuaLib_Io)
|
||||
libs[libCount++] = { LUA_IOLIBNAME, luaopen_io };
|
||||
|
||||
if (libFlags & LuaLib_Math)
|
||||
libs[libCount++] = { LUA_MATHLIBNAME, luaopen_math };
|
||||
|
||||
if (libFlags & LuaLib_Os)
|
||||
libs[libCount++] = { LUA_OSLIBNAME, luaopen_os };
|
||||
|
||||
if (libFlags & LuaLib_Package)
|
||||
libs[libCount++] = { LUA_LOADLIBNAME, luaopen_package };
|
||||
|
||||
if (libFlags & LuaLib_String)
|
||||
libs[libCount++] = { LUA_STRLIBNAME, luaopen_string };
|
||||
|
||||
if (libFlags & LuaLib_Table)
|
||||
libs[libCount++] = { LUA_TABLIBNAME, luaopen_table };
|
||||
|
||||
if (libFlags & LuaLib_Utf8)
|
||||
libs[libCount++] = { LUA_UTF8LIBNAME, luaopen_utf8 };
|
||||
|
||||
for (std::size_t i = 0; i < libCount; ++i)
|
||||
{
|
||||
luaL_requiref(m_state, libs[i].name, libs[i].func, 1);
|
||||
lua_pop(m_state, 1); /* remove lib */
|
||||
}
|
||||
}
|
||||
|
||||
LuaInstance& LuaInstance::operator=(LuaInstance&& instance)
|
||||
{
|
||||
LuaState::operator=(std::move(instance));
|
||||
|
||||
@@ -62,6 +62,8 @@ namespace Nz
|
||||
m_handle(object.m_handle),
|
||||
m_userData(object.m_userData),
|
||||
m_world(object.m_world),
|
||||
m_isRegistered(object.m_isRegistered),
|
||||
m_isSimulationEnabled(object.m_isSimulationEnabled),
|
||||
m_isStatic(object.m_isStatic),
|
||||
m_gravityFactor(object.m_gravityFactor),
|
||||
m_mass(object.m_mass)
|
||||
@@ -406,15 +408,16 @@ namespace Nz
|
||||
OnRigidBody2DMove = std::move(object.OnRigidBody2DMove);
|
||||
OnRigidBody2DRelease = std::move(object.OnRigidBody2DRelease);
|
||||
|
||||
m_handle = object.m_handle;
|
||||
m_isRegistered = object.m_isRegistered;
|
||||
m_isStatic = object.m_isStatic;
|
||||
m_geom = std::move(object.m_geom);
|
||||
m_gravityFactor = object.m_gravityFactor;
|
||||
m_mass = object.m_mass;
|
||||
m_shapes = std::move(object.m_shapes);
|
||||
m_userData = object.m_userData;
|
||||
m_world = object.m_world;
|
||||
m_handle = object.m_handle;
|
||||
m_isRegistered = object.m_isRegistered;
|
||||
m_isSimulationEnabled = object.m_isSimulationEnabled;
|
||||
m_isStatic = object.m_isStatic;
|
||||
m_geom = std::move(object.m_geom);
|
||||
m_gravityFactor = object.m_gravityFactor;
|
||||
m_mass = object.m_mass;
|
||||
m_shapes = std::move(object.m_shapes);
|
||||
m_userData = object.m_userData;
|
||||
m_world = object.m_world;
|
||||
|
||||
cpBodySetUserData(m_handle, this);
|
||||
for (cpShape* shape : m_shapes)
|
||||
|
||||
Reference in New Issue
Block a user