Merge remote-tracking branch 'origin/Particle-Update'
Former-commit-id: 272203af1d740dc32e9714e00e4f889db6b13350
This commit is contained in:
@@ -29,8 +29,17 @@ class NAZARA_API NzAbstractRenderQueue : NzNonCopyable
|
||||
NzAbstractRenderQueue() = default;
|
||||
virtual ~NzAbstractRenderQueue();
|
||||
|
||||
// Je ne suis vraiment pas fan du nombre de surcharges pour AddBillboards,
|
||||
// mais je n'ai pas d'autre solution tout aussi performante pour le moment...
|
||||
virtual void AddBillboard(const NzMaterial* material, const NzVector3f& position, const NzVector2f& size, const NzVector2f& sinCos = NzVector2f(0.f, 1.f), const NzColor& color = NzColor::White) = 0;
|
||||
virtual void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr = nullptr, NzSparsePtr<const NzColor> colorPtr = nullptr) = 0;
|
||||
virtual void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const float> alphaPtr) = 0;
|
||||
virtual void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr = nullptr) = 0;
|
||||
virtual void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr) = 0;
|
||||
virtual void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr = nullptr, NzSparsePtr<const NzColor> colorPtr = nullptr) = 0;
|
||||
virtual void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const float> alphaPtr) = 0;
|
||||
virtual void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr = nullptr) = 0;
|
||||
virtual void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr) = 0;
|
||||
virtual void AddDrawable(const NzDrawable* drawable) = 0;
|
||||
virtual void AddLight(const NzLight* light) = 0;
|
||||
virtual void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) = 0;
|
||||
|
||||
@@ -30,6 +30,13 @@ class NAZARA_API NzDeferredRenderQueue : public NzAbstractRenderQueue, NzResourc
|
||||
|
||||
void AddBillboard(const NzMaterial* material, const NzVector3f& position, const NzVector2f& size, const NzVector2f& sinCos = NzVector2f(0.f, 1.f), const NzColor& color = NzColor::White) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr = nullptr, NzSparsePtr<const NzColor> colorPtr = nullptr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr = nullptr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr = nullptr, NzSparsePtr<const NzColor> colorPtr = nullptr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr = nullptr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr) override;
|
||||
void AddDrawable(const NzDrawable* drawable) override;
|
||||
void AddLight(const NzLight* light) override;
|
||||
void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) override;
|
||||
|
||||
@@ -32,6 +32,13 @@ class NAZARA_API NzForwardRenderQueue : public NzAbstractRenderQueue, NzResource
|
||||
|
||||
void AddBillboard(const NzMaterial* material, const NzVector3f& position, const NzVector2f& size, const NzVector2f& sinCos = NzVector2f(0.f, 1.f), const NzColor& color = NzColor::White) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr = nullptr, NzSparsePtr<const NzColor> colorPtr = nullptr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr = nullptr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const NzVector2f> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr = nullptr, NzSparsePtr<const NzColor> colorPtr = nullptr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const NzVector2f> sinCosPtr, NzSparsePtr<const float> alphaPtr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const NzColor> colorPtr = nullptr) override;
|
||||
void AddBillboards(const NzMaterial* material, unsigned int count, NzSparsePtr<const NzVector3f> positionPtr, NzSparsePtr<const float> sizePtr, NzSparsePtr<const float> anglePtr, NzSparsePtr<const float> alphaPtr) override;
|
||||
void AddDrawable(const NzDrawable* drawable) override;
|
||||
void AddLight(const NzLight* light) override;
|
||||
void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) override;
|
||||
|
||||
@@ -55,6 +55,7 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
|
||||
void Enable(nzRendererParameter renderParameter, bool enable);
|
||||
void EnableAlphaTest(bool alphaTest);
|
||||
void EnableDepthSorting(bool depthSorting);
|
||||
void EnableLighting(bool lighting);
|
||||
void EnableTransform(bool transform);
|
||||
|
||||
@@ -90,6 +91,7 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
bool HasSpecularMap() const;
|
||||
|
||||
bool IsAlphaTestEnabled() const;
|
||||
bool IsDepthSortingEnabled() const;
|
||||
bool IsEnabled(nzRendererParameter renderParameter) const;
|
||||
bool IsLightingEnabled() const;
|
||||
bool IsTransformEnabled() const;
|
||||
@@ -163,6 +165,7 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
NzUberShaderConstRef m_uberShader;
|
||||
mutable ShaderInstance m_shaders[nzShaderFlags_Max+1];
|
||||
bool m_alphaTestEnabled;
|
||||
bool m_depthSortingEnabled;
|
||||
bool m_lightingEnabled;
|
||||
bool m_transformEnabled;
|
||||
float m_alphaThreshold;
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
template<typename T> T NzApproach(T value, T objective, T increment);
|
||||
template<typename T> constexpr T NzClamp(T value, T min, T max);
|
||||
template<typename T> constexpr T NzDegrees(T degrees);
|
||||
template<typename T> constexpr T NzFromDegrees(T degrees);
|
||||
template<typename T> constexpr T NzFromRadians(T radians);
|
||||
template<typename T> constexpr T NzDegreeToRadian(T degrees);
|
||||
unsigned int NzGetNearestPowerOfTwo(unsigned int number);
|
||||
unsigned int NzGetNumberLength(signed char number);
|
||||
@@ -40,9 +41,10 @@ template<typename T> T NzMultiplyAdd(T x, T y, T z);
|
||||
template<typename T> T NzNormalizeAngle(T angle);
|
||||
template<typename T> bool NzNumberEquals(T a, T b, T maxDifference = std::numeric_limits<T>::epsilon());
|
||||
NzString NzNumberToString(long long number, nzUInt8 radix = 10);
|
||||
template<typename T> T NzRadians(T radians);
|
||||
template<typename T> T NzRadianToDegree(T radians);
|
||||
long long NzStringToNumber(NzString str, nzUInt8 radix = 10, bool* ok = nullptr);
|
||||
template<typename T> constexpr T NzToDegrees(T angle);
|
||||
template<typename T> constexpr T NzToRadians(T angle);
|
||||
|
||||
#include <Nazara/Math/Algorithm.inl>
|
||||
|
||||
|
||||
@@ -31,7 +31,13 @@ constexpr T NzClamp(T value, T min, T max)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T NzDegrees(T degrees)
|
||||
constexpr T NzDegreeToRadian(T degrees)
|
||||
{
|
||||
return degrees * F(M_PI/180.0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T NzFromDegrees(T degrees)
|
||||
{
|
||||
#if NAZARA_MATH_ANGLE_RADIAN
|
||||
return NzDegreeToRadian(degrees);
|
||||
@@ -41,9 +47,13 @@ constexpr T NzDegrees(T degrees)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T NzDegreeToRadian(T degrees)
|
||||
constexpr T NzFromRadians(T radians)
|
||||
{
|
||||
return degrees * F(M_PI/180.0);
|
||||
#if NAZARA_MATH_ANGLE_RADIAN
|
||||
return radians;
|
||||
#else
|
||||
return NzRadianToDegree(radians);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline unsigned int NzGetNearestPowerOfTwo(unsigned int number)
|
||||
@@ -51,7 +61,7 @@ inline unsigned int NzGetNearestPowerOfTwo(unsigned int number)
|
||||
///TODO: Marquer comme constexpr en C++14
|
||||
unsigned int x = 1;
|
||||
// Tant que x est plus petit que n, on décale ses bits vers la gauche, ce qui revient à multiplier par deux
|
||||
while(x <= number)
|
||||
while (x <= number)
|
||||
x <<= 1;
|
||||
|
||||
return x;
|
||||
@@ -268,16 +278,6 @@ inline NzString NzNumberToString(long long number, nzUInt8 radix)
|
||||
return str.Reversed();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzRadians(T radians)
|
||||
{
|
||||
#if NAZARA_MATH_ANGLE_RADIAN
|
||||
return radians;
|
||||
#else
|
||||
return NzRadianToDegree(radians);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzRadianToDegree(T radians)
|
||||
{
|
||||
@@ -333,6 +333,26 @@ inline long long NzStringToNumber(NzString str, nzUInt8 radix, bool* ok)
|
||||
return (negative) ? -static_cast<long long>(total) : total;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T NzToDegrees(T angle)
|
||||
{
|
||||
#if NAZARA_MATH_ANGLE_RADIAN
|
||||
return NzRadianToDegree(angle);
|
||||
#else
|
||||
return angle;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T NzToRadians(T angle)
|
||||
{
|
||||
#if NAZARA_MATH_ANGLE_RADIAN
|
||||
return angle;
|
||||
#else
|
||||
return NzDegreeToRadian(angle);
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef F2
|
||||
#undef F
|
||||
|
||||
|
||||
@@ -265,14 +265,14 @@ NzEulerAngles<T> NzQuaternion<T>::ToEulerAngles() const
|
||||
T test = x*y + z*w;
|
||||
if (test > F(0.499))
|
||||
// singularity at north pole
|
||||
return NzEulerAngles<T>(NzDegrees(F(90.0)), NzRadians(F(2.0) * std::atan2(x, w)), F(0.0));
|
||||
return NzEulerAngles<T>(NzFromDegrees(F(90.0)), NzFromRadians(F(2.0) * std::atan2(x, w)), F(0.0));
|
||||
|
||||
if (test < F(-0.499))
|
||||
return NzEulerAngles<T>(NzDegrees(F(-90.0)), NzRadians(F(-2.0) * std::atan2(x, w)), F(0.0));
|
||||
return NzEulerAngles<T>(NzFromDegrees(F(-90.0)), NzFromRadians(F(-2.0) * std::atan2(x, w)), F(0.0));
|
||||
|
||||
return NzEulerAngles<T>(NzRadians(std::atan2(F(2.0)*x*w - F(2.0)*y*z, F(1.0) - F(2.0)*x* - F(2.0)*z*z)),
|
||||
NzRadians(std::atan2(F(2.0)*y*w - F(2.0)*x*z, F(1.0) - F(2.0)*y*y - F(2.0)*z*z)),
|
||||
NzRadians(std::asin(F(2.0)*test)));
|
||||
return NzEulerAngles<T>(NzFromRadians(std::atan2(F(2.0)*x*w - F(2.0)*y*z, F(1.0) - F(2.0)*x* - F(2.0)*z*z)),
|
||||
NzFromRadians(std::atan2(F(2.0)*y*w - F(2.0)*x*z, F(1.0) - F(2.0)*y*y - F(2.0)*z*z)),
|
||||
NzFromRadians(std::asin(F(2.0)*test)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -69,7 +69,7 @@ inline unsigned int NzVector2<unsigned int>::AbsDotProduct(const NzVector2<unsig
|
||||
template<typename T>
|
||||
T NzVector2<T>::AngleBetween(const NzVector2& vec) const
|
||||
{
|
||||
return NzRadians(std::atan2(vec.y, vec.x) - std::atan2(y, x));
|
||||
return NzFromRadians(std::atan2(vec.y, vec.x) - std::atan2(y, x));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -89,7 +89,7 @@ T NzVector3<T>::AngleBetween(const NzVector3& vec) const
|
||||
#endif
|
||||
|
||||
T alpha = DotProduct(vec)/divisor;
|
||||
return NzRadians(std::acos(NzClamp(alpha, F(-1.0), F(1.0))));
|
||||
return NzFromRadians(std::acos(NzClamp(alpha, F(-1.0), F(1.0))));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
Reference in New Issue
Block a user