Noise: Fix errors/warnings
Former-commit-id: 37e946067a3324f102aabcad1f43bfdd775841a5 [formerly 04d3406dba7c84118888ba2cfdbf364f93860567] Former-commit-id: 53316c61e484c1968ddcfb7c75acc57956a054f4
This commit is contained in:
parent
b0fc1c9bf9
commit
e52656bed8
|
|
@ -3,6 +3,7 @@
|
|||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Noise/NoiseBase.hpp>
|
||||
#include <numeric>
|
||||
#include <Nazara/Noise/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
|
|
|||
|
|
@ -76,9 +76,6 @@ namespace Nz
|
|||
float Li1,Li2,Li3,Li4,Li5,Li6;
|
||||
float s[2],t[2],u[2],v[2];
|
||||
float Cx,Cy,Cz;
|
||||
float nx,ny,nz;
|
||||
|
||||
float tmp;
|
||||
float tempx,tempy,tempz;
|
||||
|
||||
xc = x * scale;
|
||||
|
|
@ -157,7 +154,6 @@ namespace Nz
|
|||
float s[4],t[4],u[4],v[4];
|
||||
float Cx,Cy,Cz,Cw;
|
||||
|
||||
float tmp;
|
||||
float tempx,tempy,tempz,tempw;
|
||||
|
||||
xc = x * scale;
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ namespace Nz
|
|||
{
|
||||
namespace
|
||||
{
|
||||
constexpr float s_SkewCoeff2D = 0.5f * (M_SQRT3 - 1.f);
|
||||
constexpr float s_UnskewCoeff2D = (3.f - M_SQRT3)/6.f;
|
||||
constexpr float s_SkewCoeff2D = 0.5f * (float(M_SQRT3) - 1.f);
|
||||
constexpr float s_UnskewCoeff2D = (3.f - float(M_SQRT3))/6.f;
|
||||
constexpr float s_SkewCoeff3D = 1.f / 3.f;
|
||||
constexpr float s_UnskewCoeff3D = 1.f / 6.f;
|
||||
constexpr float s_SkewCoeff4D = (M_SQRT5 - 1.f)/4.f;
|
||||
constexpr float s_UnskewCoeff4D = (5.f - M_SQRT5)/20.f;
|
||||
constexpr float s_SkewCoeff4D = (float(M_SQRT5) - 1.f)/4.f;
|
||||
constexpr float s_UnskewCoeff4D = (5.f - float(M_SQRT5))/20.f;
|
||||
}
|
||||
|
||||
Simplex::Simplex(unsigned int seed)
|
||||
|
|
@ -39,7 +39,7 @@ namespace Nz
|
|||
|
||||
Vector2f unskewedDistToOrigin(xc - unskewedCubeOrigin.x, yc - unskewedCubeOrigin.y);
|
||||
|
||||
Vector2f off1;
|
||||
Vector2ui off1;
|
||||
if(unskewedDistToOrigin.x > unskewedDistToOrigin.y)
|
||||
off1.Set(1, 0);
|
||||
else
|
||||
|
|
@ -47,7 +47,7 @@ namespace Nz
|
|||
|
||||
std::array<Vector2f, 3> d;
|
||||
d[0] = -unskewedDistToOrigin;
|
||||
d[1] = d[0] + off1 - Vector2f(s_UnskewCoeff2D);
|
||||
d[1] = d[0] + Vector2f(off1) - Vector2f(s_UnskewCoeff2D);
|
||||
d[2] = d[0] + Vector2f(1.f - 2.f * s_UnskewCoeff2D);
|
||||
|
||||
Vector2i offset(skewedCubeOrigin.x & 255, skewedCubeOrigin.y & 255);
|
||||
|
|
@ -248,7 +248,7 @@ namespace Nz
|
|||
|
||||
int c;
|
||||
float n1,n2,n3,n4,n5;
|
||||
float c1,c2,c3,c4,c5,c6;
|
||||
float c1,c2,c3,c4,c5;
|
||||
|
||||
float sum;
|
||||
float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz,unskewedCubeOriginw;
|
||||
|
|
@ -280,13 +280,13 @@ namespace Nz
|
|||
unskewedDistToOriginz = zc - unskewedCubeOriginz;
|
||||
unskewedDistToOriginw = wc - unskewedCubeOriginw;
|
||||
|
||||
c1 = (unskewedDistToOriginx > unskewedDistToOriginy) ? 32 : 0;
|
||||
c2 = (unskewedDistToOriginx > unskewedDistToOriginz) ? 16 : 0;
|
||||
c3 = (unskewedDistToOriginy > unskewedDistToOriginz) ? 8 : 0;
|
||||
c4 = (unskewedDistToOriginx > unskewedDistToOriginw) ? 4 : 0;
|
||||
c5 = (unskewedDistToOriginy > unskewedDistToOriginw) ? 2 : 0;
|
||||
c6 = (unskewedDistToOriginz > unskewedDistToOriginw) ? 1 : 0;
|
||||
c = c1 + c2 + c3 + c4 + c5 + c6;
|
||||
c = 0;
|
||||
c += (unskewedDistToOriginx > unskewedDistToOriginy) ? 32 : 0;
|
||||
c += (unskewedDistToOriginx > unskewedDistToOriginz) ? 16 : 0;
|
||||
c += (unskewedDistToOriginy > unskewedDistToOriginz) ? 8 : 0;
|
||||
c += (unskewedDistToOriginx > unskewedDistToOriginw) ? 4 : 0;
|
||||
c += (unskewedDistToOriginy > unskewedDistToOriginw) ? 2 : 0;
|
||||
c += (unskewedDistToOriginz > unskewedDistToOriginw) ? 1 : 0;
|
||||
|
||||
off1x = lookupTable[c][0] >= 3 ? 1 : 0;
|
||||
off1y = lookupTable[c][1] >= 3 ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ namespace Nz
|
|||
{
|
||||
static constexpr std::array<float, 4> m_functionScales =
|
||||
{
|
||||
1.f / M_SQRT2,
|
||||
0.5f / M_SQRT2,
|
||||
0.5f / M_SQRT2,
|
||||
0.5f / M_SQRT2
|
||||
1.f / float(M_SQRT2),
|
||||
0.5f / float(M_SQRT2),
|
||||
0.5f / float(M_SQRT2),
|
||||
0.5f / float(M_SQRT2)
|
||||
};
|
||||
}
|
||||
Worley::Worley() :
|
||||
|
|
@ -53,58 +53,60 @@ namespace Nz
|
|||
|
||||
SquareTest(x0,y0,xc,yc,featurePoints);
|
||||
|
||||
std::size_t functionIndex = static_cast<std::size_t>(m_function);
|
||||
|
||||
auto it = featurePoints.begin();
|
||||
std::advance(it, m_function);
|
||||
std::advance(it, functionIndex);
|
||||
|
||||
if(fractx < it->first)
|
||||
SquareTest(x0 - 1,y0,xc,yc,featurePoints);
|
||||
|
||||
it = featurePoints.begin();
|
||||
std::advance(it, m_function);
|
||||
std::advance(it, functionIndex);
|
||||
|
||||
if(1.f - fractx < it->first)
|
||||
SquareTest(x0 + 1,y0,xc,yc,featurePoints);
|
||||
|
||||
it = featurePoints.begin();
|
||||
std::advance(it, m_function);
|
||||
std::advance(it, functionIndex);
|
||||
|
||||
if(fracty < it->first)
|
||||
SquareTest(x0,y0 - 1,xc,yc,featurePoints);
|
||||
|
||||
it = featurePoints.begin();
|
||||
std::advance(it, m_function);
|
||||
std::advance(it, functionIndex);
|
||||
|
||||
if (1.f - fracty < it->first)
|
||||
SquareTest(x0,y0 + 1,xc,yc,featurePoints);
|
||||
|
||||
it = featurePoints.begin();
|
||||
std::advance(it, m_function);
|
||||
std::advance(it, functionIndex);
|
||||
|
||||
if (fractx < it->first && fracty < it->first)
|
||||
SquareTest(x0 - 1, y0 - 1,xc,yc,featurePoints);
|
||||
|
||||
it = featurePoints.begin();
|
||||
std::advance(it, m_function);
|
||||
std::advance(it, functionIndex);
|
||||
|
||||
if (1.f - fractx < it->first && fracty < it->first)
|
||||
SquareTest(x0 + 1, y0 - 1,xc,yc,featurePoints);
|
||||
|
||||
it = featurePoints.begin();
|
||||
std::advance(it, m_function);
|
||||
std::advance(it, functionIndex);
|
||||
|
||||
if (fractx < it->first && 1.f - fracty < it->first)
|
||||
SquareTest(x0 - 1, y0 + 1,xc,yc,featurePoints);
|
||||
|
||||
it = featurePoints.begin();
|
||||
std::advance(it, m_function);
|
||||
std::advance(it, functionIndex);
|
||||
|
||||
if(1.f - fractx < it->first && 1.f - fracty < it->first)
|
||||
SquareTest(x0 + 1, y0 + 1,xc,yc,featurePoints);
|
||||
|
||||
it = featurePoints.begin();
|
||||
std::advance(it, m_function);
|
||||
std::advance(it, functionIndex);
|
||||
|
||||
return it->first * m_functionScales[m_function];
|
||||
return it->first * m_functionScales[functionIndex];
|
||||
}
|
||||
|
||||
float Worley::Get(float x, float y, float z, float scale) const
|
||||
|
|
@ -127,16 +129,16 @@ namespace Nz
|
|||
int ii = xi & 255;
|
||||
int jj = yi & 255;
|
||||
|
||||
int seed = m_permutations[ii + m_permutations[jj]];
|
||||
std::size_t seed = m_permutations[ii + m_permutations[jj]];
|
||||
|
||||
//On initialise notre rng avec seed
|
||||
std::minstd_rand0 randomNumberGenerator(seed);
|
||||
std::minstd_rand0 randomNumberGenerator(static_cast<unsigned int>(seed));
|
||||
|
||||
//On prend un nombre de points à déterminer dans le cube, compris entre 1 et 8
|
||||
unsigned int m = (seed & 7) + 1;
|
||||
std::size_t m = (seed & 7) + 1;
|
||||
|
||||
//On calcule les emplacements des différents points
|
||||
for(unsigned int i(0) ; i < m ; ++i)
|
||||
for(std::size_t i(0) ; i < m; ++i)
|
||||
{
|
||||
Nz::Vector2f featurePoint;
|
||||
featurePoint.x = (randomNumberGenerator() & 1023) / 1023.f + static_cast<float>(xi);
|
||||
|
|
|
|||
Loading…
Reference in New Issue