Merge branch 'master' into NDK

Former-commit-id: f118c029ca94296495957816f910d412ae8a56f2
This commit is contained in:
Lynix
2015-03-18 20:44:52 +01:00
66 changed files with 1430 additions and 599 deletions

View File

@@ -8,6 +8,7 @@
template<typename T>
void NzMixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount)
{
///DOC: Le buffer d'entrée peut être le même que le buffer de sortie
// Pour éviter l'overflow, on utilise comme accumulateur un type assez grand, (u)int 64 bits pour les entiers, double pour les flottants
typedef typename std::conditional<std::is_unsigned<T>::value, nzUInt64, nzInt64>::type BiggestInt;
typedef typename std::conditional<std::is_integral<T>::value, BiggestInt, double>::type Biggest;

View File

@@ -10,7 +10,7 @@
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
#include <type_traits>
#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
#define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
// On force la valeur de MANAGE_MEMORY en mode debug
#if defined(NAZARA_DEBUG) && !NAZARA_AUDIO_MANAGE_MEMORY
@@ -18,6 +18,8 @@
#define NAZARA_AUDIO_MANAGE_MEMORY 1
#endif
CheckTypeAndVal(NAZARA_AUDIO_STREAMED_BUFFER_COUNT, integral, >, 0, " shall be a strictly positive integer");
NazaraCheckTypeAndVal(NAZARA_AUDIO_STREAMED_BUFFER_COUNT, integral, >, 0, " shall be a strictly positive integer");
#undef NazaraCheckTypeAndVal
#endif // NAZARA_CONFIG_CHECK_AUDIO_HPP

View File

@@ -4,13 +4,16 @@
#pragma once
#ifndef NAZARA_TUPLE_HPP
#define NAZARA_TUPLE_HPP
#ifndef NAZARA_ALGORITHM_CORE_HPP
#define NAZARA_ALGORITHM_CORE_HPP
#include <Nazara/Prerequesites.hpp>
#include <functional>
#include <tuple>
template<typename T> void NzHashCombine(std::size_t& seed, const T& v);
template<typename F, typename... ArgsT> void NzUnpackTuple(F func, const std::tuple<ArgsT...>& t);
#include <Nazara/Core/Tuple.inl>
#include <Nazara/Core/Algorithm.inl>
#endif // NAZARA_TUPLE_HPP
#endif // NAZARA_ALGORITHM_CORE_HPP

View File

@@ -8,6 +8,8 @@
#include <Nazara/Core/Debug.hpp>
///TODO: Améliorer l'implémentation de UnpackTuple
template<unsigned int N>
struct NzImplTupleUnpack
{
@@ -28,6 +30,23 @@ struct NzImplTupleUnpack<0>
}
};
// Algorithme venant de CityHash par Google
// http://stackoverflow.com/questions/8513911/how-to-create-a-good-hash-combine-with-64-bit-output-inspired-by-boosthash-co
template<typename T>
void NzHashCombine(std::size_t& seed, const T& v)
{
const nzUInt64 kMul = 0x9ddfea08eb382d69ULL;
std::hash<T> hasher;
nzUInt64 a = (hasher(v) ^ seed) * kMul;
a ^= (a >> 47);
nzUInt64 b = (seed ^ a) * kMul;
b ^= (b >> 47);
seed = static_cast<std::size_t>(b * kMul);
}
template<typename F, typename... ArgsT>
void NzUnpackTuple(F func, const std::tuple<ArgsT...>& t)
{

View File

@@ -148,7 +148,7 @@ inline NzColor NzColor::FromHSV(float hue, float saturation, float value)
if (NzNumberEquals(h, 6.f))
h = 0; // hue must be < 1
int i = h;
int i = static_cast<unsigned int>(h);
float v1 = value * (1.f - s);
float v2 = value * (1.f - s * (h - i));
float v3 = value * (1.f - s * (1.f - (h - i)));

View File

@@ -10,7 +10,7 @@
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
#include <type_traits>
#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
#define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
// On force la valeur de MANAGE_MEMORY en mode debug
#if defined(NAZARA_DEBUG) && !NAZARA_CORE_MANAGE_MEMORY
@@ -18,8 +18,10 @@
#define NAZARA_CORE_MANAGE_MEMORY 1
#endif
CheckTypeAndVal(NAZARA_CORE_DECIMAL_DIGITS, integral, >, 0, " shall be a strictly positive integer");
CheckTypeAndVal(NAZARA_CORE_FILE_BUFFERSIZE, integral, >, 0, " shall be a strictly positive integer");
CheckTypeAndVal(NAZARA_CORE_WINDOWS_CS_SPINLOCKS, integral, >=, 0, " shall be a positive integer");
NazaraCheckTypeAndVal(NAZARA_CORE_DECIMAL_DIGITS, integral, >, 0, " shall be a strictly positive integer");
NazaraCheckTypeAndVal(NAZARA_CORE_FILE_BUFFERSIZE, integral, >, 0, " shall be a strictly positive integer");
NazaraCheckTypeAndVal(NAZARA_CORE_WINDOWS_CS_SPINLOCKS, integral, >=, 0, " shall be a positive integer");
#undef NazaraCheckTypeAndVal
#endif // NAZARA_CONFIG_CHECK_CORE_HPP

View File

@@ -15,7 +15,8 @@
#if defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || (defined(__MIPS__) && defined(__MISPEB__)) || \
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || defined(__sparc__) || defined(__hppa__)
#define NAZARA_BIG_ENDIAN
#elif defined(__i386__) || defined(__i386) || defined(__X86__) || defined (__x86_64)
#elif defined(__i386__) || defined(__i386) || defined(__X86__) || defined (__x86_64) || defined(_M_I86) || \
defined(_M_IX86) || defined(_M_X64)
#define NAZARA_LITTLE_ENDIAN
#else
#error Failed to identify endianness, you must define either NAZARA_BIG_ENDIAN or NAZARA_LITTLE_ENDIAN

View File

@@ -7,7 +7,7 @@
#ifndef NAZARA_FUNCTOR_HPP
#define NAZARA_FUNCTOR_HPP
#include <Nazara/Core/Tuple.hpp>
#include <Nazara/Core/Algorithm.hpp>
// Inspiré du code de la SFML par Laurent Gomila

View File

@@ -14,6 +14,8 @@
class NAZARA_API NzHardwareInfo
{
public:
static void Cpuid(nzUInt32 functionId, nzUInt32 subFunctionId, nzUInt32 result[4]);
static NzString GetProcessorBrandString();
static unsigned int GetProcessorCount();
static nzProcessorVendor GetProcessorVendor();
@@ -23,6 +25,7 @@ class NAZARA_API NzHardwareInfo
static bool Initialize();
static bool IsCpuidSupported();
static bool IsInitialized();
static void Uninitialize();

View File

@@ -13,6 +13,8 @@
#include <set>
#include <unordered_map>
///TODO: Révision
class NzDynLib;
class NAZARA_API NzPluginManager

View File

@@ -50,8 +50,6 @@ class NAZARA_API NzRefCounted
private:
using ObjectListenerMap = std::unordered_map<NzObjectListener*, std::pair<int, unsigned int>>;
void RemoveObjectListenerIterator(ObjectListenerMap::iterator iterator) const;
NazaraMutexAttrib(m_mutex, mutable)
mutable ObjectListenerMap m_objectListeners;

View File

@@ -87,10 +87,10 @@ class NAZARA_API NzString : public NzHashable
const char* GetConstBuffer() const;
unsigned int GetLength() const;
unsigned int GetSize() const;
char* GetUtf8Buffer(unsigned int* size = nullptr) const;
char16_t* GetUtf16Buffer(unsigned int* size = nullptr) const;
char32_t* GetUtf32Buffer(unsigned int* size = nullptr) const;
wchar_t* GetWideBuffer(unsigned int* size = nullptr) const;
std::string GetUtf8String() const;
std::u16string GetUtf16String() const;
std::u32string GetUtf32String() const;
std::wstring GetWideString() const;
NzString GetWord(unsigned int index, nzUInt32 flags = None) const;
unsigned int GetWordPosition(unsigned int index, nzUInt32 flags = None) const;

View File

@@ -10,7 +10,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Functor.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <ostream>
#include <iosfwd>
class NzThreadImpl;

View File

@@ -10,7 +10,7 @@
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
#include <type_traits>
#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
#define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
// On force la valeur de MANAGE_MEMORY en mode debug
#if defined(NAZARA_DEBUG) && !NAZARA_GRAPHICS_MANAGE_MEMORY
@@ -18,7 +18,9 @@
#define NAZARA_GRAPHICS_MANAGE_MEMORY 1
#endif
CheckTypeAndVal(NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT, integral, >, 0, " shall be a strictly positive integer");
CheckTypeAndVal(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, integral, >, 0, " shall be a strictly positive integer");
NazaraCheckTypeAndVal(NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT, integral, >, 0, " shall be a strictly positive integer");
NazaraCheckTypeAndVal(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, integral, >, 0, " shall be a strictly positive integer");
#undef NazaraCheckTypeAndVal
#endif // NAZARA_CONFIG_CHECK_GRAPHICS_HPP

View File

@@ -109,31 +109,31 @@ class NAZARA_API NzMaterial : public NzRefCounted, public NzResource
void Reset();
bool SetAlphaMap(const NzString& name);
void SetAlphaMap(NzTexture* map);
bool SetAlphaMap(const NzString& textureName);
void SetAlphaMap(NzTextureRef alphaMap);
void SetAlphaThreshold(float alphaThreshold);
void SetAmbientColor(const NzColor& ambient);
void SetDepthFunc(nzRendererComparison depthFunc);
void SetDiffuseColor(const NzColor& diffuse);
bool SetDiffuseMap(const NzString& name);
void SetDiffuseMap(NzTexture* map);
bool SetDiffuseMap(const NzString& textureName);
void SetDiffuseMap(NzTextureRef diffuseMap);
void SetDiffuseSampler(const NzTextureSampler& sampler);
void SetDstBlend(nzBlendFunc func);
bool SetEmissiveMap(const NzString& name);
void SetEmissiveMap(NzTexture* map);
bool SetEmissiveMap(const NzString& textureName);
void SetEmissiveMap(NzTextureRef textureName);
void SetFaceCulling(nzFaceSide faceSide);
void SetFaceFilling(nzFaceFilling filling);
bool SetHeightMap(const NzString& name);
void SetHeightMap(NzTexture* map);
bool SetNormalMap(const NzString& name);
void SetNormalMap(NzTexture* map);
bool SetHeightMap(const NzString& textureName);
void SetHeightMap(NzTextureRef textureName);
bool SetNormalMap(const NzString& textureName);
void SetNormalMap(NzTextureRef textureName);
void SetRenderStates(const NzRenderStates& states);
void SetShader(const NzUberShader* uberShader);
void SetShader(NzUberShaderConstRef uberShader);
bool SetShader(const NzString& uberShaderName);
void SetShininess(float shininess);
void SetSpecularColor(const NzColor& specular);
bool SetSpecularMap(const NzString& name);
void SetSpecularMap(NzTexture* map);
bool SetSpecularMap(const NzString& textureName);
void SetSpecularMap(NzTextureRef specularMap);
void SetSpecularSampler(const NzTextureSampler& sampler);
void SetSrcBlend(nzBlendFunc func);

View File

@@ -40,14 +40,10 @@ class NAZARA_API NzModel : public NzResource, public NzSceneNode
virtual ~NzModel();
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
void AdvanceAnimation(float elapsedTime);
NzModel* Clone() const;
NzModel* Create() const;
void EnableAnimation(bool animation);
NzAnimation* GetAnimation() const;
NzMaterial* GetMaterial(const NzString& subMeshName) const;
NzMaterial* GetMaterial(unsigned int matIndex) const;
NzMaterial* GetMaterial(unsigned int skinIndex, const NzString& subMeshName) const;
@@ -57,12 +53,7 @@ class NAZARA_API NzModel : public NzResource, public NzSceneNode
unsigned int GetSkinCount() const;
NzMesh* GetMesh() const;
nzSceneNodeType GetSceneNodeType() const override;
NzSkeleton* GetSkeleton();
const NzSkeleton* GetSkeleton() const;
bool HasAnimation() const;
bool IsAnimationEnabled() const;
virtual bool IsAnimated() const;
bool IsDrawable() const;

View File

@@ -16,6 +16,7 @@
#include <Nazara/Graphics/ParticleRenderer.hpp>
#include <Nazara/Graphics/SceneNode.hpp>
#include <Nazara/Math/BoundingVolume.hpp>
#include <functional>
#include <memory>
#include <set>
#include <vector>

View File

@@ -23,7 +23,7 @@ class NAZARA_API NzSceneNode : public NzNode
public:
NzSceneNode();
NzSceneNode(const NzSceneNode& sceneNode);
NzSceneNode(NzSceneNode& sceneNode) = delete;
NzSceneNode(NzSceneNode&& sceneNode) = delete;
virtual ~NzSceneNode();
virtual void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const = 0;

View File

@@ -35,15 +35,20 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
NzVector3f GetGlobalForward() const;
NzVector3f GetGlobalRight() const;
NzVector3f GetGlobalUp() const;
const NzMatrix4f& GetInvViewProjMatrix() const;
const NzMatrix4f& GetProjectionMatrix() const;
const NzVector2f& GetSize() const;
const NzRenderTarget* GetTarget() const;
const NzRectf& GetTargetRegion() const;
const NzMatrix4f& GetViewMatrix() const;
const NzMatrix4f& GetViewProjMatrix() const;
const NzRecti& GetViewport() const;
float GetZFar() const;
float GetZNear() const;
NzVector2i MapWorldToPixel(const NzVector2f& coords);
NzVector2f MapPixelToWorld(const NzVector2i& pixel);
void SetSize(const NzVector2f& size);
void SetSize(float width, float height);
void SetTarget(const NzRenderTarget* renderTarget);
@@ -61,20 +66,26 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
bool OnRenderTargetSizeChange(const NzRenderTarget* renderTarget, void* userdata) override;
void UpdateFrustum() const;
void UpdateInvViewProjMatrix() const;
void UpdateProjectionMatrix() const;
void UpdateViewMatrix() const;
void UpdateViewProjMatrix() const;
void UpdateViewport() const;
mutable NzFrustumf m_frustum;
mutable NzMatrix4f m_invViewProjMatrix;
mutable NzMatrix4f m_projectionMatrix;
mutable NzMatrix4f m_viewMatrix;
mutable NzMatrix4f m_viewProjMatrix;
NzRectf m_targetRegion;
mutable NzRecti m_viewport;
NzVector2f m_size;
const NzRenderTarget* m_target;
mutable bool m_frustumUpdated;
mutable bool m_invViewProjMatrixUpdated;
mutable bool m_projectionMatrixUpdated;
mutable bool m_viewMatrixUpdated;
mutable bool m_viewProjMatrixUpdated;
mutable bool m_viewportUpdated;
float m_zFar;
float m_zNear;

View File

@@ -38,8 +38,8 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
void CheckAny(int index) const;
bool CheckBoolean(int index) const;
bool CheckBoolean(int index, bool defValue) const;
int CheckInteger(int index) const;
int CheckInteger(int index, int defValue) const;
long long CheckInteger(int index) const;
long long CheckInteger(int index, long long defValue) const;
double CheckNumber(int index) const;
double CheckNumber(int index, double defValue) const;
void CheckStack(int space, const char* error = nullptr) const;
@@ -47,8 +47,6 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
const char* CheckString(int index, std::size_t* length = nullptr) const;
const char* CheckString(int index, const char* defValue, std::size_t* length = nullptr) const;
void CheckType(int index, nzLuaType type) const;
unsigned int CheckUnsigned(int index) const;
unsigned int CheckUnsigned(int index, unsigned int defValue) const;
void* CheckUserdata(int index, const char* tname) const;
void* CheckUserdata(int index, const NzString& tname) const;
@@ -71,19 +69,19 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
bool ExecuteFromStream(NzInputStream& stream);
int GetAbsIndex(int index) const;
void GetField(const char* fieldName, int index = -1) const;
void GetField(const NzString& fieldName, int index = -1) const;
void GetGlobal(const char* name) const;
void GetGlobal(const NzString& name) const;
nzLuaType GetField(const char* fieldName, int index = -1) const;
nzLuaType GetField(const NzString& fieldName, int index = -1) const;
nzLuaType GetGlobal(const char* name) const;
nzLuaType GetGlobal(const NzString& name) const;
lua_State* GetInternalState() const;
NzString GetLastError() const;
nzUInt32 GetMemoryLimit() const;
nzUInt32 GetMemoryUsage() const;
void GetMetatable(const char* tname) const;
void GetMetatable(const NzString& tname) const;
nzLuaType GetMetatable(const char* tname) const;
nzLuaType GetMetatable(const NzString& tname) const;
bool GetMetatable(int index) const;
unsigned int GetStackTop() const;
void GetTable(int index = -2) const;
nzLuaType GetTable(int index = -2) const;
nzUInt32 GetTimeLimit() const;
nzLuaType GetType(int index) const;
const char* GetTypeName(nzLuaType type) const;
@@ -108,7 +106,7 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
void PushBoolean(bool value);
void PushCFunction(NzLuaCFunction func, int upvalueCount = 0);
void PushFunction(NzLuaFunction func);
void PushInteger(int value);
void PushInteger(long long value);
void PushLightUserdata(void* value);
void PushMetatable(const char* str);
void PushMetatable(const NzString& str);
@@ -118,7 +116,6 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
void PushString(const char* str);
void PushString(const NzString& str);
void PushTable(unsigned int sequenceElementCount = 0, unsigned int arrayElementCount = 0);
void PushUnsigned(unsigned int value);
void* PushUserdata(unsigned int size);
void PushValue(int index);
@@ -137,11 +134,10 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
void SetTimeLimit(nzUInt32 timeLimit);
bool ToBoolean(int index) const;
int ToInteger(int index, bool* succeeded = nullptr) const;
long long ToInteger(int index, bool* succeeded = nullptr) const;
double ToNumber(int index, bool* succeeded = nullptr) const;
const void* ToPointer(int index) const;
const char* ToString(int index, std::size_t* length = nullptr) const;
unsigned int ToUnsigned(int index, bool* succeeded = nullptr) const;
void* ToUserdata(int index) const;
void* ToUserdata(int index, const char* tname) const;
void* ToUserdata(int index, const NzString& tname) const;

View File

@@ -369,15 +369,15 @@ inline NzString NzNumberToString(long long number, nzUInt8 radix)
do
{
str += symbols[number % radix];
str.Append(symbols[number % radix]);
number /= radix;
}
while (number > 0);
if (negative)
str += '-';
str.Append('-');
return str.Reversed();
return str.Reverse();
}
template<typename T>

View File

@@ -143,7 +143,7 @@
// Détection 64 bits
#if !defined(NAZARA_PLATFORM_x64) && (defined(_WIN64) || defined(__amd64__) || defined(__x86_64__) || defined(__ia64__) || defined(__ia64) || \
defined(_M_IA64) || defined(__itanium__) || defined(__MINGW64__))
defined(_M_IA64) || defined(__itanium__) || defined(__MINGW64__) || defined(_M_AMD64) || defined (_M_X64))
#define NAZARA_PLATFORM_x64
#endif

View File

@@ -10,7 +10,7 @@
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
#include <type_traits>
#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
#define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
// On force la valeur de MANAGE_MEMORY en mode debug
#if defined(NAZARA_DEBUG) && !NAZARA_RENDERER_MANAGE_MEMORY
@@ -18,6 +18,8 @@
#define NAZARA_RENDERER_MANAGE_MEMORY 1
#endif
CheckTypeAndVal(NAZARA_RENDERER_INSTANCE_BUFFER_SIZE, integral, >, 0, " shall be a strictly positive integer");
NazaraCheckTypeAndVal(NAZARA_RENDERER_INSTANCE_BUFFER_SIZE, integral, >, 0, " shall be a strictly positive integer");
#undef NazaraCheckTypeAndVal
#endif // NAZARA_CONFIG_CHECK_RENDERER_HPP

View File

@@ -10,7 +10,7 @@
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
#include <type_traits>
#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
#define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
// On force la valeur de MANAGE_MEMORY en mode debug
#if defined(NAZARA_DEBUG) && !NAZARA_UTILITY_MANAGE_MEMORY
@@ -18,6 +18,8 @@
#define NAZARA_UTILITY_MANAGE_MEMORY 1
#endif
CheckTypeAndVal(NAZARA_UTILITY_SKINNING_MAX_WEIGHTS, integral, >, 0, " shall be a strictly positive integer");
NazaraCheckTypeAndVal(NAZARA_UTILITY_SKINNING_MAX_WEIGHTS, integral, >, 0, " shall be a strictly positive integer");
#undef NazaraCheckTypeAndVal
#endif // NAZARA_CONFIG_CHECK_UTILITY_HPP

View File

@@ -48,7 +48,6 @@ struct NAZARA_API NzMeshParams
bool IsValid() const;
};
class NzAnimation;
class NzMesh;
class NzPrimitiveList;

View File

@@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Error.hpp>
#include <algorithm>
#include <cstring>
#include <Nazara/Utility/Debug.hpp>