Merge branch 'master' into culling
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 24 Jun 2015 at 13:55:50
|
||||
// This file was automatically generated
|
||||
|
||||
/*
|
||||
Nazara Engine - Audio module
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 09 May 2016 at 17:07:09
|
||||
// This file was automatically generated
|
||||
|
||||
/*
|
||||
Nazara Engine - Core module
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace Nz
|
||||
class AbstractHash;
|
||||
class ByteArray;
|
||||
|
||||
template<typename F, typename Tuple> auto Apply(F&& fn, Tuple&& t);
|
||||
template<typename O, typename F, typename Tuple> auto Apply(O& object, F&& fn, Tuple&& t);
|
||||
template<typename F, typename Tuple> decltype(auto) Apply(F&& fn, Tuple&& t);
|
||||
template<typename O, typename F, typename Tuple> decltype(auto) Apply(O& object, F&& fn, Tuple&& t);
|
||||
template<typename T> ByteArray ComputeHash(HashType hash, const T& v);
|
||||
template<typename T> ByteArray ComputeHash(AbstractHash* hash, const T& v);
|
||||
template<typename T, std::size_t N> constexpr std::size_t CountOf(T(&name)[N]) noexcept;
|
||||
|
||||
@@ -19,13 +19,13 @@ namespace Nz
|
||||
{
|
||||
// http://www.cppsamples.com/common-tasks/apply-tuple-to-function.html
|
||||
template<typename F, typename Tuple, size_t... S>
|
||||
auto ApplyImplFunc(F&& fn, Tuple&& t, std::index_sequence<S...>)
|
||||
decltype(auto) ApplyImplFunc(F&& fn, Tuple&& t, std::index_sequence<S...>)
|
||||
{
|
||||
return std::forward<F>(fn)(std::get<S>(std::forward<Tuple>(t))...);
|
||||
}
|
||||
|
||||
template<typename O, typename F, typename Tuple, size_t... S>
|
||||
auto ApplyImplMethod(O& object, F&& fn, Tuple&& t, std::index_sequence<S...>)
|
||||
decltype(auto) ApplyImplMethod(O& object, F&& fn, Tuple&& t, std::index_sequence<S...>)
|
||||
{
|
||||
return (object .* std::forward<F>(fn))(std::get<S>(std::forward<Tuple>(t))...);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace Nz
|
||||
* \see Apply
|
||||
*/
|
||||
template<typename F, typename Tuple>
|
||||
auto Apply(F&& fn, Tuple&& t)
|
||||
decltype(auto) Apply(F&& fn, Tuple&& t)
|
||||
{
|
||||
constexpr std::size_t tSize = std::tuple_size<typename std::remove_reference<Tuple>::type>::value;
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Nz
|
||||
* \see Apply
|
||||
*/
|
||||
template<typename O, typename F, typename Tuple>
|
||||
auto Apply(O& object, F&& fn, Tuple&& t)
|
||||
decltype(auto) Apply(O& object, F&& fn, Tuple&& t)
|
||||
{
|
||||
constexpr std::size_t tSize = std::tuple_size<typename std::remove_reference<Tuple>::type>::value;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Nz
|
||||
bool Wait(Mutex* mutex, UInt32 timeout);
|
||||
|
||||
ConditionVariable& operator=(const ConditionVariable&) = delete;
|
||||
inline ConditionVariable& operator=(ConditionVariable&& condition) noexcept;
|
||||
ConditionVariable& operator=(ConditionVariable&& condition) noexcept;
|
||||
|
||||
private:
|
||||
ConditionVariableImpl* m_impl;
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Nz
|
||||
template<typename T> bool operator<(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator<(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
template<typename T> bool operator<=(const ObjectRef<T>, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator<=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator<=(const T& lhs, const ObjectRef<T>& rhs);
|
||||
template<typename T> bool operator<=(const ObjectRef<T>& lhs, const T& rhs);
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Nz
|
||||
while (it != Type::s_managerMap.end())
|
||||
{
|
||||
const ObjectRef<Type>& ref = it->second;
|
||||
if (ref.GetReferenceCount() == 1) // Are we the only ones to own the resource ?
|
||||
if (ref->GetReferenceCount() == 1) // Are we the only ones to own the resource ?
|
||||
{
|
||||
NazaraDebug("Purging resource from file " + ref->GetFilePath());
|
||||
Type::s_managerMap.erase(it++); // Then we erase it
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 15 Sep 2016 at 00:43:26
|
||||
// This file was automatically generated
|
||||
|
||||
/*
|
||||
Nazara Engine - Graphics module
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Nz
|
||||
m_isometricModeEnabled(false)
|
||||
{
|
||||
NazaraAssert(m_tiles.size() != 0U, "Invalid map size");
|
||||
NazaraAssert(m_tileSize.x != 0U && m_tileSize.y != 0U, "Invalid tile size");
|
||||
NazaraAssert(m_tileSize.x > 0 && m_tileSize.y > 0, "Invalid tile size");
|
||||
NazaraAssert(m_layers.size() != 0U, "Invalid material count");
|
||||
|
||||
for (Layer& layer : m_layers)
|
||||
@@ -175,7 +175,7 @@ namespace Nz
|
||||
* \param color The multiplicative color applied to the 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.
|
||||
*
|
||||
* \see EnableTiles
|
||||
@@ -253,7 +253,7 @@ namespace Nz
|
||||
Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height);
|
||||
EnableTiles(unnormalizedCoords, color, materialIndex);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \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
|
||||
*/
|
||||
inline TileMap& TileMap::operator=(const TileMap& TileMap)
|
||||
inline TileMap& TileMap::operator=(const TileMap& tileMap)
|
||||
{
|
||||
InstancedRenderable::operator=(TileMap);
|
||||
InstancedRenderable::operator=(tileMap);
|
||||
|
||||
m_layers = TileMap.m_layers;
|
||||
m_mapSize = TileMap.m_mapSize;
|
||||
m_tiles = TileMap.m_tiles;
|
||||
m_tileSize = TileMap.m_tileSize;
|
||||
m_layers = tileMap.m_layers;
|
||||
m_mapSize = tileMap.m_mapSize;
|
||||
m_tiles = tileMap.m_tiles;
|
||||
m_tileSize = tileMap.m_tileSize;
|
||||
|
||||
// We do not copy final vertices because it's highly probable that our parameters are modified and they must be regenerated
|
||||
InvalidateBoundingVolume();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 24 Jun 2015 at 13:55:50
|
||||
// This file was automatically generated
|
||||
|
||||
/*
|
||||
Nazara Engine - Lua scripting module
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Nz
|
||||
friend class LuaClass;
|
||||
|
||||
public:
|
||||
using ClassFunc = std::function<int(LuaInstance& lua, T& instance)>;
|
||||
using ClassFunc = std::function<int(LuaInstance& lua, T& instance, std::size_t argumentCount)>;
|
||||
using ClassIndexFunc = std::function<bool(LuaInstance& lua, T& instance)>;
|
||||
using ConstructorFunc = std::function<bool(LuaInstance& lua, T* instance, std::size_t argumentCount)>;
|
||||
template<typename P> using ConvertToParent = std::function<P*(T*)>;
|
||||
@@ -34,6 +34,7 @@ namespace Nz
|
||||
using StaticIndexFunc = std::function<bool(LuaInstance& lua)>;
|
||||
using StaticFunc = std::function<int(LuaInstance& lua)>;
|
||||
|
||||
LuaClass() = default;
|
||||
LuaClass(const String& name);
|
||||
|
||||
void BindDefaultConstructor();
|
||||
@@ -50,6 +51,9 @@ namespace Nz
|
||||
template<class P> void Inherit(LuaClass<P>& parent);
|
||||
template<class P> void Inherit(LuaClass<P>& parent, ConvertToParent<P> convertFunc);
|
||||
|
||||
void Reset();
|
||||
void Reset(const String& name);
|
||||
|
||||
void Register(LuaInstance& lua);
|
||||
|
||||
void PushGlobalTable(LuaInstance& lua);
|
||||
@@ -62,6 +66,19 @@ namespace Nz
|
||||
void SetStaticSetter(StaticIndexFunc getter);
|
||||
|
||||
private:
|
||||
template<typename U, bool HasDestructor>
|
||||
friend struct LuaClassImplFinalizerSetupProxy;
|
||||
|
||||
void PushClassInfo(LuaInstance& lua);
|
||||
void SetupConstructor(LuaInstance& lua);
|
||||
void SetupDefaultToString(LuaInstance& lua);
|
||||
void SetupFinalizer(LuaInstance& lua);
|
||||
void SetupGetter(LuaInstance& lua, LuaCFunction proxy);
|
||||
void SetupGlobalTable(LuaInstance& lua);
|
||||
void SetupMetatable(LuaInstance& lua);
|
||||
void SetupMethod(LuaInstance& lua, LuaCFunction proxy, const String& name, std::size_t methodIndex);
|
||||
void SetupSetter(LuaInstance& lua, LuaCFunction proxy);
|
||||
|
||||
using ParentFunc = std::function<void(LuaInstance& lua, T* instance)>;
|
||||
using InstanceGetter = std::function<T*(LuaInstance& lua)>;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// This file is part of the "Nazara Engine - Lua scripting module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Lua/LuaClass.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <type_traits>
|
||||
@@ -10,10 +11,9 @@
|
||||
namespace Nz
|
||||
{
|
||||
template<class T>
|
||||
LuaClass<T>::LuaClass(const String& name) :
|
||||
m_info(new ClassInfo)
|
||||
LuaClass<T>::LuaClass(const String& name)
|
||||
{
|
||||
m_info->name = name;
|
||||
Reset(name);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@@ -58,147 +58,37 @@ namespace Nz
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void LuaClass<T>::Reset()
|
||||
{
|
||||
m_info.reset();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void LuaClass<T>::Reset(const String& name)
|
||||
{
|
||||
m_info = std::make_shared<ClassInfo>();
|
||||
m_info->name = name;
|
||||
|
||||
m_info->instanceGetters[m_info->name] = [info = m_info] (LuaInstance& instance)
|
||||
{
|
||||
return static_cast<T*>(instance.CheckUserdata(1, info->name));
|
||||
};
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void LuaClass<T>::Register(LuaInstance& lua)
|
||||
{
|
||||
// Le ClassInfo doit rester en vie jusqu'à la fin du script
|
||||
// Obliger l'instance de LuaClass à rester en vie dans cette fin serait contraignant pour l'utilisateur
|
||||
// J'utilise donc une astuce, la stocker dans une UserData associée avec chaque fonction de la metatable du type,
|
||||
// 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
|
||||
std::shared_ptr<ClassInfo>* info = static_cast<std::shared_ptr<ClassInfo>*>(lua.PushUserdata(sizeof(std::shared_ptr<ClassInfo>)));
|
||||
PlacementNew(info, m_info);
|
||||
PushClassInfo(lua);
|
||||
|
||||
// On créé la table qui contiendra une méthode (Le finalizer) pour libérer le ClassInfo
|
||||
lua.PushTable(0, 1);
|
||||
lua.PushLightUserdata(info);
|
||||
lua.PushCFunction(InfoDestructor, 1);
|
||||
lua.SetField("__gc");
|
||||
lua.SetMetatable(-2); // La table devient la metatable de l'UserData
|
||||
// Let's create the metatable which will be associated with every instance.
|
||||
SetupMetatable(lua);
|
||||
|
||||
// Maintenant, nous allons associer l'UserData avec chaque fonction, de sorte qu'il reste en vie
|
||||
// aussi longtemps que nécessaire, et que le pointeur soit transmis à chaque méthode
|
||||
if (m_info->constructor || m_info->staticGetter || m_info->staticSetter || !m_staticMethods.empty())
|
||||
SetupGlobalTable(lua);
|
||||
|
||||
if (!lua.NewMetatable(m_info->name))
|
||||
NazaraWarning("Class \"" + m_info->name + "\" already registred in this instance");
|
||||
{
|
||||
// Set the type in a __type field
|
||||
lua.PushString(m_info->name);
|
||||
lua.SetField("__type");
|
||||
|
||||
// In case a __tostring method is missing, add a default implementation returning the type
|
||||
if (m_methods.find("__tostring") == m_methods.end())
|
||||
{
|
||||
// Define the Finalizer
|
||||
lua.PushValue(1); // shared_ptr on UserData
|
||||
lua.PushCFunction(ToStringProxy, 1);
|
||||
lua.SetField("__tostring");
|
||||
}
|
||||
|
||||
// Define the Finalizer
|
||||
lua.PushValue(1);
|
||||
lua.PushCFunction(FinalizerProxy, 1);
|
||||
lua.SetField("__gc");
|
||||
|
||||
if (m_info->getter || !m_info->parentGetters.empty())
|
||||
{
|
||||
lua.PushValue(1); // shared_ptr on UserData
|
||||
lua.PushValue(-2); // Metatable
|
||||
lua.PushCFunction(GetterProxy, 2);
|
||||
}
|
||||
else
|
||||
// Optimisation, plutôt que de rediriger vers une fonction C qui ne fera rien d'autre que rechercher
|
||||
// dans la table, nous envoyons directement la table, de sorte que Lua fasse directement la recherche
|
||||
// Ceci n'est possible que si nous n'avons ni getter, ni parent
|
||||
lua.PushValue(-1); // Metatable
|
||||
|
||||
lua.SetField("__index"); // Getter
|
||||
|
||||
if (m_info->setter)
|
||||
{
|
||||
lua.PushValue(1); // shared_ptr on UserData
|
||||
lua.PushCFunction(SetterProxy, 1);
|
||||
lua.SetField("__newindex"); // Setter
|
||||
}
|
||||
|
||||
m_info->methods.reserve(m_methods.size());
|
||||
for (auto& pair : m_methods)
|
||||
{
|
||||
std::size_t methodIndex = m_info->methods.size();
|
||||
m_info->methods.push_back(pair.second);
|
||||
|
||||
lua.PushValue(1); // shared_ptr on UserData
|
||||
lua.PushInteger(methodIndex);
|
||||
|
||||
lua.PushCFunction(MethodProxy, 2);
|
||||
lua.SetField(pair.first); // Method name
|
||||
}
|
||||
|
||||
m_info->instanceGetters[m_info->name] = [info = m_info] (LuaInstance& instance)
|
||||
{
|
||||
return static_cast<T*>(instance.CheckUserdata(1, info->name));
|
||||
};
|
||||
}
|
||||
lua.Pop(); // On pop la metatable
|
||||
|
||||
if (m_info->constructor || m_info->staticGetter || m_info->staticSetter || !m_info->staticMethods.empty())
|
||||
{
|
||||
// Création de l'instance globale
|
||||
lua.PushTable(); // Class = {}
|
||||
|
||||
// Création de la metatable associée à la table globale
|
||||
lua.PushTable(); // ClassMeta = {}
|
||||
|
||||
if (m_info->constructor)
|
||||
{
|
||||
lua.PushValue(1); // ClassInfo
|
||||
lua.PushCFunction(ConstructorProxy, 1);
|
||||
lua.SetField("__call"); // ClassMeta.__call = ConstructorProxy
|
||||
}
|
||||
|
||||
if (m_info->staticGetter)
|
||||
{
|
||||
lua.PushValue(1); // shared_ptr on UserData
|
||||
lua.PushValue(-2); // ClassMeta
|
||||
lua.PushCFunction(StaticGetterProxy, 2);
|
||||
}
|
||||
else
|
||||
// Optimisation, plutôt que de rediriger vers une fonction C qui ne fera rien d'autre que rechercher
|
||||
// dans la table, nous envoyons directement la table, de sorte que Lua fasse directement la recherche
|
||||
// Ceci n'est possible que si nous n'avons ni getter, ni parent
|
||||
lua.PushValue(-1); // ClassMeta
|
||||
|
||||
lua.SetField("__index"); // ClassMeta.__index = StaticGetterProxy/ClassMeta
|
||||
|
||||
if (m_info->staticSetter)
|
||||
{
|
||||
lua.PushValue(1); // shared_ptr on UserData
|
||||
lua.PushCFunction(StaticSetterProxy, 1);
|
||||
lua.SetField("__newindex"); // ClassMeta.__newindex = StaticSetterProxy
|
||||
}
|
||||
|
||||
m_info->staticMethods.reserve(m_staticMethods.size());
|
||||
for (auto& pair : m_staticMethods)
|
||||
{
|
||||
std::size_t methodIndex = m_info->staticMethods.size();
|
||||
m_info->staticMethods.push_back(pair.second);
|
||||
|
||||
lua.PushValue(1); // shared_ptr on UserData
|
||||
lua.PushInteger(methodIndex);
|
||||
|
||||
lua.PushCFunction(StaticMethodProxy, 2);
|
||||
lua.SetField(pair.first); // ClassMeta.method = StaticMethodProxy
|
||||
}
|
||||
|
||||
lua.SetMetatable(-2); // setmetatable(Class, ClassMeta)
|
||||
|
||||
lua.PushValue(-1); // Copie
|
||||
lua.SetGlobal(m_info->name); // Class
|
||||
|
||||
m_info->globalTableRef = lua.CreateReference();
|
||||
}
|
||||
lua.Pop(); // On pop l'Userdata (contenant nos informations)
|
||||
lua.Pop(); // Pop our ClassInfo, which is now referenced by all our functions
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@@ -237,9 +127,9 @@ namespace Nz
|
||||
{
|
||||
typename LuaImplMethodProxy<Args...>::template Impl<DefArgs...> handler(std::forward<DefArgs>(defArgs)...);
|
||||
|
||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object) -> 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);
|
||||
});
|
||||
@@ -251,9 +141,9 @@ namespace Nz
|
||||
{
|
||||
typename LuaImplMethodProxy<Args...>::template Impl<DefArgs...> handler(std::forward<DefArgs>(defArgs)...);
|
||||
|
||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object) -> 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);
|
||||
});
|
||||
@@ -265,9 +155,9 @@ namespace Nz
|
||||
{
|
||||
typename LuaImplMethodProxy<Args...>::template Impl<DefArgs...> handler(std::forward<DefArgs>(defArgs)...);
|
||||
|
||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object) -> 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);
|
||||
});
|
||||
@@ -279,9 +169,9 @@ namespace Nz
|
||||
{
|
||||
typename LuaImplMethodProxy<Args...>::template Impl<DefArgs...> handler(std::forward<DefArgs>(defArgs)...);
|
||||
|
||||
BindMethod(name, [func, handler] (LuaInstance& lua, T& object) -> 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);
|
||||
});
|
||||
@@ -313,7 +203,7 @@ namespace Nz
|
||||
|
||||
BindStaticMethod(name, [func, handler] (LuaInstance& lua) -> int
|
||||
{
|
||||
handler.ProcessArgs(lua);
|
||||
handler.ProcessArguments(lua);
|
||||
|
||||
return handler.Invoke(lua, func);
|
||||
});
|
||||
@@ -325,6 +215,176 @@ namespace Nz
|
||||
m_info->staticSetter = setter;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void LuaClass<T>::PushClassInfo(LuaInstance& lua)
|
||||
{
|
||||
// Our ClassInfo has to outlive the LuaClass, because we don't want to force the user to keep the LuaClass alive
|
||||
// To do that, each Registration creates a tiny shared_ptr wrapper whose life is directly managed by Lua.
|
||||
// This shared_ptr object gets pushed as a up-value for every proxy function set in the metatable.
|
||||
// This way, there is no way our ClassInfo gets freed before any instance and the global class gets destroyed.
|
||||
std::shared_ptr<ClassInfo>* info = static_cast<std::shared_ptr<ClassInfo>*>(lua.PushUserdata(sizeof(std::shared_ptr<ClassInfo>)));
|
||||
PlacementNew(info, m_info);
|
||||
|
||||
// Setup a tiny metatable to let Lua know how to destroy our ClassInfo
|
||||
lua.PushTable(0, 1);
|
||||
lua.PushLightUserdata(info);
|
||||
lua.PushCFunction(InfoDestructor, 1);
|
||||
lua.SetField("__gc");
|
||||
lua.SetMetatable(-2);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void LuaClass<T>::SetupConstructor(LuaInstance& lua)
|
||||
{
|
||||
lua.PushValue(1); // ClassInfo
|
||||
lua.PushCFunction(ConstructorProxy, 1);
|
||||
lua.SetField("__call"); // ClassMeta.__call = ConstructorProxy
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void LuaClass<T>::SetupDefaultToString(LuaInstance& lua)
|
||||
{
|
||||
lua.PushValue(1); // shared_ptr on UserData
|
||||
lua.PushCFunction(ToStringProxy, 1);
|
||||
lua.SetField("__tostring");
|
||||
}
|
||||
|
||||
template<typename T, bool HasDestructor>
|
||||
struct LuaClassImplFinalizerSetupProxy;
|
||||
|
||||
template<typename T>
|
||||
struct LuaClassImplFinalizerSetupProxy<T, true>
|
||||
{
|
||||
static void Setup(LuaInstance& lua)
|
||||
{
|
||||
lua.PushValue(1); // ClassInfo
|
||||
lua.PushCFunction(LuaClass<T>::FinalizerProxy, 1);
|
||||
lua.SetField("__gc");
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct LuaClassImplFinalizerSetupProxy<T, false>
|
||||
{
|
||||
static void Setup(LuaInstance&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
void LuaClass<T>::SetupFinalizer(LuaInstance& lua)
|
||||
{
|
||||
LuaClassImplFinalizerSetupProxy<T, std::is_destructible<T>::value>::Setup(lua);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void LuaClass<T>::SetupGetter(LuaInstance& lua, LuaCFunction proxy)
|
||||
{
|
||||
lua.PushValue(1); // ClassInfo
|
||||
lua.PushValue(-2); // Metatable
|
||||
lua.PushCFunction(proxy, 2);
|
||||
|
||||
lua.SetField("__index"); // Getter
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void LuaClass<T>::SetupGlobalTable(LuaInstance& lua)
|
||||
{
|
||||
// Create the global table
|
||||
lua.PushTable(); // Class = {}
|
||||
|
||||
// Create a metatable which will be used for our global table
|
||||
lua.PushTable(); // ClassMeta = {}
|
||||
|
||||
if (m_info->constructor)
|
||||
SetupConstructor(lua);
|
||||
|
||||
if (m_info->staticGetter)
|
||||
SetupGetter(lua, StaticGetterProxy);
|
||||
else
|
||||
{
|
||||
// Optimize by assigning the metatable instead of a search function
|
||||
lua.PushValue(-1); // Metatable
|
||||
lua.SetField("__index");
|
||||
}
|
||||
|
||||
if (m_info->staticSetter)
|
||||
SetupSetter(lua, StaticSetterProxy);
|
||||
|
||||
m_info->staticMethods.reserve(m_staticMethods.size());
|
||||
for (auto& pair : m_staticMethods)
|
||||
{
|
||||
std::size_t methodIndex = m_info->staticMethods.size();
|
||||
m_info->staticMethods.push_back(pair.second);
|
||||
|
||||
SetupMethod(lua, StaticMethodProxy, pair.first, methodIndex);
|
||||
}
|
||||
|
||||
lua.SetMetatable(-2); // setmetatable(Class, ClassMeta), pops ClassMeta
|
||||
|
||||
lua.PushValue(-1); // As CreateReference() pops the table, push a copy
|
||||
m_info->globalTableRef = lua.CreateReference();
|
||||
|
||||
lua.SetGlobal(m_info->name); // _G["Class"] = Class
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void LuaClass<T>::SetupMetatable(LuaInstance& lua)
|
||||
{
|
||||
if (!lua.NewMetatable(m_info->name))
|
||||
NazaraWarning("Class \"" + m_info->name + "\" already registred in this instance");
|
||||
{
|
||||
SetupFinalizer(lua);
|
||||
|
||||
if (m_info->getter || !m_info->parentGetters.empty())
|
||||
SetupGetter(lua, GetterProxy);
|
||||
else
|
||||
{
|
||||
// Optimize by assigning the metatable instead of a search function
|
||||
// This is only possible if we have no custom getter nor parent
|
||||
lua.PushValue(-1); // Metatable
|
||||
lua.SetField("__index");
|
||||
}
|
||||
|
||||
if (m_info->setter)
|
||||
SetupSetter(lua, SetterProxy);
|
||||
|
||||
// In case a __tostring method is missing, add a default implementation returning the class name
|
||||
if (m_methods.find("__tostring") == m_methods.end())
|
||||
SetupDefaultToString(lua);
|
||||
|
||||
m_info->methods.reserve(m_methods.size());
|
||||
for (auto& pair : m_methods)
|
||||
{
|
||||
std::size_t methodIndex = m_info->methods.size();
|
||||
m_info->methods.push_back(pair.second);
|
||||
|
||||
SetupMethod(lua, MethodProxy, pair.first, methodIndex);
|
||||
}
|
||||
}
|
||||
lua.Pop(); //< Pops the metatable, it won't be collected before it's referenced by the Lua registry.
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void LuaClass<T>::SetupMethod(LuaInstance& lua, LuaCFunction proxy, const String& name, std::size_t methodIndex)
|
||||
{
|
||||
lua.PushValue(1); // ClassInfo
|
||||
lua.PushInteger(methodIndex);
|
||||
lua.PushCFunction(proxy, 2);
|
||||
|
||||
lua.SetField(name); // Method name
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void LuaClass<T>::SetupSetter(LuaInstance& lua, LuaCFunction proxy)
|
||||
{
|
||||
lua.PushValue(1); // ClassInfo
|
||||
lua.PushCFunction(proxy, 1);
|
||||
|
||||
lua.SetField("__newindex"); // Setter
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
int LuaClass<T>::ConstructorProxy(lua_State* state)
|
||||
{
|
||||
@@ -389,7 +449,7 @@ namespace Nz
|
||||
{
|
||||
// Query from the metatable
|
||||
lua.GetMetatable(info->name); //< Metatable
|
||||
lua.PushValue(1); //< Field
|
||||
lua.PushValue(2); //< Field
|
||||
lua.GetTable(); // Metatable[Field]
|
||||
|
||||
lua.Remove(-2); // Remove Metatable
|
||||
@@ -416,7 +476,6 @@ 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));
|
||||
lua.Remove(1); //< Remove the instance from the Lua stack
|
||||
|
||||
Get(info, lua, instance);
|
||||
return 1;
|
||||
@@ -432,7 +491,7 @@ namespace Nz
|
||||
T* instance = nullptr;
|
||||
if (lua.GetMetatable(1))
|
||||
{
|
||||
LuaType type = lua.GetField("__type");
|
||||
LuaType type = lua.GetField("__name");
|
||||
if (type == LuaType_String)
|
||||
{
|
||||
String name = lua.ToString(-1);
|
||||
@@ -441,8 +500,6 @@ namespace Nz
|
||||
instance = it->second(lua);
|
||||
}
|
||||
lua.Pop(2);
|
||||
|
||||
lua.Remove(1); //< Remove the instance from the Lua stack
|
||||
}
|
||||
|
||||
if (!instance)
|
||||
@@ -451,9 +508,11 @@ namespace Nz
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::size_t argCount = lua.GetStackTop() - 1U;
|
||||
|
||||
unsigned int index = static_cast<unsigned int>(lua.ToInteger(lua.GetIndexOfUpValue(2)));
|
||||
const ClassFunc& method = info->methods[index];
|
||||
return method(lua, *instance);
|
||||
return method(lua, *instance, argCount);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@@ -465,7 +524,6 @@ namespace Nz
|
||||
const ClassIndexFunc& setter = info->setter;
|
||||
|
||||
T& instance = *static_cast<T*>(lua.CheckUserdata(1, info->name));
|
||||
lua.Remove(1); //< Remove the instance from the Lua stack
|
||||
|
||||
if (!setter(lua, instance))
|
||||
{
|
||||
|
||||
@@ -34,10 +34,10 @@ namespace Nz
|
||||
inline LuaInstance(LuaInstance&& instance) noexcept;
|
||||
~LuaInstance();
|
||||
|
||||
void ArgCheck(bool condition, unsigned int argNum, const char* error);
|
||||
void ArgCheck(bool condition, unsigned int argNum, const String& error);
|
||||
int ArgError(unsigned int argNum, const char* error);
|
||||
int ArgError(unsigned int argNum, const String& error);
|
||||
void ArgCheck(bool condition, unsigned int argNum, const char* error) const;
|
||||
void ArgCheck(bool condition, unsigned int argNum, const String& error) const;
|
||||
int ArgError(unsigned int argNum, const char* error) const;
|
||||
int ArgError(unsigned int argNum, const String& error) const;
|
||||
|
||||
bool Call(unsigned int argCount);
|
||||
bool Call(unsigned int argCount, unsigned int resultCount);
|
||||
@@ -123,6 +123,7 @@ namespace Nz
|
||||
void Pop(unsigned int n = 1U) const;
|
||||
|
||||
template<typename T> int Push(T arg) const;
|
||||
template<typename T, typename T2, typename... Args> int Push(T firstArg, T2 secondArg, Args... args) const;
|
||||
void PushBoolean(bool value) const;
|
||||
void PushCFunction(LuaCFunction func, unsigned int upvalueCount = 0) const;
|
||||
template<typename T> void PushField(const char* name, T&& arg, int tableIndex = -2) const;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Nz
|
||||
m_memoryUsage = instance.m_memoryUsage;
|
||||
m_state = instance.m_state;
|
||||
m_timeLimit = instance.m_timeLimit;
|
||||
|
||||
|
||||
instance.m_state = nullptr;
|
||||
|
||||
return *this;
|
||||
@@ -209,6 +209,24 @@ namespace Nz
|
||||
return LuaImplReplyVal(instance, val, TypeTag<T>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<!std::is_arithmetic<T>::value && !std::is_enum<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<T&>)
|
||||
{
|
||||
return LuaImplReplyVal(instance, std::move(val), TypeTag<T>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<!std::is_arithmetic<T>::value && !std::is_enum<T>::value, int> LuaImplReplyVal(const LuaInstance& instance, T val, TypeTag<const T&>)
|
||||
{
|
||||
return LuaImplReplyVal(instance, std::move(val), TypeTag<T>());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
int LuaImplReplyVal(const LuaInstance& instance, T&& val, TypeTag<T&&>)
|
||||
{
|
||||
return LuaImplReplyVal(instance, std::forward<T>(val), TypeTag<T>());
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, std::string&& val, TypeTag<std::string>)
|
||||
{
|
||||
instance.PushString(val.c_str(), val.size());
|
||||
@@ -266,7 +284,7 @@ namespace Nz
|
||||
template<std::size_t N, std::size_t FirstDefArg, typename ArgType, typename ArgContainer, typename DefArgContainer>
|
||||
static unsigned int Process(const LuaInstance& instance, unsigned int argIndex, ArgContainer& args, DefArgContainer& defArgs)
|
||||
{
|
||||
return LuaImplQueryArg(instance, argIndex, &std::get<N>(args), std::get<std::tuple_size<DefArgContainer>() - N + FirstDefArg - 1>(defArgs), TypeTag<ArgType>());
|
||||
return LuaImplQueryArg(instance, argIndex, &std::get<N>(args), std::get<FirstDefArg + std::tuple_size<DefArgContainer>() - N - 1>(defArgs), TypeTag<ArgType>());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -302,7 +320,7 @@ namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
void ProcessArgs(const LuaInstance& instance) const
|
||||
void ProcessArguments(const LuaInstance& instance) const
|
||||
{
|
||||
m_index = 1;
|
||||
ProcessArgs<0, Args...>(instance);
|
||||
@@ -373,9 +391,9 @@ namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
void ProcessArgs(const LuaInstance& instance) const
|
||||
void ProcessArguments(const LuaInstance& instance) const
|
||||
{
|
||||
m_index = 1;
|
||||
m_index = 2; //< 1 being the instance
|
||||
ProcessArgs<0, Args...>(instance);
|
||||
}
|
||||
|
||||
@@ -394,6 +412,19 @@ namespace Nz
|
||||
return LuaImplReplyVal(instance, std::move(Apply(object, func, m_args)), TypeTag<decltype(Apply(object, func, m_args))>());
|
||||
}
|
||||
|
||||
template<typename T, typename P>
|
||||
std::enable_if_t<std::is_base_of<P, T>::value, int> Invoke(const LuaInstance& instance, T& object, T&(P::*func)(Args...)) const
|
||||
{
|
||||
T& r = Apply(object, func, m_args);
|
||||
if (&r == &object)
|
||||
{
|
||||
instance.PushValue(1); //< Userdata
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return LuaImplReplyVal(instance, r, TypeTag<T&>());
|
||||
}
|
||||
|
||||
template<typename T, typename P>
|
||||
std::enable_if_t<std::is_base_of<P, T>::value, int> Invoke(const LuaInstance& instance, const T& object, void(P::*func)(Args...) const) const
|
||||
{
|
||||
@@ -409,11 +440,22 @@ namespace Nz
|
||||
return LuaImplReplyVal(instance, std::move(Apply(object, func, m_args)), TypeTag<decltype(Apply(object, func, m_args))>());
|
||||
}
|
||||
|
||||
template<typename T, typename P>
|
||||
std::enable_if_t<std::is_base_of<P, T>::value, int> Invoke(const LuaInstance& instance, const T& object, const T&(P::*func)(Args...) const) const
|
||||
{
|
||||
const T& r = Apply(object, func, m_args);
|
||||
if (&r == &object)
|
||||
{
|
||||
instance.PushValue(1); //< Userdata
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return LuaImplReplyVal(instance, r, TypeTag<T&>());
|
||||
}
|
||||
|
||||
template<typename T, typename P>
|
||||
std::enable_if_t<std::is_base_of<P, typename PointedType<T>::type>::value, int> Invoke(const LuaInstance& instance, T& object, void(P::*func)(Args...)) const
|
||||
{
|
||||
NazaraUnused(instance);
|
||||
|
||||
if (!object)
|
||||
{
|
||||
instance.Error("Invalid object");
|
||||
@@ -436,11 +478,28 @@ namespace Nz
|
||||
return LuaImplReplyVal(instance, std::move(Apply(*object, func, m_args)), TypeTag<decltype(Apply(*object, func, m_args))>());
|
||||
}
|
||||
|
||||
template<typename T, typename P>
|
||||
std::enable_if_t<std::is_base_of<P, typename PointedType<T>::type>::value, int> Invoke(const LuaInstance& instance, T& object, typename PointedType<T>::type&(P::*func)(Args...) const) const
|
||||
{
|
||||
if (!object)
|
||||
{
|
||||
instance.Error("Invalid object");
|
||||
return 0;
|
||||
}
|
||||
|
||||
const typename PointedType<T>::type& r = Apply(*object, func, m_args);
|
||||
if (&r == &*object)
|
||||
{
|
||||
instance.PushValue(1); //< Userdata
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return LuaImplReplyVal(instance, r, TypeTag<T&>());
|
||||
}
|
||||
|
||||
template<typename T, typename P>
|
||||
std::enable_if_t<std::is_base_of<P, typename PointedType<T>::type>::value, int> Invoke(const LuaInstance& instance, const T& object, void(P::*func)(Args...) const) const
|
||||
{
|
||||
NazaraUnused(instance);
|
||||
|
||||
if (!object)
|
||||
{
|
||||
instance.Error("Invalid object");
|
||||
@@ -463,6 +522,25 @@ namespace Nz
|
||||
return LuaImplReplyVal(instance, std::move(Apply(*object, func, m_args)), TypeTag<decltype(Apply(*object, func, m_args))>());
|
||||
}
|
||||
|
||||
template<typename T, typename P>
|
||||
std::enable_if_t<std::is_base_of<P, typename PointedType<T>::type>::value, int> Invoke(const LuaInstance& instance, const T& object, const typename PointedType<T>::type&(P::*func)(Args...) const) const
|
||||
{
|
||||
if (!object)
|
||||
{
|
||||
instance.Error("Invalid object");
|
||||
return 0;
|
||||
}
|
||||
|
||||
const typename PointedType<T>::type& r = Apply(*object, func, m_args);
|
||||
if (&r == &*object)
|
||||
{
|
||||
instance.PushValue(1); //< Userdata
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return LuaImplReplyVal(instance, r, TypeTag<T&>());
|
||||
}
|
||||
|
||||
private:
|
||||
using ArgContainer = std::tuple<std::remove_cv_t<std::remove_reference_t<Args>>...>;
|
||||
using DefArgContainer = std::tuple<std::remove_cv_t<std::remove_reference_t<DefArgs>>...>;
|
||||
@@ -606,6 +684,16 @@ namespace Nz
|
||||
return LuaImplReplyVal(*this, std::move(arg), TypeTag<T>());
|
||||
}
|
||||
|
||||
template<typename T, typename T2, typename... Args>
|
||||
int LuaInstance::Push(T firstArg, T2 secondArg, Args... args) const
|
||||
{
|
||||
int valCount = 0;
|
||||
valCount += Push(std::move(firstArg));
|
||||
valCount += Push(secondArg, std::forward<Args>(args)...);
|
||||
|
||||
return valCount;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void LuaInstance::PushField(const char* name, T&& arg, int tableIndex) const
|
||||
{
|
||||
@@ -626,7 +714,7 @@ namespace Nz
|
||||
|
||||
PushFunction([func, handler] (LuaInstance& lua) -> int
|
||||
{
|
||||
handler.ProcessArgs(lua);
|
||||
handler.ProcessArguments(lua);
|
||||
|
||||
return handler.Invoke(lua, func);
|
||||
});
|
||||
@@ -648,7 +736,7 @@ namespace Nz
|
||||
template<typename T>
|
||||
void LuaInstance::PushInstance(const char* tname, const T& instance) const
|
||||
{
|
||||
T* userdata = static_cast<T*>(PushUserdata(sizeof(T*)));
|
||||
T* userdata = static_cast<T*>(PushUserdata(sizeof(T)));
|
||||
PlacementNew(userdata, instance);
|
||||
|
||||
SetMetatable(tname);
|
||||
@@ -657,7 +745,7 @@ namespace Nz
|
||||
template<typename T>
|
||||
void LuaInstance::PushInstance(const char* tname, T&& instance) const
|
||||
{
|
||||
T* userdata = static_cast<T*>(PushUserdata(sizeof(T*)));
|
||||
T* userdata = static_cast<T*>(PushUserdata(sizeof(T)));
|
||||
PlacementNew(userdata, std::move(instance));
|
||||
|
||||
SetMetatable(tname);
|
||||
@@ -666,7 +754,7 @@ namespace Nz
|
||||
template<typename T, typename... Args>
|
||||
void LuaInstance::PushInstance(const char* tname, Args&&... args) const
|
||||
{
|
||||
T* userdata = static_cast<T*>(PushUserdata(sizeof(T*)));
|
||||
T* userdata = static_cast<T*>(PushUserdata(sizeof(T)));
|
||||
PlacementNew(userdata, std::forward<Args>(args)...);
|
||||
|
||||
SetMetatable(tname);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 24 Jun 2015 at 13:55:50
|
||||
// This file was automatically generated
|
||||
|
||||
/*
|
||||
Nazara Engine - Mathematics module
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace Nz
|
||||
}
|
||||
#endif
|
||||
|
||||
T* ptr = (&m11) + column*4;
|
||||
const T* ptr = (&m11) + column*4;
|
||||
return Vector4<T>(ptr);
|
||||
}
|
||||
|
||||
@@ -636,7 +636,7 @@ namespace Nz
|
||||
}
|
||||
#endif
|
||||
|
||||
T* ptr = &m11;
|
||||
const T* ptr = &m11;
|
||||
return Vector4<T>(ptr[row], ptr[row+4], ptr[row+8], ptr[row+12]);
|
||||
}
|
||||
|
||||
@@ -792,7 +792,7 @@ namespace Nz
|
||||
template<typename T>
|
||||
bool Matrix4<T>::IsAffine() const
|
||||
{
|
||||
return m14 == F(0.0) && m24 == F(0.0) && m34 == F(0.0) && m44 == F(1.0);
|
||||
return NumberEquals(m14, F(0.0)) && NumberEquals(m24, F(0.0)) && NumberEquals(m34, F(0.0)) && NumberEquals(m44, F(1.0));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -553,9 +553,9 @@ namespace Nz
|
||||
template<typename T>
|
||||
Vector3<T> Quaternion<T>::operator*(const Vector3<T>& vec) const
|
||||
{
|
||||
Vector3f quatVec(x, y, z);
|
||||
Vector3f uv = quatVec.CrossProduct(vec);
|
||||
Vector3f uuv = quatVec.CrossProduct(uv);
|
||||
Vector3<T> quatVec(x, y, z);
|
||||
Vector3<T> uv = quatVec.CrossProduct(vec);
|
||||
Vector3<T> uuv = quatVec.CrossProduct(uv);
|
||||
uv *= F(2.0) * w;
|
||||
uuv *= F(2.0);
|
||||
|
||||
|
||||
@@ -911,9 +911,9 @@ namespace Nz
|
||||
template<typename T>
|
||||
bool Vector3<T>::operator<(const Vector3& vec) const
|
||||
{
|
||||
if (x == vec.x)
|
||||
if (NumberEquals(x, vec.x))
|
||||
{
|
||||
if (y == vec.y)
|
||||
if (NumberEquals(y, vec.y))
|
||||
return z < vec.z;
|
||||
else
|
||||
return y < vec.y;
|
||||
@@ -931,10 +931,10 @@ namespace Nz
|
||||
template<typename T>
|
||||
bool Vector3<T>::operator<=(const Vector3& vec) const
|
||||
{
|
||||
if (x == vec.x)
|
||||
if (NumberEquals(x, vec.x))
|
||||
{
|
||||
if (y == vec.y)
|
||||
return z <= vec.z;
|
||||
if (NumberEquals(y, vec.y))
|
||||
return NumberEquals(z, vec.z) || z < vec.z;
|
||||
else
|
||||
return y < vec.y;
|
||||
}
|
||||
@@ -1371,7 +1371,7 @@ namespace std
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#undef F
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
@@ -843,11 +843,11 @@ namespace Nz
|
||||
template<typename T>
|
||||
bool Vector4<T>::operator<(const Vector4& vec) const
|
||||
{
|
||||
if (x == vec.x)
|
||||
if (NumberEquals(x, vec.x))
|
||||
{
|
||||
if (y == vec.y)
|
||||
if (NumberEquals(y, vec.y))
|
||||
{
|
||||
if (z == vec.z)
|
||||
if (NumberEquals(z, vec.z))
|
||||
return w < vec.w;
|
||||
else
|
||||
return z < vec.z;
|
||||
@@ -869,12 +869,12 @@ namespace Nz
|
||||
template<typename T>
|
||||
bool Vector4<T>::operator<=(const Vector4& vec) const
|
||||
{
|
||||
if (x == vec.x)
|
||||
if (NumberEquals(x, vec.x))
|
||||
{
|
||||
if (y == vec.y)
|
||||
if (NumberEquals(y, vec.y))
|
||||
{
|
||||
if (z == vec.z)
|
||||
return w <= vec.w;
|
||||
if (NumberEquals(z, vec.z))
|
||||
return NumberEquals(w, vec.w) || w < vec.w;
|
||||
else
|
||||
return z < vec.z;
|
||||
}
|
||||
@@ -1144,7 +1144,7 @@ namespace std
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#undef F
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 03 Feb 2016 at 00:06:56
|
||||
// This file was automatically generated
|
||||
|
||||
/*
|
||||
Nazara Engine - Network module
|
||||
@@ -36,7 +36,10 @@
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
#include <Nazara/Network/NetPacket.hpp>
|
||||
#include <Nazara/Network/Network.hpp>
|
||||
#include <Nazara/Network/RUdpConnection.hpp>
|
||||
#include <Nazara/Network/RUdpMessage.hpp>
|
||||
#include <Nazara/Network/SocketHandle.hpp>
|
||||
#include <Nazara/Network/SocketPoller.hpp>
|
||||
#include <Nazara/Network/TcpClient.hpp>
|
||||
#include <Nazara/Network/TcpServer.hpp>
|
||||
#include <Nazara/Network/UdpSocket.hpp>
|
||||
|
||||
@@ -380,7 +380,7 @@ namespace std
|
||||
|
||||
// This is SDBM adapted for IP addresses, tested to generate the least collisions possible
|
||||
// (It doesn't mean it cannot be improved though)
|
||||
std::size_t hash = 0;
|
||||
std::size_t h = 0;
|
||||
switch (ip.GetProtocol())
|
||||
{
|
||||
case Nz::NetProtocol_Any:
|
||||
@@ -389,20 +389,20 @@ namespace std
|
||||
|
||||
case Nz::NetProtocol_IPv4:
|
||||
{
|
||||
hash = ip.ToUInt32() + (hash << 6) + (hash << 16) - hash;
|
||||
h = ip.ToUInt32() + (h << 6) + (h << 16) - h;
|
||||
break;
|
||||
}
|
||||
case Nz::NetProtocol_IPv6:
|
||||
{
|
||||
Nz::IpAddress::IPv6 v6 = ip.ToIPv6();
|
||||
for (std::size_t i = 0; i < v6.size(); i++)
|
||||
hash = v6[i] + (hash << 6) + (hash << 16) - hash;
|
||||
h = v6[i] + (h << 6) + (h << 16) - h;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ip.GetPort() + (hash << 6) + (hash << 16) - hash;
|
||||
return ip.GetPort() + (h << 6) + (h << 16) - h;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 12 Jul 2016 at 17:44:43
|
||||
// This file was automatically generated
|
||||
|
||||
/*
|
||||
Nazara Engine - Noise module
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 14 Oct 2016 at 18:58:18
|
||||
// This file was automatically generated
|
||||
|
||||
/*
|
||||
Nazara Engine - Physics 2D module
|
||||
@@ -29,11 +29,11 @@
|
||||
#ifndef NAZARA_GLOBAL_PHYSICS2D_HPP
|
||||
#define NAZARA_GLOBAL_PHYSICS2D_HPP
|
||||
|
||||
#include <Nazara/Physics2D/PhysWorld2D.hpp>
|
||||
#include <Nazara/Physics2D/Physics2D.hpp>
|
||||
#include <Nazara/Physics2D/Collider2D.hpp>
|
||||
#include <Nazara/Physics2D/Enums.hpp>
|
||||
#include <Nazara/Physics2D/Config.hpp>
|
||||
#include <Nazara/Physics2D/Enums.hpp>
|
||||
#include <Nazara/Physics2D/Physics2D.hpp>
|
||||
#include <Nazara/Physics2D/PhysWorld2D.hpp>
|
||||
#include <Nazara/Physics2D/RigidBody2D.hpp>
|
||||
|
||||
#endif // NAZARA_GLOBAL_PHYSICS2D_HPP
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
|
||||
|
||||
// On force la valeur de MANAGE_MEMORY en mode debug
|
||||
#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS_MANAGE_MEMORY
|
||||
#undef NAZARA_PHYSICS_MANAGE_MEMORY
|
||||
#define NAZARA_PHYSICS3D_MANAGE_MEMORY 0
|
||||
#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS2D_MANAGE_MEMORY
|
||||
#undef NAZARA_PHYSICS2D_MANAGE_MEMORY
|
||||
#define NAZARA_PHYSICS2D_MANAGE_MEMORY 0
|
||||
#endif
|
||||
|
||||
#endif // NAZARA_CONFIG_CHECK_PHYSICS_HPP
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file is part of the "Nazara Engine - Physics 2D module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Physics3D/Config.hpp>
|
||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
||||
#include <Nazara/Physics2D/Config.hpp>
|
||||
#if NAZARA_PHYSICS2D_MANAGE_MEMORY
|
||||
#include <Nazara/Core/Debug/NewRedefinition.hpp>
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
|
||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
||||
#if NAZARA_PHYSICS2D_MANAGE_MEMORY
|
||||
#undef delete
|
||||
#undef new
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 14 Oct 2016 at 18:58:18
|
||||
// This file was automatically generated
|
||||
|
||||
/*
|
||||
Nazara Engine - Physics 3D module
|
||||
@@ -29,11 +29,11 @@
|
||||
#ifndef NAZARA_GLOBAL_PHYSICS3D_HPP
|
||||
#define NAZARA_GLOBAL_PHYSICS3D_HPP
|
||||
|
||||
#include <Nazara/Physics3D/PhysWorld3D.hpp>
|
||||
#include <Nazara/Physics3D/Physics3D.hpp>
|
||||
#include <Nazara/Physics3D/RigidBody3D.hpp>
|
||||
#include <Nazara/Physics3D/Enums.hpp>
|
||||
#include <Nazara/Physics3D/Config.hpp>
|
||||
#include <Nazara/Physics3D/Collider3D.hpp>
|
||||
#include <Nazara/Physics3D/Config.hpp>
|
||||
#include <Nazara/Physics3D/Enums.hpp>
|
||||
#include <Nazara/Physics3D/Physics3D.hpp>
|
||||
#include <Nazara/Physics3D/PhysWorld3D.hpp>
|
||||
#include <Nazara/Physics3D/RigidBody3D.hpp>
|
||||
|
||||
#endif // NAZARA_GLOBAL_PHYSICS3D_HPP
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
|
||||
|
||||
// On force la valeur de MANAGE_MEMORY en mode debug
|
||||
#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS_MANAGE_MEMORY
|
||||
#undef NAZARA_PHYSICS_MANAGE_MEMORY
|
||||
#if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS3D_MANAGE_MEMORY
|
||||
#undef NAZARA_PHYSICS3D_MANAGE_MEMORY
|
||||
#define NAZARA_PHYSICS3D_MANAGE_MEMORY 0
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Physics3D/Config.hpp>
|
||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
||||
#if NAZARA_PHYSICS3D_MANAGE_MEMORY
|
||||
#include <Nazara/Core/Debug/NewRedefinition.hpp>
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
|
||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
||||
#if NAZARA_PHYSICS3D_MANAGE_MEMORY
|
||||
#undef delete
|
||||
#undef new
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,6 @@ namespace Nz
|
||||
|
||||
ColliderType3D_Max = ColliderType3D_Tree
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ENUMS_PHYSICS3D_HPP
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 24 Jun 2015 at 13:55:50
|
||||
// This file was automatically generated
|
||||
|
||||
/*
|
||||
Nazara Engine - Renderer module
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <Nazara/Renderer/OpenGL.hpp>
|
||||
#include <Nazara/Renderer/RenderBuffer.hpp>
|
||||
#include <Nazara/Renderer/Renderer.hpp>
|
||||
#include <Nazara/Renderer/RenderPipeline.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Renderer/RenderTargetParameters.hpp>
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
@@ -31,7 +30,7 @@ namespace Nz
|
||||
|
||||
struct TextureImpl;
|
||||
|
||||
class NAZARA_RENDERER_API Texture : public AbstractImage, public RefCounted, public Resource
|
||||
class NAZARA_RENDERER_API Texture : public AbstractImage, public Resource
|
||||
{
|
||||
friend TextureLibrary;
|
||||
friend TextureManager;
|
||||
@@ -54,16 +53,16 @@ namespace Nz
|
||||
|
||||
void EnsureMipmapsUpdate() const;
|
||||
|
||||
unsigned int GetDepth(UInt8 level = 0) const;
|
||||
PixelFormatType GetFormat() const;
|
||||
unsigned int GetHeight(UInt8 level = 0) const;
|
||||
UInt8 GetLevelCount() const;
|
||||
UInt8 GetMaxLevel() const;
|
||||
std::size_t GetMemoryUsage() const;
|
||||
std::size_t GetMemoryUsage(UInt8 level) const;
|
||||
Vector3ui GetSize(UInt8 level = 0) const;
|
||||
ImageType GetType() const;
|
||||
unsigned int GetWidth(UInt8 level = 0) const;
|
||||
unsigned int GetDepth(UInt8 level = 0) const override;
|
||||
PixelFormatType GetFormat() const override;
|
||||
unsigned int GetHeight(UInt8 level = 0) const override;
|
||||
UInt8 GetLevelCount() const override;
|
||||
UInt8 GetMaxLevel() const override;
|
||||
std::size_t GetMemoryUsage() const override;
|
||||
std::size_t GetMemoryUsage(UInt8 level) const override;
|
||||
Vector3ui GetSize(UInt8 level = 0) const override;
|
||||
ImageType GetType() const override;
|
||||
unsigned int GetWidth(UInt8 level = 0) const override;
|
||||
|
||||
bool HasMipmaps() const;
|
||||
|
||||
@@ -102,9 +101,9 @@ namespace Nz
|
||||
bool Update(const Image& image, UInt8 level = 0);
|
||||
bool Update(const Image& image, const Boxui& box, UInt8 level = 0);
|
||||
bool Update(const Image& image, const Rectui& rect, unsigned int z = 0, UInt8 level = 0);
|
||||
bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0);
|
||||
bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0);
|
||||
bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0);
|
||||
bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override;
|
||||
bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override;
|
||||
bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override;
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 12 Jul 2016 at 17:44:43
|
||||
// This file was automatically generated
|
||||
|
||||
/*
|
||||
Nazara Engine - Utility module
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <Nazara/Utility/Cursor.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Event.hpp>
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
#include <Nazara/Utility/Font.hpp>
|
||||
#include <Nazara/Utility/FontData.hpp>
|
||||
#include <Nazara/Utility/FontGlyph.hpp>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_ABSTRACTIMAGE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
@@ -16,10 +17,16 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_UTILITY_API AbstractImage
|
||||
class AbstractImage;
|
||||
|
||||
using AbstractImageConstRef = ObjectRef<const AbstractImage>;
|
||||
using AbstractImageRef = ObjectRef<AbstractImage>;
|
||||
|
||||
class NAZARA_UTILITY_API AbstractImage : public RefCounted
|
||||
{
|
||||
public:
|
||||
AbstractImage() = default;
|
||||
inline AbstractImage(const AbstractImage& image);
|
||||
virtual ~AbstractImage();
|
||||
|
||||
UInt8 GetBytesPerPixel() const;
|
||||
@@ -43,4 +50,6 @@ namespace Nz
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/AbstractImage.inl>
|
||||
|
||||
#endif // NAZARA_IMAGE_HPP
|
||||
|
||||
16
include/Nazara/Utility/AbstractImage.inl
Normal file
16
include/Nazara/Utility/AbstractImage.inl
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/AbstractImage.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline AbstractImage::AbstractImage(const AbstractImage&) :
|
||||
RefCounted()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
@@ -47,7 +46,7 @@ namespace Nz
|
||||
using ImageRef = ObjectRef<Image>;
|
||||
using ImageSaver = ResourceSaver<Image, ImageParams>;
|
||||
|
||||
class NAZARA_UTILITY_API Image : public AbstractImage, public RefCounted, public Resource
|
||||
class NAZARA_UTILITY_API Image : public AbstractImage, public Resource
|
||||
{
|
||||
friend ImageLibrary;
|
||||
friend ImageLoader;
|
||||
|
||||
Reference in New Issue
Block a user