Merge remote-tracking branch 'origin/master' into Particle-Update

Former-commit-id: 8b2a22ff4546805cdbae394df3cdcdf4228198e5
This commit is contained in:
Lynix 2014-09-03 13:37:39 +02:00
commit 023e41512f
9 changed files with 84 additions and 30 deletions

View File

@ -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;
};

View File

@ -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
{

View File

@ -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>

View File

@ -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();

View File

@ -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)
{

View File

@ -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,

View File

@ -87,7 +87,7 @@ namespace
"void main()\n"
"{\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";
const char* vertexSource140 =
@ -102,7 +102,7 @@ namespace
"void main()\n"
"{\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";
///TODO: Remplacer ça par des ShaderNode

View File

@ -1941,8 +1941,8 @@ GLenum NzOpenGL::CubemapFace[] =
{
GL_TEXTURE_CUBE_MAP_POSITIVE_X, // nzCubemapFace_PositiveX
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_NegativeY (Inversion pour les standards OpenGL)
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, // nzCubemapFace_PositiveY
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, // nzCubemapFace_NegativeY
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, // nzCubemapFace_PositiveZ
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z // nzCubemapFace_NegativeZ
};

View File

@ -287,7 +287,7 @@ namespace
/* for each color plane */
for (int c = 0; c < 3; ++c)
{
nzUInt8* ptr = &pixels[y * width * 4];
nzUInt8* ptr = &pixels[y * width * 3];
int bytes = header.bytesPerScanLine;
/* decode line number y */
@ -324,7 +324,7 @@ namespace
}
default:
NazaraError("Failed to load " + NzString::Number(bitCount) + " bitcount pcx files");
NazaraError("Unsupported " + NzString::Number(bitCount) + " bitcount for pcx files");
return false;
}