Added ability to give offset and gain to every noise (mappedNoise) +
bugfixes
This commit is contained in:
parent
ed200354cb
commit
a41a2ddcb3
|
|
@ -10,13 +10,12 @@
|
|||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/MappedNoiseBase.hpp>
|
||||
|
||||
template <typename T> class NAZARA_API NzAbstract2DNoise : public NzMappedNoiseBase<T>
|
||||
template <typename T> class NzAbstract2DNoise : public NzMappedNoiseBase<T>
|
||||
{
|
||||
public:
|
||||
virtual T GetBasicValue(T x, T y);
|
||||
virtual T GetMappedValue(T x, T y);
|
||||
virtual T GetValue(T x, T y, T resolution) = 0;
|
||||
virtual T GetValue(T x, T y);
|
||||
|
||||
};
|
||||
|
||||
#include <Nazara/Noise/Abstract2DNoise.inl>
|
||||
|
|
|
|||
|
|
@ -9,15 +9,15 @@
|
|||
#include <Nazara/Noise/Debug.hpp>
|
||||
|
||||
template <typename T>
|
||||
T NzAbstract2DNoise<T>::GetMappedValue(T x, T y)
|
||||
T NzAbstract2DNoise<T>::GetBasicValue(T x, T y)
|
||||
{
|
||||
return GetValue(x,y,this->m_resolution) * this->m_gain + this->m_offset;
|
||||
return this->GetValue(x,y,this->m_resolution);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T NzAbstract2DNoise<T>::GetValue(T x, T y)
|
||||
T NzAbstract2DNoise<T>::GetMappedValue(T x, T y)
|
||||
{
|
||||
return GetValue(x,y,this->m_resolution);
|
||||
return (this->GetValue(x,y,this->m_resolution) + this->m_offset) * this->m_gain;
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@
|
|||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/MappedNoiseBase.hpp>
|
||||
|
||||
template <typename T> class NAZARA_API NzAbstract3DNoise : public NzMappedNoiseBase
|
||||
template<typename T> class NzAbstract3DNoise : public NzMappedNoiseBase<T>
|
||||
{
|
||||
public:
|
||||
virtual T GetBasicValue(T x, T y, T z);
|
||||
virtual T GetMappedValue(T x, T y, T z);
|
||||
virtual T GetValue(T x, T y, T z) = 0;
|
||||
virtual T GetValue(T x, T y, T z, T resolution);
|
||||
virtual T GetValue(T x, T y, T z, T resolution) = 0;
|
||||
};
|
||||
|
||||
#include <Nazara/Noise/Abstract3DNoise.inl>
|
||||
|
|
|
|||
|
|
@ -9,15 +9,15 @@
|
|||
#include <Nazara/Noise/Debug.hpp>
|
||||
|
||||
template <typename T>
|
||||
T NzAbstract3DNoise<T>::GetMappedValue(T x, T y, T z)
|
||||
T NzAbstract3DNoise<T>::GetBasicValue(T x, T y, T z)
|
||||
{
|
||||
return GetValue(x,y,z) * m_gain + m_offset;
|
||||
return this->GetValue(x,y,z,this->m_resolution);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T NzAbstract3DNoise<T>::GetValue(T x, T y, T z, T resolution)
|
||||
T NzAbstract3DNoise<T>::GetMappedValue(T x, T y, T z)
|
||||
{
|
||||
return GetValue(x,y,z,this->m_resolution);
|
||||
return (this->GetValue(x,y,z,this->m_resolution) + this->m_offset) * this->m_gain ;
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -10,13 +10,12 @@
|
|||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/MappedNoiseBase.hpp>
|
||||
|
||||
template <typename T> class NAZARA_API NzAbstract4DNoise : public NzMappedNoiseBase
|
||||
template <typename T> class NzAbstract4DNoise : public NzMappedNoiseBase<T>
|
||||
{
|
||||
public:
|
||||
virtual T GetBasicValue(T x, T y, T z, T w);
|
||||
virtual T GetMappedValue(T x, T y, T z, T w);
|
||||
virtual T GetValue(T x, T y, T z, T w) = 0;
|
||||
virtual T GetValue(T x, T y, T z, T w, T resolution);
|
||||
|
||||
virtual T GetValue(T x, T y, T z, T w, T resolution) = 0;
|
||||
};
|
||||
|
||||
#include <Nazara/Noise/Abstract4DNoise.inl>
|
||||
|
|
|
|||
|
|
@ -9,15 +9,15 @@
|
|||
#include <Nazara/Noise/Debug.hpp>
|
||||
|
||||
template <typename T>
|
||||
T NzAbstract4DNoise<T>::GetMappedValue(T x, T y, T z, T w)
|
||||
T NzAbstract4DNoise<T>::GetBasicValue(T x, T y, T z, T w)
|
||||
{
|
||||
return GetValue(x,y,z,w) * m_gain + m_offset;
|
||||
return this->GetValue(x,y,z,w,this->m_resolution);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T NzAbstract3DNoise<T>::GetValue(T x, T y, T z, T resolution)
|
||||
T NzAbstract4DNoise<T>::GetMappedValue(T x, T y, T z, T w)
|
||||
{
|
||||
return GetValue(x,y,z,w,this->m_resolution);
|
||||
return (this->GetValue(x,y,z,w,this->m_resolution) + this->m_offset) * this->m_gain ;
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ void NzMappedNoiseBase<T>::SetResolution(T resolution)
|
|||
if (NzNumberEquals(resolution, static_cast<T>(0.0)))
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Division by zero";
|
||||
ss << __FILE__ << ':' << __LINE__ << " : resolution cannot be 0.0f";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
m_resolution = static_cast<T>(1.0)/resolution;
|
||||
m_resolution = resolution;
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <Nazara/Noise/Abstract2DNoise.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
template <typename T> class NAZARA_API NzPerlin2D : public NzAbstract2DNoise<T>, public NzNoiseBase
|
||||
template <typename T> class NzPerlin2D : public NzAbstract2DNoise<T>, public NzNoiseBase
|
||||
{
|
||||
public:
|
||||
NzPerlin2D();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <Nazara/Noise/Abstract3DNoise.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template <typename T> class NAZARA_API NzPerlin3D : public NzAbstract3DNoise<T>, public NzNoiseBase
|
||||
template <typename T> class NzPerlin3D : public NzAbstract3DNoise<T>, public NzNoiseBase
|
||||
{
|
||||
public:
|
||||
NzPerlin3D();
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ NzPerlin3D<T>::NzPerlin3D()
|
|||
template <typename T>
|
||||
T NzPerlin3D<T>::GetValue(T x, T y, T z, T resolution)
|
||||
{
|
||||
x *= resolution;
|
||||
y *= resolution;
|
||||
z *= resolution;
|
||||
x /= resolution;
|
||||
y /= resolution;
|
||||
z /= resolution;
|
||||
|
||||
x0 = fastfloor(x);
|
||||
y0 = fastfloor(y);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <Nazara/Noise/Abstract4DNoise.hpp>
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
|
||||
template <typename T> class NAZARA_API NzPerlin4D : public NzAbstract4DNoise<T>, public NzNoiseBase
|
||||
template <typename T> class NzPerlin4D : public NzAbstract4DNoise<T>, public NzNoiseBase
|
||||
{
|
||||
public:
|
||||
NzPerlin4D();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <Nazara/Noise/Abstract2DNoise.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
template <typename T> class NAZARA_API NzSimplex2D : public NzAbstract2DNoise<T>, public NzNoiseBase
|
||||
template <typename T> class NzSimplex2D : public NzAbstract2DNoise<T>, public NzNoiseBase
|
||||
{
|
||||
public:
|
||||
NzSimplex2D();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <Nazara/Noise/Abstract3DNoise.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template <typename T> class NAZARA_API NzSimplex3D : public NzAbstract3DNoise<T>, public NzNoiseBase
|
||||
template <typename T> class NzSimplex3D : public NzAbstract3DNoise<T>, public NzNoiseBase
|
||||
{
|
||||
public:
|
||||
NzSimplex3D();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <Nazara/Noise/Abstract4DNoise.hpp>
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
|
||||
template <typename T> class NAZARA_API NzSimplex4D : public NzAbstract4DNoise<T>, public NzNoiseBase
|
||||
template <typename T> class NzSimplex4D : public NzAbstract4DNoise<T>, public NzNoiseBase
|
||||
{
|
||||
public:
|
||||
NzSimplex4D();
|
||||
|
|
|
|||
Loading…
Reference in New Issue