diff --git a/modules/fastnoise/lib/FastNoise.cpp b/modules/fastnoise/lib/FastNoise.cpp index b5daf2ad1..b01245578 100644 --- a/modules/fastnoise/lib/FastNoise.cpp +++ b/modules/fastnoise/lib/FastNoise.cpp @@ -493,26 +493,38 @@ FN_DECIMAL FastNoise::GetNoise(FN_DECIMAL x, FN_DECIMAL y) const // White Noise FN_DECIMAL FastNoise::GetWhiteNoise(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z, FN_DECIMAL w) const { + int32_t* xx = reinterpret_cast(&x); + int32_t* yy = reinterpret_cast(&y); + int32_t* zz = reinterpret_cast(&z); + int32_t* ww = reinterpret_cast(&w); + return ValCoord4D(m_seed, - *reinterpret_cast(&x) ^ (*reinterpret_cast(&x) >> 16), - *reinterpret_cast(&y) ^ (*reinterpret_cast(&y) >> 16), - *reinterpret_cast(&z) ^ (*reinterpret_cast(&z) >> 16), - *reinterpret_cast(&w) ^ (*reinterpret_cast(&w) >> 16)); + *xx ^ (*xx >> 16), + *yy ^ (*yy >> 16), + *zz ^ (*zz >> 16), + *ww ^ (*ww >> 16)); } FN_DECIMAL FastNoise::GetWhiteNoise(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) const { + int32_t* xx = reinterpret_cast(&x); + int32_t* yy = reinterpret_cast(&y); + int32_t* zz = reinterpret_cast(&z); + return ValCoord3D(m_seed, - *reinterpret_cast(&x) ^ (*reinterpret_cast(&x) >> 16), - *reinterpret_cast(&y) ^ (*reinterpret_cast(&y) >> 16), - *reinterpret_cast(&z) ^ (*reinterpret_cast(&z) >> 16)); + *xx ^ (*xx >> 16), + *yy ^ (*yy >> 16), + *zz ^ (*zz >> 16)); } FN_DECIMAL FastNoise::GetWhiteNoise(FN_DECIMAL x, FN_DECIMAL y) const { + int32_t* xx = reinterpret_cast(&x); + int32_t* yy = reinterpret_cast(&y); + return ValCoord2D(m_seed, - *reinterpret_cast(&x) ^ (*reinterpret_cast(&x) >> 16), - *reinterpret_cast(&y) ^ (*reinterpret_cast(&y) >> 16)); + *xx ^ (*xx >> 16), + *yy ^ (*yy >> 16)); } FN_DECIMAL FastNoise::GetWhiteNoiseInt(int x, int y, int z, int w) const @@ -624,6 +636,7 @@ FN_DECIMAL FastNoise::SingleValue(unsigned char offset, FN_DECIMAL x, FN_DECIMAL FN_DECIMAL xs, ys, zs; switch (m_interp) { + default: case Linear: xs = x - (FN_DECIMAL)x0; ys = y - (FN_DECIMAL)y0; @@ -738,6 +751,7 @@ FN_DECIMAL FastNoise::SingleValue(unsigned char offset, FN_DECIMAL x, FN_DECIMAL FN_DECIMAL xs, ys; switch (m_interp) { + default: case Linear: xs = x - (FN_DECIMAL)x0; ys = y - (FN_DECIMAL)y0; @@ -852,6 +866,7 @@ FN_DECIMAL FastNoise::SinglePerlin(unsigned char offset, FN_DECIMAL x, FN_DECIMA FN_DECIMAL xs, ys, zs; switch (m_interp) { + default: case Linear: xs = x - (FN_DECIMAL)x0; ys = y - (FN_DECIMAL)y0; @@ -974,6 +989,7 @@ FN_DECIMAL FastNoise::SinglePerlin(unsigned char offset, FN_DECIMAL x, FN_DECIMA FN_DECIMAL xs, ys; switch (m_interp) { + default: case Linear: xs = x - (FN_DECIMAL)x0; ys = y - (FN_DECIMAL)y0; @@ -1714,7 +1730,9 @@ FN_DECIMAL FastNoise::SingleCellular(FN_DECIMAL x, FN_DECIMAL y, FN_DECIMAL z) c int zr = FastRound(z); FN_DECIMAL distance = 999999; - int xc, yc, zc; + int xc = 0; + int yc = 0; + int zc = 0; switch (m_cellularDistanceFunction) { @@ -1938,7 +1956,8 @@ FN_DECIMAL FastNoise::SingleCellular(FN_DECIMAL x, FN_DECIMAL y) const int yr = FastRound(y); FN_DECIMAL distance = 999999; - int xc, yc; + int xc = 0; + int yc = 0; switch (m_cellularDistanceFunction) {