Merge remote-tracking branch 'origin/master' into Particle-Update
Former-commit-id: 8b2a22ff4546805cdbae394df3cdcdf4228198e5
This commit is contained in:
commit
023e41512f
|
|
@ -10,21 +10,34 @@
|
||||||
///FIXME: Est-ce que SparsePtr est vraiment le meilleur nom pour cette classe ?
|
///FIXME: Est-ce que SparsePtr est vraiment le meilleur nom pour cette classe ?
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class NzSparsePtr
|
class NzSparsePtr
|
||||||
{
|
{
|
||||||
public:
|
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();
|
||||||
NzSparsePtr(void* ptr, unsigned int stride);
|
NzSparsePtr(T* ptr);
|
||||||
|
NzSparsePtr(VoidPtr ptr, unsigned int stride);
|
||||||
NzSparsePtr(const NzSparsePtr& ptr) = default;
|
NzSparsePtr(const NzSparsePtr& ptr) = default;
|
||||||
~NzSparsePtr() = default;
|
~NzSparsePtr() = default;
|
||||||
|
|
||||||
void* Get() const;
|
VoidPtr GetPtr() const;
|
||||||
unsigned int GetStride() 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);
|
void SetStride(unsigned int stride);
|
||||||
|
|
||||||
|
operator bool() const;
|
||||||
|
operator T*() const;
|
||||||
T& operator*() const;
|
T& operator*() const;
|
||||||
T& operator->() const;
|
T& operator->() const;
|
||||||
T& operator[](unsigned int index) const;
|
T& operator[](unsigned int index) const;
|
||||||
|
|
@ -51,7 +64,7 @@ class NzSparsePtr
|
||||||
NzSparsePtr& operator=(const NzSparsePtr& ptr) = default;
|
NzSparsePtr& operator=(const NzSparsePtr& ptr) = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nzUInt8* m_ptr;
|
BytePtr m_ptr;
|
||||||
unsigned int m_stride;
|
unsigned int m_stride;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,25 @@
|
||||||
#include <Nazara/Core/Debug.hpp>
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzSparsePtr<T>::NzSparsePtr() :
|
NzSparsePtr<T>::NzSparsePtr()
|
||||||
m_ptr(nullptr),
|
|
||||||
m_stride(0)
|
|
||||||
{
|
{
|
||||||
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzSparsePtr<T>::NzSparsePtr(void* ptr, unsigned int stride)
|
NzSparsePtr<T>::NzSparsePtr(T* ptr)
|
||||||
{
|
{
|
||||||
Set(ptr);
|
Reset(ptr);
|
||||||
SetStride(stride);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
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;
|
return m_ptr;
|
||||||
}
|
}
|
||||||
|
|
@ -31,9 +35,37 @@ unsigned int NzSparsePtr<T>::GetStride() const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
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>
|
template<typename T>
|
||||||
|
|
@ -42,6 +74,18 @@ void NzSparsePtr<T>::SetStride(unsigned int stride)
|
||||||
m_stride = 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>
|
template<typename T>
|
||||||
T& NzSparsePtr<T>::operator*() const
|
T& NzSparsePtr<T>::operator*() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
#ifndef NAZARA_GLOBAL_MATH_HPP
|
#ifndef NAZARA_GLOBAL_MATH_HPP
|
||||||
#define 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/BoundingVolume.hpp>
|
||||||
#include <Nazara/Math/Box.hpp>
|
#include <Nazara/Math/Box.hpp>
|
||||||
#include <Nazara/Math/Config.hpp>
|
#include <Nazara/Math/Config.hpp>
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ template<typename T> class NzQuaternion
|
||||||
|
|
||||||
static NzQuaternion Identity();
|
static NzQuaternion Identity();
|
||||||
static NzQuaternion Lerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation);
|
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 RotationBetween(const NzVector3<T>& from, const NzVector3<T>& to);
|
||||||
static NzQuaternion Slerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation);
|
static NzQuaternion Slerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation);
|
||||||
static NzQuaternion Zero();
|
static NzQuaternion Zero();
|
||||||
|
|
|
||||||
|
|
@ -408,6 +408,12 @@ NzQuaternion<T> NzQuaternion<T>::Lerp(const NzQuaternion& from, const NzQuaterni
|
||||||
return interpolated;
|
return interpolated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzQuaternion<T> NzQuaternion<T>::Normalize(const NzQuaternion& quat, T* length)
|
||||||
|
{
|
||||||
|
return quat.GetNormal(length);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzQuaternion<T> NzQuaternion<T>::RotationBetween(const NzVector3<T>& from, const NzVector3<T>& to)
|
NzQuaternion<T> NzQuaternion<T>::RotationBetween(const NzVector3<T>& from, const NzVector3<T>& to)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -185,16 +185,6 @@ enum nzSamplerWrap
|
||||||
nzSamplerWrap_Max = nzSamplerWrap_Repeat
|
nzSamplerWrap_Max = nzSamplerWrap_Repeat
|
||||||
};
|
};
|
||||||
|
|
||||||
enum nzShaderTarget
|
|
||||||
{
|
|
||||||
nzShaderTarget_FullscreenQuad,
|
|
||||||
nzShaderTarget_Model,
|
|
||||||
nzShaderTarget_None,
|
|
||||||
nzShaderTarget_Sprite,
|
|
||||||
|
|
||||||
nzShaderTarget_Max = nzShaderTarget_Sprite
|
|
||||||
};
|
|
||||||
|
|
||||||
enum nzShaderUniform
|
enum nzShaderUniform
|
||||||
{
|
{
|
||||||
nzShaderUniform_EyePosition,
|
nzShaderUniform_EyePosition,
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ namespace
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);\n"
|
" gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);\n"
|
||||||
" vTexCoord = vec3(VertexPosition.x, -VertexPosition.y, -VertexPosition.z);\n"
|
" vTexCoord = vec3(VertexPosition.x, VertexPosition.y, -VertexPosition.z);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
const char* vertexSource140 =
|
const char* vertexSource140 =
|
||||||
|
|
@ -102,7 +102,7 @@ namespace
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);\n"
|
" gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);\n"
|
||||||
" vTexCoord = vec3(VertexPosition.x, -VertexPosition.y, -VertexPosition.z);\n"
|
" vTexCoord = vec3(VertexPosition.x, VertexPosition.y, -VertexPosition.z);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
///TODO: Remplacer ça par des ShaderNode
|
///TODO: Remplacer ça par des ShaderNode
|
||||||
|
|
|
||||||
|
|
@ -1941,8 +1941,8 @@ GLenum NzOpenGL::CubemapFace[] =
|
||||||
{
|
{
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X, // nzCubemapFace_PositiveX
|
GL_TEXTURE_CUBE_MAP_POSITIVE_X, // nzCubemapFace_PositiveX
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_X, // nzCubemapFace_NegativeX
|
GL_TEXTURE_CUBE_MAP_NEGATIVE_X, // nzCubemapFace_NegativeX
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, // nzCubemapFace_PositiveY (Inversion pour les standards OpenGL)
|
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, // nzCubemapFace_PositiveY
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, // nzCubemapFace_NegativeY (Inversion pour les standards OpenGL)
|
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, // nzCubemapFace_NegativeY
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, // nzCubemapFace_PositiveZ
|
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, // nzCubemapFace_PositiveZ
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z // nzCubemapFace_NegativeZ
|
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z // nzCubemapFace_NegativeZ
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,7 @@ namespace
|
||||||
/* for each color plane */
|
/* for each color plane */
|
||||||
for (int c = 0; c < 3; ++c)
|
for (int c = 0; c < 3; ++c)
|
||||||
{
|
{
|
||||||
nzUInt8* ptr = &pixels[y * width * 4];
|
nzUInt8* ptr = &pixels[y * width * 3];
|
||||||
int bytes = header.bytesPerScanLine;
|
int bytes = header.bytesPerScanLine;
|
||||||
|
|
||||||
/* decode line number y */
|
/* decode line number y */
|
||||||
|
|
@ -324,7 +324,7 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
NazaraError("Failed to load " + NzString::Number(bitCount) + " bitcount pcx files");
|
NazaraError("Unsupported " + NzString::Number(bitCount) + " bitcount for pcx files");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue