Merge branch 'master' into physics3d-material
This commit is contained in:
commit
c592acfd5f
|
|
@ -58,6 +58,7 @@ Nazara Engine:
|
|||
- Update Constraint2Ds classes (Add : Ref, Library, ConstRef, New function and Update : ctors)
|
||||
- Fix LuaClass not working correctly when Lua stack wasn't empty
|
||||
- Add RigidBody2D simulation control (via EnableSimulation and IsSimulationEnabled), which allows to disable physics and collisions at will.
|
||||
- ⚠️ LuaInstance no longer load all lua libraries on construction, this is done in the new LoadLibraries method which allows you to excludes some libraries
|
||||
|
||||
Nazara Development Kit:
|
||||
- Added ImageWidget (#139)
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef NDK_PREREQUESITES_HPP
|
||||
#define NDK_PREREQUESITES_HPP
|
||||
#ifndef NDK_PREREQUISITES_HPP
|
||||
#define NDK_PREREQUISITES_HPP
|
||||
|
||||
/*!
|
||||
* \defgroup NDK (NazaraSDK) Nazara Development Kit
|
||||
|
|
@ -51,4 +51,4 @@ namespace Ndk
|
|||
using SystemIndex = Nz::UInt32;
|
||||
}
|
||||
|
||||
#endif // NDK_PREREQUESITES_HPP
|
||||
#endif // NDK_PREREQUISITES_HPP
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ namespace Ndk
|
|||
* \param addDefaultSystems Should default provided systems be used
|
||||
*/
|
||||
|
||||
inline World::World(bool addDefaultSystems)
|
||||
inline World::World(bool addDefaultSystems) :
|
||||
m_orderedSystemsUpdated(false)
|
||||
{
|
||||
if (addDefaultSystems)
|
||||
AddDefaultSystems();
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ namespace Ndk
|
|||
consoleRef.AddLine(str);
|
||||
});
|
||||
|
||||
overlay->lua.LoadLibraries();
|
||||
LuaAPI::RegisterClasses(overlay->lua);
|
||||
|
||||
// Override "print" function to add a line in the console
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ namespace Nz
|
|||
|
||||
static constexpr BitField GetFlagValue(E enumValue);
|
||||
|
||||
static constexpr BitField ValueMask = ((BitField(1) << (MaxValue + 1)) - 1);
|
||||
static constexpr BitField ValueMask = BitField((UInt64(1) << (MaxValue + 1)) - 1);
|
||||
|
||||
private:
|
||||
BitField m_value;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#ifndef NAZARA_ENUMS_LUA_HPP
|
||||
#define NAZARA_ENUMS_LUA_HPP
|
||||
|
||||
#include <Nazara/Core/Flags.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
enum LuaBindMode
|
||||
|
|
@ -26,6 +28,21 @@ namespace Nz
|
|||
LuaComparison_Max = LuaComparison_LessOrEqual
|
||||
};
|
||||
|
||||
enum LuaLib
|
||||
{
|
||||
LuaLib_Coroutine,
|
||||
LuaLib_Debug,
|
||||
LuaLib_Math,
|
||||
LuaLib_Io,
|
||||
LuaLib_Package,
|
||||
LuaLib_Os,
|
||||
LuaLib_String,
|
||||
LuaLib_Table,
|
||||
LuaLib_Utf8,
|
||||
|
||||
LuaLib_Max = LuaLib_Utf8
|
||||
};
|
||||
|
||||
enum LuaOperation
|
||||
{
|
||||
LuaOperation_Addition,
|
||||
|
|
@ -61,6 +78,16 @@ namespace Nz
|
|||
|
||||
LuaType_Max = LuaType_Userdata
|
||||
};
|
||||
|
||||
template<>
|
||||
struct EnumAsFlags<LuaLib>
|
||||
{
|
||||
static constexpr LuaLib max = LuaLib_Max;
|
||||
};
|
||||
|
||||
using LuaLibFlags = Flags<LuaLib>;
|
||||
|
||||
constexpr LuaLibFlags LuaLib_All = LuaLibFlags(LuaLibFlags::ValueMask);
|
||||
}
|
||||
|
||||
#endif // NAZARA_ENUMS_LUA_HPP
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Lua/Enums.hpp>
|
||||
#include <Nazara/Lua/LuaState.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
|
|
@ -29,6 +30,8 @@ namespace Nz
|
|||
inline std::size_t GetMemoryUsage() const;
|
||||
inline UInt32 GetTimeLimit() const;
|
||||
|
||||
void LoadLibraries(LuaLibFlags libFlags = LuaLib_All);
|
||||
|
||||
inline void SetMemoryLimit(std::size_t memoryLimit);
|
||||
inline void SetTimeLimit(UInt32 limit);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef NAZARA_PREREQUESITES_HPP
|
||||
#define NAZARA_PREREQUESITES_HPP
|
||||
#ifndef NAZARA_PREREQUISITES_HPP
|
||||
#define NAZARA_PREREQUISITES_HPP
|
||||
|
||||
// Try to identify the compiler
|
||||
#if defined(__BORLANDC__)
|
||||
|
|
@ -179,4 +179,4 @@ namespace Nz
|
|||
typedef uint64_t UInt64;
|
||||
}
|
||||
|
||||
#endif // NAZARA_PREREQUESITES_HPP
|
||||
#endif // NAZARA_PREREQUISITES_HPP
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue