Merge remote-tracking branch 'origin/master' into Particle-Update
Former-commit-id: 8b2a22ff4546805cdbae394df3cdcdf4228198e5
This commit is contained in:
@@ -10,21 +10,34 @@
|
||||
///FIXME: Est-ce que SparsePtr est vraiment le meilleur nom pour cette classe ?
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
template<typename T>
|
||||
class NzSparsePtr
|
||||
{
|
||||
public:
|
||||
using BytePtr = typename std::conditional<std::is_const<T>::value, const nzUInt8*, nzUInt8*>::type;
|
||||
using VoidPtr = typename std::conditional<std::is_const<T>::value, const void*, void*>::type;
|
||||
|
||||
NzSparsePtr();
|
||||
NzSparsePtr(void* ptr, unsigned int stride);
|
||||
NzSparsePtr(T* ptr);
|
||||
NzSparsePtr(VoidPtr ptr, unsigned int stride);
|
||||
NzSparsePtr(const NzSparsePtr& ptr) = default;
|
||||
~NzSparsePtr() = default;
|
||||
|
||||
void* Get() const;
|
||||
VoidPtr GetPtr() const;
|
||||
unsigned int GetStride() const;
|
||||
void Set(void* ptr);
|
||||
|
||||
void Reset();
|
||||
void Reset(T* ptr);
|
||||
void Reset(VoidPtr ptr, unsigned int stride);
|
||||
void Reset(const NzSparsePtr& ptr);
|
||||
|
||||
void SetPtr(VoidPtr ptr);
|
||||
void SetStride(unsigned int stride);
|
||||
|
||||
operator bool() const;
|
||||
operator T*() const;
|
||||
T& operator*() const;
|
||||
T& operator->() const;
|
||||
T& operator[](unsigned int index) const;
|
||||
@@ -51,7 +64,7 @@ class NzSparsePtr
|
||||
NzSparsePtr& operator=(const NzSparsePtr& ptr) = default;
|
||||
|
||||
private:
|
||||
nzUInt8* m_ptr;
|
||||
BytePtr m_ptr;
|
||||
unsigned int m_stride;
|
||||
};
|
||||
|
||||
|
||||
@@ -5,21 +5,25 @@
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>::NzSparsePtr() :
|
||||
m_ptr(nullptr),
|
||||
m_stride(0)
|
||||
NzSparsePtr<T>::NzSparsePtr()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>::NzSparsePtr(void* ptr, unsigned int stride)
|
||||
NzSparsePtr<T>::NzSparsePtr(T* ptr)
|
||||
{
|
||||
Set(ptr);
|
||||
SetStride(stride);
|
||||
Reset(ptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void* NzSparsePtr<T>::Get() const
|
||||
NzSparsePtr<T>::NzSparsePtr(VoidPtr ptr, unsigned int stride)
|
||||
{
|
||||
Reset(ptr, stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename NzSparsePtr<T>::VoidPtr NzSparsePtr<T>::GetPtr() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
@@ -31,9 +35,37 @@ unsigned int NzSparsePtr<T>::GetStride() const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::Set(void* ptr)
|
||||
void NzSparsePtr<T>::Reset()
|
||||
{
|
||||
m_ptr = reinterpret_cast<nzUInt8*>(ptr);
|
||||
SetPtr(nullptr);
|
||||
SetStride(0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::Reset(T* ptr)
|
||||
{
|
||||
SetPtr(ptr);
|
||||
SetStride(sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::Reset(VoidPtr ptr, unsigned int stride)
|
||||
{
|
||||
SetPtr(ptr);
|
||||
SetStride(stride);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::Reset(const NzSparsePtr& ptr)
|
||||
{
|
||||
SetPtr(ptr.GetPtr());
|
||||
SetStride(ptr.GetStride());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzSparsePtr<T>::SetPtr(VoidPtr ptr)
|
||||
{
|
||||
m_ptr = reinterpret_cast<BytePtr>(ptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -42,6 +74,18 @@ void NzSparsePtr<T>::SetStride(unsigned int stride)
|
||||
m_stride = stride;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>::operator bool() const
|
||||
{
|
||||
return m_ptr != nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSparsePtr<T>::operator T*() const
|
||||
{
|
||||
return reinterpret_cast<T*>(m_ptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzSparsePtr<T>::operator*() const
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef NAZARA_GLOBAL_MATH_HPP
|
||||
#define NAZARA_GLOBAL_MATH_HPP
|
||||
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <Nazara/Math/Algorithm.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
|
||||
@@ -76,6 +76,7 @@ template<typename T> class NzQuaternion
|
||||
|
||||
static NzQuaternion Identity();
|
||||
static NzQuaternion Lerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation);
|
||||
static NzQuaternion Normalize(const NzQuaternion& quat, T* length = nullptr);
|
||||
static NzQuaternion RotationBetween(const NzVector3<T>& from, const NzVector3<T>& to);
|
||||
static NzQuaternion Slerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation);
|
||||
static NzQuaternion Zero();
|
||||
|
||||
@@ -408,6 +408,12 @@ NzQuaternion<T> NzQuaternion<T>::Lerp(const NzQuaternion& from, const NzQuaterni
|
||||
return interpolated;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::Normalize(const NzQuaternion& quat, T* length)
|
||||
{
|
||||
return quat.GetNormal(length);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzQuaternion<T> NzQuaternion<T>::RotationBetween(const NzVector3<T>& from, const NzVector3<T>& to)
|
||||
{
|
||||
|
||||
@@ -185,16 +185,6 @@ enum nzSamplerWrap
|
||||
nzSamplerWrap_Max = nzSamplerWrap_Repeat
|
||||
};
|
||||
|
||||
enum nzShaderTarget
|
||||
{
|
||||
nzShaderTarget_FullscreenQuad,
|
||||
nzShaderTarget_Model,
|
||||
nzShaderTarget_None,
|
||||
nzShaderTarget_Sprite,
|
||||
|
||||
nzShaderTarget_Max = nzShaderTarget_Sprite
|
||||
};
|
||||
|
||||
enum nzShaderUniform
|
||||
{
|
||||
nzShaderUniform_EyePosition,
|
||||
|
||||
Reference in New Issue
Block a user