diff --git a/SQCSim2021/SQCSim2021.vcxproj b/SQCSim2021/SQCSim2021.vcxproj
index 6283299..8a66eba 100644
--- a/SQCSim2021/SQCSim2021.vcxproj
+++ b/SQCSim2021/SQCSim2021.vcxproj
@@ -29,7 +29,7 @@
-
+
@@ -49,7 +49,7 @@
-
+
@@ -72,13 +72,13 @@
Application
true
Unicode
- v142
+ ClangCL
Application
true
Unicode
- v142
+ ClangCL
Application
@@ -117,8 +117,8 @@
true
- $(ProjectDir)\external\irrKlang-1.6.0\include$(MSBuildProjectDirectory)$(MSBuildProjectDirectory);external\devil178\include;external\sfml23\include;$(IncludePath)
- external\devil178\lib;external\sfml23\lib;$(LibraryPath);D:\Repos\SQCSim2021\SQCSim2021\external\irrKlang-1.6.0\lib\Win32-visualStudio
+ external\irrKlang-64bit-1.6.0\include;external\devil180\include;external\sfml251\include;external\glew210\include;$(IncludePath)
+ external\devil180\lib\x64\Release;external\glew210\lib\Release\x64;external\sfml251\lib;$(LibraryPath);external\irrKlang-64bit-1.6.0\lib\Winx64-visualStudio
false
diff --git a/SQCSim2021/SQCSim2021.vcxproj.filters b/SQCSim2021/SQCSim2021.vcxproj.filters
index 124abf1..4b2e6c9 100644
--- a/SQCSim2021/SQCSim2021.vcxproj.filters
+++ b/SQCSim2021/SQCSim2021.vcxproj.filters
@@ -68,10 +68,10 @@
Fichiers d%27en-tête
-
+
Fichiers d%27en-tête
-
+
Fichiers d%27en-tête
@@ -121,10 +121,10 @@
Fichiers sources
-
+
Fichiers sources
-
+
Fichiers sources
diff --git a/SQCSim2021/chunk.cpp b/SQCSim2021/chunk.cpp
index c524112..2a98568 100644
--- a/SQCSim2021/chunk.cpp
+++ b/SQCSim2021/chunk.cpp
@@ -7,24 +7,24 @@ Chunk::Chunk(unsigned int x, unsigned int y) : m_posX(x), m_posY(y) {
std::ifstream input(pos.str(), std::fstream::binary);
if (input.fail()) {
- Perlin perlin = Perlin(8, 45.f, 7.f, PERLIN_SEED);
+ OpenSimplexNoise::Noise simplex = OpenSimplexNoise::Noise(PERLIN_SEED);
m_blocks.Reset(BTYPE_AIR);
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Montagnes
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
float xnoiz, ynoiz;
- xnoiz = (double)(ix + x * CHUNK_SIZE_X) / (double)UINT16_MAX;
- ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / (double)UINT16_MAX;
- float height = (perlin.Get(xnoiz, ynoiz)) * 20.f + 5.f;
+ xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 256.;
+ ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 256.;
+ float height = (simplex.eval(xnoiz, ynoiz)) * 60.f + 5.f;
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy)
SetBlock(ix, iy, iz, BTYPE_METAL, nullptr);
}
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Collines
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
float xnoiz, ynoiz;
- xnoiz = (double)(ix + x * CHUNK_SIZE_X) / (double)UINT16_MAX;
- ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / (double)UINT16_MAX;
- float height = perlin.Get(xnoiz, ynoiz) * 5.f + 24.f;
+ xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 64.;
+ ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 64.;
+ float height = simplex.eval(xnoiz, ynoiz) * 5.f + 24.f;
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy) {
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
SetBlock(ix, iy, iz, BTYPE_GRASS, nullptr);
@@ -32,7 +32,7 @@ Chunk::Chunk(unsigned int x, unsigned int y) : m_posX(x), m_posY(y) {
}
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // "Lacs"
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
- for (int iy = 0; iy < 13; ++iy) {
+ for (int iy = 0; iy < 16; ++iy) {
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
SetBlock(ix, iy, iz, BTYPE_ICE, nullptr);
}
@@ -40,15 +40,14 @@ Chunk::Chunk(unsigned int x, unsigned int y) : m_posX(x), m_posY(y) {
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // "Arbres"
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
float xnoiz, ynoiz;
- xnoiz = (double)(iz * CHUNK_SIZE_Y + x * CHUNK_SIZE_X) / (double)UINT16_MAX;
- ynoiz = (double)(ix * CHUNK_SIZE_Y + y * CHUNK_SIZE_Z) / (double)UINT16_MAX;
- bool tree = (int)(abs(perlin.Get(xnoiz, ynoiz)) * 17933.f) % CHUNK_SIZE_Y > 126 ? true : false;
-
+ xnoiz = (double)(iz * CHUNK_SIZE_Y + x * CHUNK_SIZE_X) / 256.;
+ ynoiz = (double)(ix * CHUNK_SIZE_Y + y * CHUNK_SIZE_Z) / 256.;
+ bool tree = (int)(abs(simplex.eval(xnoiz, ynoiz)) * 17933.f) % CHUNK_SIZE_Y > 126 ? true : false;
for (int iy = 0; iy < CHUNK_SIZE_Y - 10; ++iy)
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
if (GetBlock(ix, iy - 1, iz) == BTYPE_GRASS)
if (tree) {
- for (int i = 0; i < (int)(abs(perlin.Get(xnoiz, ynoiz))) % 3 + 1; ++i)
+ for (int i = 0; i < (int)(abs(simplex.eval(xnoiz, ynoiz) * 65)) % 42 + 1; ++i)
SetBlock(ix, iy + i, iz, BTYPE_DIRT, nullptr);
break;
}
diff --git a/SQCSim2021/chunk.h b/SQCSim2021/chunk.h
index 5c0add3..f4d58b1 100644
--- a/SQCSim2021/chunk.h
+++ b/SQCSim2021/chunk.h
@@ -5,6 +5,8 @@
#include "array2d.h"
#include "vertexbuffer.h"
#include "blockinfo.h"
+#include "perlin.h"
+#include "opensimplex.h"
class World;
diff --git a/SQCSim2021/define.h b/SQCSim2021/define.h
index 63987e3..f3f0d93 100644
--- a/SQCSim2021/define.h
+++ b/SQCSim2021/define.h
@@ -36,8 +36,8 @@
#endif
#ifdef NDEBUG
-#define WORLD_SIZE_X 128
-#define WORLD_SIZE_Y 128
+#define WORLD_SIZE_X 64
+#define WORLD_SIZE_Y 64
#define FRAMES_RENDER_CHUNKS 1
#define FRAMES_UPDATE_CHUNKS 1
@@ -47,7 +47,7 @@
#define THREADS_UPDATE_CHUNKS 8
#define THREADS_DELETE_CHUNKS 10
-#define VIEW_DISTANCE 1024
+#define VIEW_DISTANCE 512
#define TEXTURE_SIZE 512
#define MAX_BULLETS 512
#endif
diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp
index 65099e9..204d89e 100644
--- a/SQCSim2021/engine.cpp
+++ b/SQCSim2021/engine.cpp
@@ -186,12 +186,14 @@ int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; }
void Engine::Render(float elapsedTime) {
static float gameTime = elapsedTime;
+ static float pollTime = 0;
static float bulletTime = 0;
static BlockType bloc = 1;
if (elapsedTime > 0.1f) return;
gameTime += elapsedTime;
+ pollTime += elapsedTime;
Transformation all;
Transformation skybox;
@@ -205,9 +207,13 @@ void Engine::Render(float elapsedTime) {
if (bulletTime > 0.f) bulletTime -= elapsedTime;
if (bulletTime < 0.f) bulletTime = 0.f;
+ if (pollTime >= .005f) {
m_player.ApplyPhysics(m_player.GetInput(m_keyW, m_keyS, m_keyA, m_keyD, m_keySpace, (bloc == BTYPE_LAST && bulletTime <= 0.f && m_mouseL), elapsedTime), m_world, elapsedTime, &m_audio);
m_audio.Update3DAudio(m_player.GetPOV(), m_player.GetDirection(), m_player.GetVelocity()); // Ajustement du positionnement 3D avec les coordonnées du joueur et
// son vecteur de vélocité (pour l'effet Doppler)
+ pollTime = 0;
+ }
+
m_player.ApplyTransformation(all);
m_player.ApplyTransformation(skybox, false); // Version d'ApplyTransformation qui ne tient compte que de la rotation
@@ -252,7 +258,7 @@ void Engine::Render(float elapsedTime) {
m_bullets[x] = nullptr;
}
- m_world.Update(m_renderCount, m_bullets, m_player, all, m_shader01, m_textureAtlas, m_perlin, m_blockinfo);
+ m_world.Update(m_renderCount, m_bullets, m_player, all, m_shader01, m_textureAtlas, m_blockinfo);
if (m_isSkybox) m_skybox.Render(skybox);
diff --git a/SQCSim2021/opensimplex.cpp b/SQCSim2021/opensimplex.cpp
new file mode 100644
index 0000000..a64d31f
--- /dev/null
+++ b/SQCSim2021/opensimplex.cpp
@@ -0,0 +1,2542 @@
+#include "opensimplex.h"
+
+#include
+namespace OpenSimplexNoise
+{
+ using namespace std;
+
+ Noise::Noise()
+ : m_stretch2d(-0.211324865405187) //(1/Math.sqrt(2+1)-1)/2;
+ , m_squish2d(0.366025403784439) //(Math.sqrt(2+1)-1)/2;
+ , m_stretch3d(-1.0 / 6) //(1/Math.sqrt(3+1)-1)/3;
+ , m_squish3d(1.0 / 3) //(Math.sqrt(3+1)-1)/3;
+ , m_stretch4d(-0.138196601125011) //(1/Math.sqrt(4+1)-1)/4;
+ , m_squish4d(0.309016994374947) //(Math.sqrt(4+1)-1)/4;
+ , m_norm2d(47)
+ , m_norm3d(103)
+ , m_norm4d(30)
+ , m_defaultSeed(0)
+ , m_perm{0}
+ , m_permGradIndex3d{0}
+ , m_gradients2d{ 5, 2, 2, 5,
+ -5, 2, -2, 5,
+ 5, -2, 2, -5,
+ -5, -2, -2, -5, }
+ , m_gradients3d{-11, 4, 4, -4, 11, 4, -4, 4, 11,
+ 11, 4, 4, 4, 11, 4, 4, 4, 11,
+ -11, -4, 4, -4, -11, 4, -4, -4, 11,
+ 11, -4, 4, 4, -11, 4, 4, -4, 11,
+ -11, 4, -4, -4, 11, -4, -4, 4, -11,
+ 11, 4, -4, 4, 11, -4, 4, 4, -11,
+ -11, -4, -4, -4, -11, -4, -4, -4, -11,
+ 11, -4, -4, 4, -11, -4, 4, -4, -11, }
+ , m_gradients4d{ 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3,
+ -3, 1, 1, 1, -1, 3, 1, 1, -1, 1, 3, 1, -1, 1, 1, 3,
+ 3, -1, 1, 1, 1, -3, 1, 1, 1, -1, 3, 1, 1, -1, 1, 3,
+ -3, -1, 1, 1, -1, -3, 1, 1, -1, -1, 3, 1, -1, -1, 1, 3,
+ 3, 1, -1, 1, 1, 3, -1, 1, 1, 1, -3, 1, 1, 1, -1, 3,
+ -3, 1, -1, 1, -1, 3, -1, 1, -1, 1, -3, 1, -1, 1, -1, 3,
+ 3, -1, -1, 1, 1, -3, -1, 1, 1, -1, -3, 1, 1, -1, -1, 3,
+ -3, -1, -1, 1, -1, -3, -1, 1, -1, -1, -3, 1, -1, -1, -1, 3,
+ 3, 1, 1, -1, 1, 3, 1, -1, 1, 1, 3, -1, 1, 1, 1, -3,
+ -3, 1, 1, -1, -1, 3, 1, -1, -1, 1, 3, -1, -1, 1, 1, -3,
+ 3, -1, 1, -1, 1, -3, 1, -1, 1, -1, 3, -1, 1, -1, 1, -3,
+ -3, -1, 1, -1, -1, -3, 1, -1, -1, -1, 3, -1, -1, -1, 1, -3,
+ 3, 1, -1, -1, 1, 3, -1, -1, 1, 1, -3, -1, 1, 1, -1, -3,
+ -3, 1, -1, -1, -1, 3, -1, -1, -1, 1, -3, -1, -1, 1, -1, -3,
+ 3, -1, -1, -1, 1, -3, -1, -1, 1, -1, -3, -1, 1, -1, -1, -3,
+ -3, -1, -1, -1, -1, -3, -1, -1, -1, -1, -3, -1, -1, -1, -1, -3, }
+ {
+ }
+
+ Noise::Noise(int64_t seed)
+ : Noise()
+ {
+ short source[256];
+ for (short i = 0; i < 256; i++)
+ {
+ source[i] = i;
+ }
+ seed = seed * 6364136223846793005l + 1442695040888963407l;
+ seed = seed * 6364136223846793005l + 1442695040888963407l;
+ seed = seed * 6364136223846793005l + 1442695040888963407l;
+ for (int i = 255; i >= 0; i--)
+ {
+ seed = seed * 6364136223846793005l + 1442695040888963407l;
+ int r = static_cast((seed + 31) % (i + 1));
+ if (r < 0)
+ {
+ r += (i + 1);
+ }
+ m_perm[i] = source[r];
+ m_permGradIndex3d[i] = static_cast((m_perm[i] % (m_gradients3d.size() / 3)) * 3);
+ source[r] = source[i];
+ }
+ }
+
+ double Noise::eval(double x, double y) const
+ {
+ //Place input coordinates onto grid.
+ double stretchOffset = (x + y) * m_stretch2d;
+ double xs = x + stretchOffset;
+ double ys = y + stretchOffset;
+
+ //Floor to get grid coordinates of rhombus (stretched square) super-cell origin.
+ int xsb = static_cast(floor(xs));
+ int ysb = static_cast(floor(ys));
+
+ //Skew out to get actual coordinates of rhombus origin. We'll need these later.
+ double squishOffset = (xsb + ysb) * m_squish2d;
+ double xb = xsb + squishOffset;
+ double yb = ysb + squishOffset;
+
+ //Compute grid coordinates relative to rhombus origin.
+ double xins = xs - xsb;
+ double yins = ys - ysb;
+
+ //Sum those together to get a value that determines which region we're in.
+ double inSum = xins + yins;
+
+ //Positions relative to origin point.
+ double dx0 = x - xb;
+ double dy0 = y - yb;
+
+ //We'll be defining these inside the next block and using them afterwards.
+ double dx_ext, dy_ext;
+ int xsv_ext, ysv_ext;
+
+ double value = 0;
+
+ //Contribution (1,0)
+ double dx1 = dx0 - 1 - m_squish2d;
+ double dy1 = dy0 - 0 - m_squish2d;
+ double attn1 = 2 - dx1 * dx1 - dy1 * dy1;
+ if (attn1 > 0)
+ {
+ attn1 *= attn1;
+ value += attn1 * attn1 * extrapolate(xsb + 1, ysb + 0, dx1, dy1);
+ }
+
+ //Contribution (0,1)
+ double dx2 = dx0 - 0 - m_squish2d;
+ double dy2 = dy0 - 1 - m_squish2d;
+ double attn2 = 2 - dx2 * dx2 - dy2 * dy2;
+ if (attn2 > 0)
+ {
+ attn2 *= attn2;
+ value += attn2 * attn2 * extrapolate(xsb + 0, ysb + 1, dx2, dy2);
+ }
+
+ if (inSum <= 1)
+ { //We're inside the triangle (2-Simplex) at (0,0)
+ double zins = 1 - inSum;
+ if (zins > xins || zins > yins)
+ { //(0,0) is one of the closest two triangular vertices
+ if (xins > yins)
+ {
+ xsv_ext = xsb + 1;
+ ysv_ext = ysb - 1;
+ dx_ext = dx0 - 1;
+ dy_ext = dy0 + 1;
+ }
+ else
+ {
+ xsv_ext = xsb - 1;
+ ysv_ext = ysb + 1;
+ dx_ext = dx0 + 1;
+ dy_ext = dy0 - 1;
+ }
+ }
+ else
+ { //(1,0) and (0,1) are the closest two vertices.
+ xsv_ext = xsb + 1;
+ ysv_ext = ysb + 1;
+ dx_ext = dx0 - 1 - 2 * m_squish2d;
+ dy_ext = dy0 - 1 - 2 * m_squish2d;
+ }
+ }
+ else
+ { //We're inside the triangle (2-Simplex) at (1,1)
+ double zins = 2 - inSum;
+ if (zins < xins || zins < yins)
+ { //(0,0) is one of the closest two triangular vertices
+ if (xins > yins)
+ {
+ xsv_ext = xsb + 2;
+ ysv_ext = ysb + 0;
+ dx_ext = dx0 - 2 - 2 * m_squish2d;
+ dy_ext = dy0 + 0 - 2 * m_squish2d;
+ }
+ else
+ {
+ xsv_ext = xsb + 0;
+ ysv_ext = ysb + 2;
+ dx_ext = dx0 + 0 - 2 * m_squish2d;
+ dy_ext = dy0 - 2 - 2 * m_squish2d;
+ }
+ }
+ else
+ { //(1,0) and (0,1) are the closest two vertices.
+ dx_ext = dx0;
+ dy_ext = dy0;
+ xsv_ext = xsb;
+ ysv_ext = ysb;
+ }
+ xsb += 1;
+ ysb += 1;
+ dx0 = dx0 - 1 - 2 * m_squish2d;
+ dy0 = dy0 - 1 - 2 * m_squish2d;
+ }
+
+ //Contribution (0,0) or (1,1)
+ double attn0 = 2 - dx0 * dx0 - dy0 * dy0;
+ if (attn0 > 0)
+ {
+ attn0 *= attn0;
+ value += attn0 * attn0 * extrapolate(xsb, ysb, dx0, dy0);
+ }
+
+ //Extra Vertex
+ double attn_ext = 2 - dx_ext * dx_ext - dy_ext * dy_ext;
+ if (attn_ext > 0)
+ {
+ attn_ext *= attn_ext;
+ value += attn_ext * attn_ext * extrapolate(xsv_ext, ysv_ext, dx_ext, dy_ext);
+ }
+
+ return value / m_norm2d;
+ }
+
+ double Noise::eval(double x, double y, double z) const
+ {
+ //Place input coordinates on simplectic honeycomb.
+ double stretchOffset = (x + y + z) * m_stretch3d;
+ double xs = x + stretchOffset;
+ double ys = y + stretchOffset;
+ double zs = z + stretchOffset;
+
+ //static_cast(floor to get simplectic honeycomb coordinates of rhombohedron (stretched cube) super-cell origin.
+ int xsb = static_cast(floor(xs));
+ int ysb = static_cast(floor(ys));
+ int zsb = static_cast(floor(zs));
+
+ //Skew out to get actual coordinates of rhombohedron origin. We'll need these later.
+ double squishOffset = (xsb + ysb + zsb) * m_squish3d;
+ double xb = xsb + squishOffset;
+ double yb = ysb + squishOffset;
+ double zb = zsb + squishOffset;
+
+ //Compute simplectic honeycomb coordinates relative to rhombohedral origin.
+ double xins = xs - xsb;
+ double yins = ys - ysb;
+ double zins = zs - zsb;
+
+ //Sum those together to get a value that determines which region we're in.
+ double inSum = xins + yins + zins;
+
+ //Positions relative to origin point.
+ double dx0 = x - xb;
+ double dy0 = y - yb;
+ double dz0 = z - zb;
+
+ //We'll be defining these inside the next block and using them afterwards.
+ double dx_ext0, dy_ext0, dz_ext0;
+ double dx_ext1, dy_ext1, dz_ext1;
+ int xsv_ext0, ysv_ext0, zsv_ext0;
+ int xsv_ext1, ysv_ext1, zsv_ext1;
+
+ double value = 0;
+ if (inSum <= 1)
+ { //We're inside the tetrahedron (3-Simplex) at (0,0,0)
+
+//Determine which two of (0,0,1), (0,1,0), (1,0,0) are closest.
+ char aPoint = 0x01;
+ double aScore = xins;
+ char bPoint = 0x02;
+ double bScore = yins;
+ if (aScore >= bScore && zins > bScore)
+ {
+ bScore = zins;
+ bPoint = 0x04;
+ }
+ else if (aScore < bScore && zins > aScore)
+ {
+ aScore = zins;
+ aPoint = 0x04;
+ }
+
+ //Now we determine the two lattice points not part of the tetrahedron that may contribute.
+ //This depends on the closest two tetrahedral vertices, including (0,0,0)
+ double wins = 1 - inSum;
+ if (wins > aScore || wins > bScore)
+ { //(0,0,0) is one of the closest two tetrahedral vertices.
+ char c = (bScore > aScore ? bPoint : aPoint); //Our other closest vertex is the closest out of a and b.
+
+ if ((c & 0x01) == 0)
+ {
+ xsv_ext0 = xsb - 1;
+ xsv_ext1 = xsb;
+ dx_ext0 = dx0 + 1;
+ dx_ext1 = dx0;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsb + 1;
+ dx_ext0 = dx_ext1 = dx0 - 1;
+ }
+
+ if ((c & 0x02) == 0)
+ {
+ ysv_ext0 = ysv_ext1 = ysb;
+ dy_ext0 = dy_ext1 = dy0;
+ if ((c & 0x01) == 0)
+ {
+ ysv_ext1 -= 1;
+ dy_ext1 += 1;
+ }
+ else
+ {
+ ysv_ext0 -= 1;
+ dy_ext0 += 1;
+ }
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysb + 1;
+ dy_ext0 = dy_ext1 = dy0 - 1;
+ }
+
+ if ((c & 0x04) == 0)
+ {
+ zsv_ext0 = zsb;
+ zsv_ext1 = zsb - 1;
+ dz_ext0 = dz0;
+ dz_ext1 = dz0 + 1;
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsb + 1;
+ dz_ext0 = dz_ext1 = dz0 - 1;
+ }
+ }
+ else
+ { //(0,0,0) is not one of the closest two tetrahedral vertices.
+ char c = static_cast(aPoint | bPoint); //Our two extra vertices are determined by the closest two.
+
+ if ((c & 0x01) == 0)
+ {
+ xsv_ext0 = xsb;
+ xsv_ext1 = xsb - 1;
+ dx_ext0 = dx0 - 2 * m_squish3d;
+ dx_ext1 = dx0 + 1 - m_squish3d;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsb + 1;
+ dx_ext0 = dx0 - 1 - 2 * m_squish3d;
+ dx_ext1 = dx0 - 1 - m_squish3d;
+ }
+
+ if ((c & 0x02) == 0)
+ {
+ ysv_ext0 = ysb;
+ ysv_ext1 = ysb - 1;
+ dy_ext0 = dy0 - 2 * m_squish3d;
+ dy_ext1 = dy0 + 1 - m_squish3d;
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysb + 1;
+ dy_ext0 = dy0 - 1 - 2 * m_squish3d;
+ dy_ext1 = dy0 - 1 - m_squish3d;
+ }
+
+ if ((c & 0x04) == 0)
+ {
+ zsv_ext0 = zsb;
+ zsv_ext1 = zsb - 1;
+ dz_ext0 = dz0 - 2 * m_squish3d;
+ dz_ext1 = dz0 + 1 - m_squish3d;
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsb + 1;
+ dz_ext0 = dz0 - 1 - 2 * m_squish3d;
+ dz_ext1 = dz0 - 1 - m_squish3d;
+ }
+ }
+
+ //Contribution (0,0,0)
+ double attn0 = 2 - dx0 * dx0 - dy0 * dy0 - dz0 * dz0;
+ if (attn0 > 0)
+ {
+ attn0 *= attn0;
+ value += attn0 * attn0 * extrapolate(xsb + 0, ysb + 0, zsb + 0, dx0, dy0, dz0);
+ }
+
+ //Contribution (1,0,0)
+ double dx1 = dx0 - 1 - m_squish3d;
+ double dy1 = dy0 - 0 - m_squish3d;
+ double dz1 = dz0 - 0 - m_squish3d;
+ double attn1 = 2 - dx1 * dx1 - dy1 * dy1 - dz1 * dz1;
+ if (attn1 > 0)
+ {
+ attn1 *= attn1;
+ value += attn1 * attn1 * extrapolate(xsb + 1, ysb + 0, zsb + 0, dx1, dy1, dz1);
+ }
+
+ //Contribution (0,1,0)
+ double dx2 = dx0 - 0 - m_squish3d;
+ double dy2 = dy0 - 1 - m_squish3d;
+ double dz2 = dz1;
+ double attn2 = 2 - dx2 * dx2 - dy2 * dy2 - dz2 * dz2;
+ if (attn2 > 0)
+ {
+ attn2 *= attn2;
+ value += attn2 * attn2 * extrapolate(xsb + 0, ysb + 1, zsb + 0, dx2, dy2, dz2);
+ }
+
+ //Contribution (0,0,1)
+ double dx3 = dx2;
+ double dy3 = dy1;
+ double dz3 = dz0 - 1 - m_squish3d;
+ double attn3 = 2 - dx3 * dx3 - dy3 * dy3 - dz3 * dz3;
+ if (attn3 > 0)
+ {
+ attn3 *= attn3;
+ value += attn3 * attn3 * extrapolate(xsb + 0, ysb + 0, zsb + 1, dx3, dy3, dz3);
+ }
+ }
+ else if (inSum >= 2)
+ { //We're inside the tetrahedron (3-Simplex) at (1,1,1)
+
+//Determine which two tetrahedral vertices are the closest, out of (1,1,0), (1,0,1), (0,1,1) but not (1,1,1).
+ char aPoint = 0x06;
+ double aScore = xins;
+ char bPoint = 0x05;
+ double bScore = yins;
+ if (aScore <= bScore && zins < bScore)
+ {
+ bScore = zins;
+ bPoint = 0x03;
+ }
+ else if (aScore > bScore && zins < aScore)
+ {
+ aScore = zins;
+ aPoint = 0x03;
+ }
+
+ //Now we determine the two lattice points not part of the tetrahedron that may contribute.
+ //This depends on the closest two tetrahedral vertices, including (1,1,1)
+ double wins = 3 - inSum;
+ if (wins < aScore || wins < bScore)
+ { //(1,1,1) is one of the closest two tetrahedral vertices.
+ char c = (bScore < aScore ? bPoint : aPoint); //Our other closest vertex is the closest out of a and b.
+
+ if ((c & 0x01) != 0)
+ {
+ xsv_ext0 = xsb + 2;
+ xsv_ext1 = xsb + 1;
+ dx_ext0 = dx0 - 2 - 3 * m_squish3d;
+ dx_ext1 = dx0 - 1 - 3 * m_squish3d;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsb;
+ dx_ext0 = dx_ext1 = dx0 - 3 * m_squish3d;
+ }
+
+ if ((c & 0x02) != 0)
+ {
+ ysv_ext0 = ysv_ext1 = ysb + 1;
+ dy_ext0 = dy_ext1 = dy0 - 1 - 3 * m_squish3d;
+ if ((c & 0x01) != 0)
+ {
+ ysv_ext1 += 1;
+ dy_ext1 -= 1;
+ }
+ else
+ {
+ ysv_ext0 += 1;
+ dy_ext0 -= 1;
+ }
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysb;
+ dy_ext0 = dy_ext1 = dy0 - 3 * m_squish3d;
+ }
+
+ if ((c & 0x04) != 0)
+ {
+ zsv_ext0 = zsb + 1;
+ zsv_ext1 = zsb + 2;
+ dz_ext0 = dz0 - 1 - 3 * m_squish3d;
+ dz_ext1 = dz0 - 2 - 3 * m_squish3d;
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsb;
+ dz_ext0 = dz_ext1 = dz0 - 3 * m_squish3d;
+ }
+ }
+ else
+ { //(1,1,1) is not one of the closest two tetrahedral vertices.
+ char c = static_cast(aPoint & bPoint); //Our two extra vertices are determined by the closest two.
+
+ if ((c & 0x01) != 0)
+ {
+ xsv_ext0 = xsb + 1;
+ xsv_ext1 = xsb + 2;
+ dx_ext0 = dx0 - 1 - m_squish3d;
+ dx_ext1 = dx0 - 2 - 2 * m_squish3d;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsb;
+ dx_ext0 = dx0 - m_squish3d;
+ dx_ext1 = dx0 - 2 * m_squish3d;
+ }
+
+ if ((c & 0x02) != 0)
+ {
+ ysv_ext0 = ysb + 1;
+ ysv_ext1 = ysb + 2;
+ dy_ext0 = dy0 - 1 - m_squish3d;
+ dy_ext1 = dy0 - 2 - 2 * m_squish3d;
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysb;
+ dy_ext0 = dy0 - m_squish3d;
+ dy_ext1 = dy0 - 2 * m_squish3d;
+ }
+
+ if ((c & 0x04) != 0)
+ {
+ zsv_ext0 = zsb + 1;
+ zsv_ext1 = zsb + 2;
+ dz_ext0 = dz0 - 1 - m_squish3d;
+ dz_ext1 = dz0 - 2 - 2 * m_squish3d;
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsb;
+ dz_ext0 = dz0 - m_squish3d;
+ dz_ext1 = dz0 - 2 * m_squish3d;
+ }
+ }
+
+ //Contribution (1,1,0)
+ double dx3 = dx0 - 1 - 2 * m_squish3d;
+ double dy3 = dy0 - 1 - 2 * m_squish3d;
+ double dz3 = dz0 - 0 - 2 * m_squish3d;
+ double attn3 = 2 - dx3 * dx3 - dy3 * dy3 - dz3 * dz3;
+ if (attn3 > 0)
+ {
+ attn3 *= attn3;
+ value += attn3 * attn3 * extrapolate(xsb + 1, ysb + 1, zsb + 0, dx3, dy3, dz3);
+ }
+
+ //Contribution (1,0,1)
+ double dx2 = dx3;
+ double dy2 = dy0 - 0 - 2 * m_squish3d;
+ double dz2 = dz0 - 1 - 2 * m_squish3d;
+ double attn2 = 2 - dx2 * dx2 - dy2 * dy2 - dz2 * dz2;
+ if (attn2 > 0)
+ {
+ attn2 *= attn2;
+ value += attn2 * attn2 * extrapolate(xsb + 1, ysb + 0, zsb + 1, dx2, dy2, dz2);
+ }
+
+ //Contribution (0,1,1)
+ double dx1 = dx0 - 0 - 2 * m_squish3d;
+ double dy1 = dy3;
+ double dz1 = dz2;
+ double attn1 = 2 - dx1 * dx1 - dy1 * dy1 - dz1 * dz1;
+ if (attn1 > 0)
+ {
+ attn1 *= attn1;
+ value += attn1 * attn1 * extrapolate(xsb + 0, ysb + 1, zsb + 1, dx1, dy1, dz1);
+ }
+
+ //Contribution (1,1,1)
+ dx0 = dx0 - 1 - 3 * m_squish3d;
+ dy0 = dy0 - 1 - 3 * m_squish3d;
+ dz0 = dz0 - 1 - 3 * m_squish3d;
+ double attn0 = 2 - dx0 * dx0 - dy0 * dy0 - dz0 * dz0;
+ if (attn0 > 0)
+ {
+ attn0 *= attn0;
+ value += attn0 * attn0 * extrapolate(xsb + 1, ysb + 1, zsb + 1, dx0, dy0, dz0);
+ }
+ }
+ else
+ { //We're inside the octahedron (Rectified 3-Simplex) in between.
+ double aScore;
+ char aPoint;
+ bool aIsFurtherSide;
+ double bScore;
+ char bPoint;
+ bool bIsFurtherSide;
+
+ //Decide between point (0,0,1) and (1,1,0) as closest
+ double p1 = xins + yins;
+ if (p1 > 1)
+ {
+ aScore = p1 - 1;
+ aPoint = 0x03;
+ aIsFurtherSide = true;
+ }
+ else
+ {
+ aScore = 1 - p1;
+ aPoint = 0x04;
+ aIsFurtherSide = false;
+ }
+
+ //Decide between point (0,1,0) and (1,0,1) as closest
+ double p2 = xins + zins;
+ if (p2 > 1)
+ {
+ bScore = p2 - 1;
+ bPoint = 0x05;
+ bIsFurtherSide = true;
+ }
+ else
+ {
+ bScore = 1 - p2;
+ bPoint = 0x02;
+ bIsFurtherSide = false;
+ }
+
+ //The closest out of the two (1,0,0) and (0,1,1) will replace the furthest out of the two decided above, if closer.
+ double p3 = yins + zins;
+ if (p3 > 1)
+ {
+ double score = p3 - 1;
+ if (aScore <= bScore && aScore < score)
+ {
+ aScore = score;
+ aPoint = 0x06;
+ aIsFurtherSide = true;
+ }
+ else if (aScore > bScore && bScore < score)
+ {
+ bScore = score;
+ bPoint = 0x06;
+ bIsFurtherSide = true;
+ }
+ }
+ else
+ {
+ double score = 1 - p3;
+ if (aScore <= bScore && aScore < score)
+ {
+ aScore = score;
+ aPoint = 0x01;
+ aIsFurtherSide = false;
+ }
+ else if (aScore > bScore && bScore < score)
+ {
+ bScore = score;
+ bPoint = 0x01;
+ bIsFurtherSide = false;
+ }
+ }
+
+ //Where each of the two closest points are determines how the extra two vertices are calculated.
+ if (aIsFurtherSide == bIsFurtherSide)
+ {
+ if (aIsFurtherSide)
+ { //Both closest points on (1,1,1) side
+
+//One of the two extra points is (1,1,1)
+ dx_ext0 = dx0 - 1 - 3 * m_squish3d;
+ dy_ext0 = dy0 - 1 - 3 * m_squish3d;
+ dz_ext0 = dz0 - 1 - 3 * m_squish3d;
+ xsv_ext0 = xsb + 1;
+ ysv_ext0 = ysb + 1;
+ zsv_ext0 = zsb + 1;
+
+ //Other extra point is based on the shared axis.
+ char c = static_cast(aPoint & bPoint);
+ if ((c & 0x01) != 0)
+ {
+ dx_ext1 = dx0 - 2 - 2 * m_squish3d;
+ dy_ext1 = dy0 - 2 * m_squish3d;
+ dz_ext1 = dz0 - 2 * m_squish3d;
+ xsv_ext1 = xsb + 2;
+ ysv_ext1 = ysb;
+ zsv_ext1 = zsb;
+ }
+ else if ((c & 0x02) != 0)
+ {
+ dx_ext1 = dx0 - 2 * m_squish3d;
+ dy_ext1 = dy0 - 2 - 2 * m_squish3d;
+ dz_ext1 = dz0 - 2 * m_squish3d;
+ xsv_ext1 = xsb;
+ ysv_ext1 = ysb + 2;
+ zsv_ext1 = zsb;
+ }
+ else
+ {
+ dx_ext1 = dx0 - 2 * m_squish3d;
+ dy_ext1 = dy0 - 2 * m_squish3d;
+ dz_ext1 = dz0 - 2 - 2 * m_squish3d;
+ xsv_ext1 = xsb;
+ ysv_ext1 = ysb;
+ zsv_ext1 = zsb + 2;
+ }
+ }
+ else
+ {//Both closest points on (0,0,0) side
+
+ //One of the two extra points is (0,0,0)
+ dx_ext0 = dx0;
+ dy_ext0 = dy0;
+ dz_ext0 = dz0;
+ xsv_ext0 = xsb;
+ ysv_ext0 = ysb;
+ zsv_ext0 = zsb;
+
+ //Other extra point is based on the omitted axis.
+ char c = static_cast(aPoint | bPoint);
+ if ((c & 0x01) == 0)
+ {
+ dx_ext1 = dx0 + 1 - m_squish3d;
+ dy_ext1 = dy0 - 1 - m_squish3d;
+ dz_ext1 = dz0 - 1 - m_squish3d;
+ xsv_ext1 = xsb - 1;
+ ysv_ext1 = ysb + 1;
+ zsv_ext1 = zsb + 1;
+ }
+ else if ((c & 0x02) == 0)
+ {
+ dx_ext1 = dx0 - 1 - m_squish3d;
+ dy_ext1 = dy0 + 1 - m_squish3d;
+ dz_ext1 = dz0 - 1 - m_squish3d;
+ xsv_ext1 = xsb + 1;
+ ysv_ext1 = ysb - 1;
+ zsv_ext1 = zsb + 1;
+ }
+ else
+ {
+ dx_ext1 = dx0 - 1 - m_squish3d;
+ dy_ext1 = dy0 - 1 - m_squish3d;
+ dz_ext1 = dz0 + 1 - m_squish3d;
+ xsv_ext1 = xsb + 1;
+ ysv_ext1 = ysb + 1;
+ zsv_ext1 = zsb - 1;
+ }
+ }
+ }
+ else
+ { //One point on (0,0,0) side, one point on (1,1,1) side
+ char c1, c2;
+ if (aIsFurtherSide)
+ {
+ c1 = aPoint;
+ c2 = bPoint;
+ }
+ else
+ {
+ c1 = bPoint;
+ c2 = aPoint;
+ }
+
+ //One contribution is a permutation of (1,1,-1)
+ if ((c1 & 0x01) == 0)
+ {
+ dx_ext0 = dx0 + 1 - m_squish3d;
+ dy_ext0 = dy0 - 1 - m_squish3d;
+ dz_ext0 = dz0 - 1 - m_squish3d;
+ xsv_ext0 = xsb - 1;
+ ysv_ext0 = ysb + 1;
+ zsv_ext0 = zsb + 1;
+ }
+ else if ((c1 & 0x02) == 0)
+ {
+ dx_ext0 = dx0 - 1 - m_squish3d;
+ dy_ext0 = dy0 + 1 - m_squish3d;
+ dz_ext0 = dz0 - 1 - m_squish3d;
+ xsv_ext0 = xsb + 1;
+ ysv_ext0 = ysb - 1;
+ zsv_ext0 = zsb + 1;
+ }
+ else
+ {
+ dx_ext0 = dx0 - 1 - m_squish3d;
+ dy_ext0 = dy0 - 1 - m_squish3d;
+ dz_ext0 = dz0 + 1 - m_squish3d;
+ xsv_ext0 = xsb + 1;
+ ysv_ext0 = ysb + 1;
+ zsv_ext0 = zsb - 1;
+ }
+
+ //One contribution is a permutation of (0,0,2)
+ dx_ext1 = dx0 - 2 * m_squish3d;
+ dy_ext1 = dy0 - 2 * m_squish3d;
+ dz_ext1 = dz0 - 2 * m_squish3d;
+ xsv_ext1 = xsb;
+ ysv_ext1 = ysb;
+ zsv_ext1 = zsb;
+ if ((c2 & 0x01) != 0)
+ {
+ dx_ext1 -= 2;
+ xsv_ext1 += 2;
+ }
+ else if ((c2 & 0x02) != 0)
+ {
+ dy_ext1 -= 2;
+ ysv_ext1 += 2;
+ }
+ else
+ {
+ dz_ext1 -= 2;
+ zsv_ext1 += 2;
+ }
+ }
+
+ //Contribution (1,0,0)
+ double dx1 = dx0 - 1 - m_squish3d;
+ double dy1 = dy0 - 0 - m_squish3d;
+ double dz1 = dz0 - 0 - m_squish3d;
+ double attn1 = 2 - dx1 * dx1 - dy1 * dy1 - dz1 * dz1;
+ if (attn1 > 0)
+ {
+ attn1 *= attn1;
+ value += attn1 * attn1 * extrapolate(xsb + 1, ysb + 0, zsb + 0, dx1, dy1, dz1);
+ }
+
+ //Contribution (0,1,0)
+ double dx2 = dx0 - 0 - m_squish3d;
+ double dy2 = dy0 - 1 - m_squish3d;
+ double dz2 = dz1;
+ double attn2 = 2 - dx2 * dx2 - dy2 * dy2 - dz2 * dz2;
+ if (attn2 > 0)
+ {
+ attn2 *= attn2;
+ value += attn2 * attn2 * extrapolate(xsb + 0, ysb + 1, zsb + 0, dx2, dy2, dz2);
+ }
+
+ //Contribution (0,0,1)
+ double dx3 = dx2;
+ double dy3 = dy1;
+ double dz3 = dz0 - 1 - m_squish3d;
+ double attn3 = 2 - dx3 * dx3 - dy3 * dy3 - dz3 * dz3;
+ if (attn3 > 0)
+ {
+ attn3 *= attn3;
+ value += attn3 * attn3 * extrapolate(xsb + 0, ysb + 0, zsb + 1, dx3, dy3, dz3);
+ }
+
+ //Contribution (1,1,0)
+ double dx4 = dx0 - 1 - 2 * m_squish3d;
+ double dy4 = dy0 - 1 - 2 * m_squish3d;
+ double dz4 = dz0 - 0 - 2 * m_squish3d;
+ double attn4 = 2 - dx4 * dx4 - dy4 * dy4 - dz4 * dz4;
+ if (attn4 > 0)
+ {
+ attn4 *= attn4;
+ value += attn4 * attn4 * extrapolate(xsb + 1, ysb + 1, zsb + 0, dx4, dy4, dz4);
+ }
+
+ //Contribution (1,0,1)
+ double dx5 = dx4;
+ double dy5 = dy0 - 0 - 2 * m_squish3d;
+ double dz5 = dz0 - 1 - 2 * m_squish3d;
+ double attn5 = 2 - dx5 * dx5 - dy5 * dy5 - dz5 * dz5;
+ if (attn5 > 0)
+ {
+ attn5 *= attn5;
+ value += attn5 * attn5 * extrapolate(xsb + 1, ysb + 0, zsb + 1, dx5, dy5, dz5);
+ }
+
+ //Contribution (0,1,1)
+ double dx6 = dx0 - 0 - 2 * m_squish3d;
+ double dy6 = dy4;
+ double dz6 = dz5;
+ double attn6 = 2 - dx6 * dx6 - dy6 * dy6 - dz6 * dz6;
+ if (attn6 > 0)
+ {
+ attn6 *= attn6;
+ value += attn6 * attn6 * extrapolate(xsb + 0, ysb + 1, zsb + 1, dx6, dy6, dz6);
+ }
+ }
+
+ //First extra vertex
+ double attn_ext0 = 2 - dx_ext0 * dx_ext0 - dy_ext0 * dy_ext0 - dz_ext0 * dz_ext0;
+ if (attn_ext0 > 0)
+ {
+ attn_ext0 *= attn_ext0;
+ value += attn_ext0 * attn_ext0 * extrapolate(xsv_ext0, ysv_ext0, zsv_ext0, dx_ext0, dy_ext0, dz_ext0);
+ }
+
+ //Second extra vertex
+ double attn_ext1 = 2 - dx_ext1 * dx_ext1 - dy_ext1 * dy_ext1 - dz_ext1 * dz_ext1;
+ if (attn_ext1 > 0)
+ {
+ attn_ext1 *= attn_ext1;
+ value += attn_ext1 * attn_ext1 * extrapolate(xsv_ext1, ysv_ext1, zsv_ext1, dx_ext1, dy_ext1, dz_ext1);
+ }
+
+ return value / m_norm3d;
+ }
+
+ double Noise::eval(double x, double y, double z, double w) const
+ {
+ //Place input coordinates on simplectic honeycomb.
+ double stretchOffset = (x + y + z + w) * m_stretch4d;
+ double xs = x + stretchOffset;
+ double ys = y + stretchOffset;
+ double zs = z + stretchOffset;
+ double ws = w + stretchOffset;
+
+ //static_cast(floor to get simplectic honeycomb coordinates of rhombo-hypercube super-cell origin.
+ int xsb = static_cast(floor(xs));
+ int ysb = static_cast(floor(ys));
+ int zsb = static_cast(floor(zs));
+ int wsb = static_cast(floor(ws));
+
+ //Skew out to get actual coordinates of stretched rhombo-hypercube origin. We'll need these later.
+ double squishOffset = (xsb + ysb + zsb + wsb) * m_squish4d;
+ double xb = xsb + squishOffset;
+ double yb = ysb + squishOffset;
+ double zb = zsb + squishOffset;
+ double wb = wsb + squishOffset;
+
+ //Compute simplectic honeycomb coordinates relative to rhombo-hypercube origin.
+ double xins = xs - xsb;
+ double yins = ys - ysb;
+ double zins = zs - zsb;
+ double wins = ws - wsb;
+
+ //Sum those together to get a value that determines which region we're in.
+ double inSum = xins + yins + zins + wins;
+
+ //Positions relative to origin point.
+ double dx0 = x - xb;
+ double dy0 = y - yb;
+ double dz0 = z - zb;
+ double dw0 = w - wb;
+
+ //We'll be defining these inside the next block and using them afterwards.
+ double dx_ext0, dy_ext0, dz_ext0, dw_ext0;
+ double dx_ext1, dy_ext1, dz_ext1, dw_ext1;
+ double dx_ext2, dy_ext2, dz_ext2, dw_ext2;
+ int xsv_ext0, ysv_ext0, zsv_ext0, wsv_ext0;
+ int xsv_ext1, ysv_ext1, zsv_ext1, wsv_ext1;
+ int xsv_ext2, ysv_ext2, zsv_ext2, wsv_ext2;
+
+ double value = 0;
+ if (inSum <= 1)
+ { //We're inside the pentachoron (4-Simplex) at (0,0,0,0)
+
+//Determine which two of (0,0,0,1), (0,0,1,0), (0,1,0,0), (1,0,0,0) are closest.
+ char aPoint = 0x01;
+ double aScore = xins;
+ char bPoint = 0x02;
+ double bScore = yins;
+ if (aScore >= bScore && zins > bScore)
+ {
+ bScore = zins;
+ bPoint = 0x04;
+ }
+ else if (aScore < bScore && zins > aScore)
+ {
+ aScore = zins;
+ aPoint = 0x04;
+ }
+ if (aScore >= bScore && wins > bScore)
+ {
+ bScore = wins;
+ bPoint = 0x08;
+ }
+ else if (aScore < bScore && wins > aScore)
+ {
+ aScore = wins;
+ aPoint = 0x08;
+ }
+
+ //Now we determine the three lattice points not part of the pentachoron that may contribute.
+ //This depends on the closest two pentachoron vertices, including (0,0,0,0)
+ double uins = 1 - inSum;
+ if (uins > aScore || uins > bScore)
+ { //(0,0,0,0) is one of the closest two pentachoron vertices.
+ char c = (bScore > aScore ? bPoint : aPoint); //Our other closest vertex is the closest out of a and b.
+ if ((c & 0x01) == 0)
+ {
+ xsv_ext0 = xsb - 1;
+ xsv_ext1 = xsv_ext2 = xsb;
+ dx_ext0 = dx0 + 1;
+ dx_ext1 = dx_ext2 = dx0;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsv_ext2 = xsb + 1;
+ dx_ext0 = dx_ext1 = dx_ext2 = dx0 - 1;
+ }
+
+ if ((c & 0x02) == 0)
+ {
+ ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb;
+ dy_ext0 = dy_ext1 = dy_ext2 = dy0;
+ if ((c & 0x01) == 0x01)
+ {
+ ysv_ext0 -= 1;
+ dy_ext0 += 1;
+ }
+ else
+ {
+ ysv_ext1 -= 1;
+ dy_ext1 += 1;
+ }
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb + 1;
+ dy_ext0 = dy_ext1 = dy_ext2 = dy0 - 1;
+ }
+
+ if ((c & 0x04) == 0)
+ {
+ zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb;
+ dz_ext0 = dz_ext1 = dz_ext2 = dz0;
+ if ((c & 0x03) != 0)
+ {
+ if ((c & 0x03) == 0x03)
+ {
+ zsv_ext0 -= 1;
+ dz_ext0 += 1;
+ }
+ else
+ {
+ zsv_ext1 -= 1;
+ dz_ext1 += 1;
+ }
+ }
+ else
+ {
+ zsv_ext2 -= 1;
+ dz_ext2 += 1;
+ }
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb + 1;
+ dz_ext0 = dz_ext1 = dz_ext2 = dz0 - 1;
+ }
+
+ if ((c & 0x08) == 0)
+ {
+ wsv_ext0 = wsv_ext1 = wsb;
+ wsv_ext2 = wsb - 1;
+ dw_ext0 = dw_ext1 = dw0;
+ dw_ext2 = dw0 + 1;
+ }
+ else
+ {
+ wsv_ext0 = wsv_ext1 = wsv_ext2 = wsb + 1;
+ dw_ext0 = dw_ext1 = dw_ext2 = dw0 - 1;
+ }
+ }
+ else
+ { //(0,0,0,0) is not one of the closest two pentachoron vertices.
+ char c = static_cast(aPoint | bPoint); //Our three extra vertices are determined by the closest two.
+
+ if ((c & 0x01) == 0)
+ {
+ xsv_ext0 = xsv_ext2 = xsb;
+ xsv_ext1 = xsb - 1;
+ dx_ext0 = dx0 - 2 * m_squish4d;
+ dx_ext1 = dx0 + 1 - m_squish4d;
+ dx_ext2 = dx0 - m_squish4d;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsv_ext2 = xsb + 1;
+ dx_ext0 = dx0 - 1 - 2 * m_squish4d;
+ dx_ext1 = dx_ext2 = dx0 - 1 - m_squish4d;
+ }
+
+ if ((c & 0x02) == 0)
+ {
+ ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb;
+ dy_ext0 = dy0 - 2 * m_squish4d;
+ dy_ext1 = dy_ext2 = dy0 - m_squish4d;
+ if ((c & 0x01) == 0x01)
+ {
+ ysv_ext1 -= 1;
+ dy_ext1 += 1;
+ }
+ else
+ {
+ ysv_ext2 -= 1;
+ dy_ext2 += 1;
+ }
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb + 1;
+ dy_ext0 = dy0 - 1 - 2 * m_squish4d;
+ dy_ext1 = dy_ext2 = dy0 - 1 - m_squish4d;
+ }
+
+ if ((c & 0x04) == 0)
+ {
+ zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb;
+ dz_ext0 = dz0 - 2 * m_squish4d;
+ dz_ext1 = dz_ext2 = dz0 - m_squish4d;
+ if ((c & 0x03) == 0x03)
+ {
+ zsv_ext1 -= 1;
+ dz_ext1 += 1;
+ }
+ else
+ {
+ zsv_ext2 -= 1;
+ dz_ext2 += 1;
+ }
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb + 1;
+ dz_ext0 = dz0 - 1 - 2 * m_squish4d;
+ dz_ext1 = dz_ext2 = dz0 - 1 - m_squish4d;
+ }
+
+ if ((c & 0x08) == 0)
+ {
+ wsv_ext0 = wsv_ext1 = wsb;
+ wsv_ext2 = wsb - 1;
+ dw_ext0 = dw0 - 2 * m_squish4d;
+ dw_ext1 = dw0 - m_squish4d;
+ dw_ext2 = dw0 + 1 - m_squish4d;
+ }
+ else
+ {
+ wsv_ext0 = wsv_ext1 = wsv_ext2 = wsb + 1;
+ dw_ext0 = dw0 - 1 - 2 * m_squish4d;
+ dw_ext1 = dw_ext2 = dw0 - 1 - m_squish4d;
+ }
+ }
+
+ //Contribution (0,0,0,0)
+ double attn0 = 2 - dx0 * dx0 - dy0 * dy0 - dz0 * dz0 - dw0 * dw0;
+ if (attn0 > 0)
+ {
+ attn0 *= attn0;
+ value += attn0 * attn0 * extrapolate(xsb + 0, ysb + 0, zsb + 0, wsb + 0, dx0, dy0, dz0, dw0);
+ }
+
+ //Contribution (1,0,0,0)
+ double dx1 = dx0 - 1 - m_squish4d;
+ double dy1 = dy0 - 0 - m_squish4d;
+ double dz1 = dz0 - 0 - m_squish4d;
+ double dw1 = dw0 - 0 - m_squish4d;
+ double attn1 = 2 - dx1 * dx1 - dy1 * dy1 - dz1 * dz1 - dw1 * dw1;
+ if (attn1 > 0)
+ {
+ attn1 *= attn1;
+ value += attn1 * attn1 * extrapolate(xsb + 1, ysb + 0, zsb + 0, wsb + 0, dx1, dy1, dz1, dw1);
+ }
+
+ //Contribution (0,1,0,0)
+ double dx2 = dx0 - 0 - m_squish4d;
+ double dy2 = dy0 - 1 - m_squish4d;
+ double dz2 = dz1;
+ double dw2 = dw1;
+ double attn2 = 2 - dx2 * dx2 - dy2 * dy2 - dz2 * dz2 - dw2 * dw2;
+ if (attn2 > 0)
+ {
+ attn2 *= attn2;
+ value += attn2 * attn2 * extrapolate(xsb + 0, ysb + 1, zsb + 0, wsb + 0, dx2, dy2, dz2, dw2);
+ }
+
+ //Contribution (0,0,1,0)
+ double dx3 = dx2;
+ double dy3 = dy1;
+ double dz3 = dz0 - 1 - m_squish4d;
+ double dw3 = dw1;
+ double attn3 = 2 - dx3 * dx3 - dy3 * dy3 - dz3 * dz3 - dw3 * dw3;
+ if (attn3 > 0)
+ {
+ attn3 *= attn3;
+ value += attn3 * attn3 * extrapolate(xsb + 0, ysb + 0, zsb + 1, wsb + 0, dx3, dy3, dz3, dw3);
+ }
+
+ //Contribution (0,0,0,1)
+ double dx4 = dx2;
+ double dy4 = dy1;
+ double dz4 = dz1;
+ double dw4 = dw0 - 1 - m_squish4d;
+ double attn4 = 2 - dx4 * dx4 - dy4 * dy4 - dz4 * dz4 - dw4 * dw4;
+ if (attn4 > 0)
+ {
+ attn4 *= attn4;
+ value += attn4 * attn4 * extrapolate(xsb + 0, ysb + 0, zsb + 0, wsb + 1, dx4, dy4, dz4, dw4);
+ }
+ }
+ else if (inSum >= 3)
+ { //We're inside the pentachoron (4-Simplex) at (1,1,1,1)
+//Determine which two of (1,1,1,0), (1,1,0,1), (1,0,1,1), (0,1,1,1) are closest.
+ char aPoint = 0x0E;
+ double aScore = xins;
+ char bPoint = 0x0D;
+ double bScore = yins;
+ if (aScore <= bScore && zins < bScore)
+ {
+ bScore = zins;
+ bPoint = 0x0B;
+ }
+ else if (aScore > bScore && zins < aScore)
+ {
+ aScore = zins;
+ aPoint = 0x0B;
+ }
+ if (aScore <= bScore && wins < bScore)
+ {
+ bScore = wins;
+ bPoint = 0x07;
+ }
+ else if (aScore > bScore && wins < aScore)
+ {
+ aScore = wins;
+ aPoint = 0x07;
+ }
+
+ //Now we determine the three lattice points not part of the pentachoron that may contribute.
+ //This depends on the closest two pentachoron vertices, including (0,0,0,0)
+ double uins = 4 - inSum;
+ if (uins < aScore || uins < bScore)
+ { //(1,1,1,1) is one of the closest two pentachoron vertices.
+ char c = (bScore < aScore ? bPoint : aPoint); //Our other closest vertex is the closest out of a and b.
+
+ if ((c & 0x01) != 0)
+ {
+ xsv_ext0 = xsb + 2;
+ xsv_ext1 = xsv_ext2 = xsb + 1;
+ dx_ext0 = dx0 - 2 - 4 * m_squish4d;
+ dx_ext1 = dx_ext2 = dx0 - 1 - 4 * m_squish4d;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsv_ext2 = xsb;
+ dx_ext0 = dx_ext1 = dx_ext2 = dx0 - 4 * m_squish4d;
+ }
+
+ if ((c & 0x02) != 0)
+ {
+ ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb + 1;
+ dy_ext0 = dy_ext1 = dy_ext2 = dy0 - 1 - 4 * m_squish4d;
+ if ((c & 0x01) != 0)
+ {
+ ysv_ext1 += 1;
+ dy_ext1 -= 1;
+ }
+ else
+ {
+ ysv_ext0 += 1;
+ dy_ext0 -= 1;
+ }
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb;
+ dy_ext0 = dy_ext1 = dy_ext2 = dy0 - 4 * m_squish4d;
+ }
+
+ if ((c & 0x04) != 0)
+ {
+ zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb + 1;
+ dz_ext0 = dz_ext1 = dz_ext2 = dz0 - 1 - 4 * m_squish4d;
+ if ((c & 0x03) != 0x03)
+ {
+ if ((c & 0x03) == 0)
+ {
+ zsv_ext0 += 1;
+ dz_ext0 -= 1;
+ }
+ else
+ {
+ zsv_ext1 += 1;
+ dz_ext1 -= 1;
+ }
+ }
+ else
+ {
+ zsv_ext2 += 1;
+ dz_ext2 -= 1;
+ }
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb;
+ dz_ext0 = dz_ext1 = dz_ext2 = dz0 - 4 * m_squish4d;
+ }
+
+ if ((c & 0x08) != 0)
+ {
+ wsv_ext0 = wsv_ext1 = wsb + 1;
+ wsv_ext2 = wsb + 2;
+ dw_ext0 = dw_ext1 = dw0 - 1 - 4 * m_squish4d;
+ dw_ext2 = dw0 - 2 - 4 * m_squish4d;
+ }
+ else
+ {
+ wsv_ext0 = wsv_ext1 = wsv_ext2 = wsb;
+ dw_ext0 = dw_ext1 = dw_ext2 = dw0 - 4 * m_squish4d;
+ }
+ }
+ else
+ { //(1,1,1,1) is not one of the closest two pentachoron vertices.
+ char c = static_cast(aPoint & bPoint); //Our three extra vertices are determined by the closest two.
+
+ if ((c & 0x01) != 0)
+ {
+ xsv_ext0 = xsv_ext2 = xsb + 1;
+ xsv_ext1 = xsb + 2;
+ dx_ext0 = dx0 - 1 - 2 * m_squish4d;
+ dx_ext1 = dx0 - 2 - 3 * m_squish4d;
+ dx_ext2 = dx0 - 1 - 3 * m_squish4d;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsv_ext2 = xsb;
+ dx_ext0 = dx0 - 2 * m_squish4d;
+ dx_ext1 = dx_ext2 = dx0 - 3 * m_squish4d;
+ }
+
+ if ((c & 0x02) != 0)
+ {
+ ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb + 1;
+ dy_ext0 = dy0 - 1 - 2 * m_squish4d;
+ dy_ext1 = dy_ext2 = dy0 - 1 - 3 * m_squish4d;
+ if ((c & 0x01) != 0)
+ {
+ ysv_ext2 += 1;
+ dy_ext2 -= 1;
+ }
+ else
+ {
+ ysv_ext1 += 1;
+ dy_ext1 -= 1;
+ }
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb;
+ dy_ext0 = dy0 - 2 * m_squish4d;
+ dy_ext1 = dy_ext2 = dy0 - 3 * m_squish4d;
+ }
+
+ if ((c & 0x04) != 0)
+ {
+ zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb + 1;
+ dz_ext0 = dz0 - 1 - 2 * m_squish4d;
+ dz_ext1 = dz_ext2 = dz0 - 1 - 3 * m_squish4d;
+ if ((c & 0x03) != 0)
+ {
+ zsv_ext2 += 1;
+ dz_ext2 -= 1;
+ }
+ else
+ {
+ zsv_ext1 += 1;
+ dz_ext1 -= 1;
+ }
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb;
+ dz_ext0 = dz0 - 2 * m_squish4d;
+ dz_ext1 = dz_ext2 = dz0 - 3 * m_squish4d;
+ }
+
+ if ((c & 0x08) != 0)
+ {
+ wsv_ext0 = wsv_ext1 = wsb + 1;
+ wsv_ext2 = wsb + 2;
+ dw_ext0 = dw0 - 1 - 2 * m_squish4d;
+ dw_ext1 = dw0 - 1 - 3 * m_squish4d;
+ dw_ext2 = dw0 - 2 - 3 * m_squish4d;
+ }
+ else
+ {
+ wsv_ext0 = wsv_ext1 = wsv_ext2 = wsb;
+ dw_ext0 = dw0 - 2 * m_squish4d;
+ dw_ext1 = dw_ext2 = dw0 - 3 * m_squish4d;
+ }
+ }
+
+ //Contribution (1,1,1,0)
+ double dx4 = dx0 - 1 - 3 * m_squish4d;
+ double dy4 = dy0 - 1 - 3 * m_squish4d;
+ double dz4 = dz0 - 1 - 3 * m_squish4d;
+ double dw4 = dw0 - 3 * m_squish4d;
+ double attn4 = 2 - dx4 * dx4 - dy4 * dy4 - dz4 * dz4 - dw4 * dw4;
+ if (attn4 > 0)
+ {
+ attn4 *= attn4;
+ value += attn4 * attn4 * extrapolate(xsb + 1, ysb + 1, zsb + 1, wsb + 0, dx4, dy4, dz4, dw4);
+ }
+
+ //Contribution (1,1,0,1)
+ double dx3 = dx4;
+ double dy3 = dy4;
+ double dz3 = dz0 - 3 * m_squish4d;
+ double dw3 = dw0 - 1 - 3 * m_squish4d;
+ double attn3 = 2 - dx3 * dx3 - dy3 * dy3 - dz3 * dz3 - dw3 * dw3;
+ if (attn3 > 0)
+ {
+ attn3 *= attn3;
+ value += attn3 * attn3 * extrapolate(xsb + 1, ysb + 1, zsb + 0, wsb + 1, dx3, dy3, dz3, dw3);
+ }
+
+ //Contribution (1,0,1,1)
+ double dx2 = dx4;
+ double dy2 = dy0 - 3 * m_squish4d;
+ double dz2 = dz4;
+ double dw2 = dw3;
+ double attn2 = 2 - dx2 * dx2 - dy2 * dy2 - dz2 * dz2 - dw2 * dw2;
+ if (attn2 > 0)
+ {
+ attn2 *= attn2;
+ value += attn2 * attn2 * extrapolate(xsb + 1, ysb + 0, zsb + 1, wsb + 1, dx2, dy2, dz2, dw2);
+ }
+
+ //Contribution (0,1,1,1)
+ double dx1 = dx0 - 3 * m_squish4d;
+ double dz1 = dz4;
+ double dy1 = dy4;
+ double dw1 = dw3;
+ double attn1 = 2 - dx1 * dx1 - dy1 * dy1 - dz1 * dz1 - dw1 * dw1;
+ if (attn1 > 0)
+ {
+ attn1 *= attn1;
+ value += attn1 * attn1 * extrapolate(xsb + 0, ysb + 1, zsb + 1, wsb + 1, dx1, dy1, dz1, dw1);
+ }
+
+ //Contribution (1,1,1,1)
+ dx0 = dx0 - 1 - 4 * m_squish4d;
+ dy0 = dy0 - 1 - 4 * m_squish4d;
+ dz0 = dz0 - 1 - 4 * m_squish4d;
+ dw0 = dw0 - 1 - 4 * m_squish4d;
+ double attn0 = 2 - dx0 * dx0 - dy0 * dy0 - dz0 * dz0 - dw0 * dw0;
+ if (attn0 > 0)
+ {
+ attn0 *= attn0;
+ value += attn0 * attn0 * extrapolate(xsb + 1, ysb + 1, zsb + 1, wsb + 1, dx0, dy0, dz0, dw0);
+ }
+ }
+ else if (inSum <= 2)
+ { //We're inside the first dispentachoron (Rectified 4-Simplex)
+ double aScore;
+ char aPoint;
+ bool aIsBiggerSide = true;
+ double bScore;
+ char bPoint;
+ bool bIsBiggerSide = true;
+
+ //Decide between (1,1,0,0) and (0,0,1,1)
+ if (xins + yins > zins + wins)
+ {
+ aScore = xins + yins;
+ aPoint = 0x03;
+ }
+ else
+ {
+ aScore = zins + wins;
+ aPoint = 0x0C;
+ }
+
+ //Decide between (1,0,1,0) and (0,1,0,1)
+ if (xins + zins > yins + wins)
+ {
+ bScore = xins + zins;
+ bPoint = 0x05;
+ }
+ else
+ {
+ bScore = yins + wins;
+ bPoint = 0x0A;
+ }
+
+ //Closer between (1,0,0,1) and (0,1,1,0) will replace the further of a and b, if closer.
+ if (xins + wins > yins + zins)
+ {
+ double score = xins + wins;
+ if (aScore >= bScore && score > bScore)
+ {
+ bScore = score;
+ bPoint = 0x09;
+ }
+ else if (aScore < bScore && score > aScore)
+ {
+ aScore = score;
+ aPoint = 0x09;
+ }
+ }
+ else
+ {
+ double score = yins + zins;
+ if (aScore >= bScore && score > bScore)
+ {
+ bScore = score;
+ bPoint = 0x06;
+ }
+ else if (aScore < bScore && score > aScore)
+ {
+ aScore = score;
+ aPoint = 0x06;
+ }
+ }
+
+ //Decide if (1,0,0,0) is closer.
+ double p1 = 2 - inSum + xins;
+ if (aScore >= bScore && p1 > bScore)
+ {
+ bScore = p1;
+ bPoint = 0x01;
+ bIsBiggerSide = false;
+ }
+ else if (aScore < bScore && p1 > aScore)
+ {
+ aScore = p1;
+ aPoint = 0x01;
+ aIsBiggerSide = false;
+ }
+
+ //Decide if (0,1,0,0) is closer.
+ double p2 = 2 - inSum + yins;
+ if (aScore >= bScore && p2 > bScore)
+ {
+ bScore = p2;
+ bPoint = 0x02;
+ bIsBiggerSide = false;
+ }
+ else if (aScore < bScore && p2 > aScore)
+ {
+ aScore = p2;
+ aPoint = 0x02;
+ aIsBiggerSide = false;
+ }
+
+ //Decide if (0,0,1,0) is closer.
+ double p3 = 2 - inSum + zins;
+ if (aScore >= bScore && p3 > bScore)
+ {
+ bScore = p3;
+ bPoint = 0x04;
+ bIsBiggerSide = false;
+ }
+ else if (aScore < bScore && p3 > aScore)
+ {
+ aScore = p3;
+ aPoint = 0x04;
+ aIsBiggerSide = false;
+ }
+
+ //Decide if (0,0,0,1) is closer.
+ double p4 = 2 - inSum + wins;
+ if (aScore >= bScore && p4 > bScore)
+ {
+ bScore = p4;
+ bPoint = 0x08;
+ bIsBiggerSide = false;
+ }
+ else if (aScore < bScore && p4 > aScore)
+ {
+ aScore = p4;
+ aPoint = 0x08;
+ aIsBiggerSide = false;
+ }
+
+ //Where each of the two closest points are determines how the extra three vertices are calculated.
+ if (aIsBiggerSide == bIsBiggerSide)
+ {
+ if (aIsBiggerSide)
+ { //Both closest points on the bigger side
+ char c1 = static_cast(aPoint | bPoint);
+ char c2 = static_cast(aPoint & bPoint);
+ if ((c1 & 0x01) == 0)
+ {
+ xsv_ext0 = xsb;
+ xsv_ext1 = xsb - 1;
+ dx_ext0 = dx0 - 3 * m_squish4d;
+ dx_ext1 = dx0 + 1 - 2 * m_squish4d;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsb + 1;
+ dx_ext0 = dx0 - 1 - 3 * m_squish4d;
+ dx_ext1 = dx0 - 1 - 2 * m_squish4d;
+ }
+
+ if ((c1 & 0x02) == 0)
+ {
+ ysv_ext0 = ysb;
+ ysv_ext1 = ysb - 1;
+ dy_ext0 = dy0 - 3 * m_squish4d;
+ dy_ext1 = dy0 + 1 - 2 * m_squish4d;
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysb + 1;
+ dy_ext0 = dy0 - 1 - 3 * m_squish4d;
+ dy_ext1 = dy0 - 1 - 2 * m_squish4d;
+ }
+
+ if ((c1 & 0x04) == 0)
+ {
+ zsv_ext0 = zsb;
+ zsv_ext1 = zsb - 1;
+ dz_ext0 = dz0 - 3 * m_squish4d;
+ dz_ext1 = dz0 + 1 - 2 * m_squish4d;
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsb + 1;
+ dz_ext0 = dz0 - 1 - 3 * m_squish4d;
+ dz_ext1 = dz0 - 1 - 2 * m_squish4d;
+ }
+
+ if ((c1 & 0x08) == 0)
+ {
+ wsv_ext0 = wsb;
+ wsv_ext1 = wsb - 1;
+ dw_ext0 = dw0 - 3 * m_squish4d;
+ dw_ext1 = dw0 + 1 - 2 * m_squish4d;
+ }
+ else
+ {
+ wsv_ext0 = wsv_ext1 = wsb + 1;
+ dw_ext0 = dw0 - 1 - 3 * m_squish4d;
+ dw_ext1 = dw0 - 1 - 2 * m_squish4d;
+ }
+
+ //One combination is a permutation of (0,0,0,2) based on c2
+ xsv_ext2 = xsb;
+ ysv_ext2 = ysb;
+ zsv_ext2 = zsb;
+ wsv_ext2 = wsb;
+ dx_ext2 = dx0 - 2 * m_squish4d;
+ dy_ext2 = dy0 - 2 * m_squish4d;
+ dz_ext2 = dz0 - 2 * m_squish4d;
+ dw_ext2 = dw0 - 2 * m_squish4d;
+ if ((c2 & 0x01) != 0)
+ {
+ xsv_ext2 += 2;
+ dx_ext2 -= 2;
+ }
+ else if ((c2 & 0x02) != 0)
+ {
+ ysv_ext2 += 2;
+ dy_ext2 -= 2;
+ }
+ else if ((c2 & 0x04) != 0)
+ {
+ zsv_ext2 += 2;
+ dz_ext2 -= 2;
+ }
+ else
+ {
+ wsv_ext2 += 2;
+ dw_ext2 -= 2;
+ }
+
+ }
+ else
+ { //Both closest points on the smaller side
+ //One of the two extra points is (0,0,0,0)
+ xsv_ext2 = xsb;
+ ysv_ext2 = ysb;
+ zsv_ext2 = zsb;
+ wsv_ext2 = wsb;
+ dx_ext2 = dx0;
+ dy_ext2 = dy0;
+ dz_ext2 = dz0;
+ dw_ext2 = dw0;
+
+ //Other two points are based on the omitted axes.
+ char c = static_cast(aPoint | bPoint);
+
+ if ((c & 0x01) == 0)
+ {
+ xsv_ext0 = xsb - 1;
+ xsv_ext1 = xsb;
+ dx_ext0 = dx0 + 1 - m_squish4d;
+ dx_ext1 = dx0 - m_squish4d;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsb + 1;
+ dx_ext0 = dx_ext1 = dx0 - 1 - m_squish4d;
+ }
+
+ if ((c & 0x02) == 0)
+ {
+ ysv_ext0 = ysv_ext1 = ysb;
+ dy_ext0 = dy_ext1 = dy0 - m_squish4d;
+ if ((c & 0x01) == 0x01)
+ {
+ ysv_ext0 -= 1;
+ dy_ext0 += 1;
+ }
+ else
+ {
+ ysv_ext1 -= 1;
+ dy_ext1 += 1;
+ }
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysb + 1;
+ dy_ext0 = dy_ext1 = dy0 - 1 - m_squish4d;
+ }
+
+ if ((c & 0x04) == 0)
+ {
+ zsv_ext0 = zsv_ext1 = zsb;
+ dz_ext0 = dz_ext1 = dz0 - m_squish4d;
+ if ((c & 0x03) == 0x03)
+ {
+ zsv_ext0 -= 1;
+ dz_ext0 += 1;
+ }
+ else
+ {
+ zsv_ext1 -= 1;
+ dz_ext1 += 1;
+ }
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsb + 1;
+ dz_ext0 = dz_ext1 = dz0 - 1 - m_squish4d;
+ }
+
+ if ((c & 0x08) == 0)
+ {
+ wsv_ext0 = wsb;
+ wsv_ext1 = wsb - 1;
+ dw_ext0 = dw0 - m_squish4d;
+ dw_ext1 = dw0 + 1 - m_squish4d;
+ }
+ else
+ {
+ wsv_ext0 = wsv_ext1 = wsb + 1;
+ dw_ext0 = dw_ext1 = dw0 - 1 - m_squish4d;
+ }
+
+ }
+ }
+ else
+ { //One point on each "side"
+ char c1, c2;
+ if (aIsBiggerSide)
+ {
+ c1 = aPoint;
+ c2 = bPoint;
+ }
+ else
+ {
+ c1 = bPoint;
+ c2 = aPoint;
+ }
+
+ //Two contributions are the bigger-sided point with each 0 replaced with -1.
+ if ((c1 & 0x01) == 0)
+ {
+ xsv_ext0 = xsb - 1;
+ xsv_ext1 = xsb;
+ dx_ext0 = dx0 + 1 - m_squish4d;
+ dx_ext1 = dx0 - m_squish4d;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsb + 1;
+ dx_ext0 = dx_ext1 = dx0 - 1 - m_squish4d;
+ }
+
+ if ((c1 & 0x02) == 0)
+ {
+ ysv_ext0 = ysv_ext1 = ysb;
+ dy_ext0 = dy_ext1 = dy0 - m_squish4d;
+ if ((c1 & 0x01) == 0x01)
+ {
+ ysv_ext0 -= 1;
+ dy_ext0 += 1;
+ }
+ else
+ {
+ ysv_ext1 -= 1;
+ dy_ext1 += 1;
+ }
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysb + 1;
+ dy_ext0 = dy_ext1 = dy0 - 1 - m_squish4d;
+ }
+
+ if ((c1 & 0x04) == 0)
+ {
+ zsv_ext0 = zsv_ext1 = zsb;
+ dz_ext0 = dz_ext1 = dz0 - m_squish4d;
+ if ((c1 & 0x03) == 0x03)
+ {
+ zsv_ext0 -= 1;
+ dz_ext0 += 1;
+ }
+ else
+ {
+ zsv_ext1 -= 1;
+ dz_ext1 += 1;
+ }
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsb + 1;
+ dz_ext0 = dz_ext1 = dz0 - 1 - m_squish4d;
+ }
+
+ if ((c1 & 0x08) == 0)
+ {
+ wsv_ext0 = wsb;
+ wsv_ext1 = wsb - 1;
+ dw_ext0 = dw0 - m_squish4d;
+ dw_ext1 = dw0 + 1 - m_squish4d;
+ }
+ else
+ {
+ wsv_ext0 = wsv_ext1 = wsb + 1;
+ dw_ext0 = dw_ext1 = dw0 - 1 - m_squish4d;
+ }
+
+ //One contribution is a permutation of (0,0,0,2) based on the smaller-sided point
+ xsv_ext2 = xsb;
+ ysv_ext2 = ysb;
+ zsv_ext2 = zsb;
+ wsv_ext2 = wsb;
+ dx_ext2 = dx0 - 2 * m_squish4d;
+ dy_ext2 = dy0 - 2 * m_squish4d;
+ dz_ext2 = dz0 - 2 * m_squish4d;
+ dw_ext2 = dw0 - 2 * m_squish4d;
+ if ((c2 & 0x01) != 0)
+ {
+ xsv_ext2 += 2;
+ dx_ext2 -= 2;
+ }
+ else if ((c2 & 0x02) != 0)
+ {
+ ysv_ext2 += 2;
+ dy_ext2 -= 2;
+ }
+ else if ((c2 & 0x04) != 0)
+ {
+ zsv_ext2 += 2;
+ dz_ext2 -= 2;
+ }
+ else
+ {
+ wsv_ext2 += 2;
+ dw_ext2 -= 2;
+ }
+ }
+
+ //Contribution (1,0,0,0)
+ double dx1 = dx0 - 1 - m_squish4d;
+ double dy1 = dy0 - 0 - m_squish4d;
+ double dz1 = dz0 - 0 - m_squish4d;
+ double dw1 = dw0 - 0 - m_squish4d;
+ double attn1 = 2 - dx1 * dx1 - dy1 * dy1 - dz1 * dz1 - dw1 * dw1;
+ if (attn1 > 0)
+ {
+ attn1 *= attn1;
+ value += attn1 * attn1 * extrapolate(xsb + 1, ysb + 0, zsb + 0, wsb + 0, dx1, dy1, dz1, dw1);
+ }
+
+ //Contribution (0,1,0,0)
+ double dx2 = dx0 - 0 - m_squish4d;
+ double dy2 = dy0 - 1 - m_squish4d;
+ double dz2 = dz1;
+ double dw2 = dw1;
+ double attn2 = 2 - dx2 * dx2 - dy2 * dy2 - dz2 * dz2 - dw2 * dw2;
+ if (attn2 > 0)
+ {
+ attn2 *= attn2;
+ value += attn2 * attn2 * extrapolate(xsb + 0, ysb + 1, zsb + 0, wsb + 0, dx2, dy2, dz2, dw2);
+ }
+
+ //Contribution (0,0,1,0)
+ double dx3 = dx2;
+ double dy3 = dy1;
+ double dz3 = dz0 - 1 - m_squish4d;
+ double dw3 = dw1;
+ double attn3 = 2 - dx3 * dx3 - dy3 * dy3 - dz3 * dz3 - dw3 * dw3;
+ if (attn3 > 0)
+ {
+ attn3 *= attn3;
+ value += attn3 * attn3 * extrapolate(xsb + 0, ysb + 0, zsb + 1, wsb + 0, dx3, dy3, dz3, dw3);
+ }
+
+ //Contribution (0,0,0,1)
+ double dx4 = dx2;
+ double dy4 = dy1;
+ double dz4 = dz1;
+ double dw4 = dw0 - 1 - m_squish4d;
+ double attn4 = 2 - dx4 * dx4 - dy4 * dy4 - dz4 * dz4 - dw4 * dw4;
+ if (attn4 > 0)
+ {
+ attn4 *= attn4;
+ value += attn4 * attn4 * extrapolate(xsb + 0, ysb + 0, zsb + 0, wsb + 1, dx4, dy4, dz4, dw4);
+ }
+
+ //Contribution (1,1,0,0)
+ double dx5 = dx0 - 1 - 2 * m_squish4d;
+ double dy5 = dy0 - 1 - 2 * m_squish4d;
+ double dz5 = dz0 - 0 - 2 * m_squish4d;
+ double dw5 = dw0 - 0 - 2 * m_squish4d;
+ double attn5 = 2 - dx5 * dx5 - dy5 * dy5 - dz5 * dz5 - dw5 * dw5;
+ if (attn5 > 0)
+ {
+ attn5 *= attn5;
+ value += attn5 * attn5 * extrapolate(xsb + 1, ysb + 1, zsb + 0, wsb + 0, dx5, dy5, dz5, dw5);
+ }
+
+ //Contribution (1,0,1,0)
+ double dx6 = dx0 - 1 - 2 * m_squish4d;
+ double dy6 = dy0 - 0 - 2 * m_squish4d;
+ double dz6 = dz0 - 1 - 2 * m_squish4d;
+ double dw6 = dw0 - 0 - 2 * m_squish4d;
+ double attn6 = 2 - dx6 * dx6 - dy6 * dy6 - dz6 * dz6 - dw6 * dw6;
+ if (attn6 > 0)
+ {
+ attn6 *= attn6;
+ value += attn6 * attn6 * extrapolate(xsb + 1, ysb + 0, zsb + 1, wsb + 0, dx6, dy6, dz6, dw6);
+ }
+
+ //Contribution (1,0,0,1)
+ double dx7 = dx0 - 1 - 2 * m_squish4d;
+ double dy7 = dy0 - 0 - 2 * m_squish4d;
+ double dz7 = dz0 - 0 - 2 * m_squish4d;
+ double dw7 = dw0 - 1 - 2 * m_squish4d;
+ double attn7 = 2 - dx7 * dx7 - dy7 * dy7 - dz7 * dz7 - dw7 * dw7;
+ if (attn7 > 0)
+ {
+ attn7 *= attn7;
+ value += attn7 * attn7 * extrapolate(xsb + 1, ysb + 0, zsb + 0, wsb + 1, dx7, dy7, dz7, dw7);
+ }
+
+ //Contribution (0,1,1,0)
+ double dx8 = dx0 - 0 - 2 * m_squish4d;
+ double dy8 = dy0 - 1 - 2 * m_squish4d;
+ double dz8 = dz0 - 1 - 2 * m_squish4d;
+ double dw8 = dw0 - 0 - 2 * m_squish4d;
+ double attn8 = 2 - dx8 * dx8 - dy8 * dy8 - dz8 * dz8 - dw8 * dw8;
+ if (attn8 > 0)
+ {
+ attn8 *= attn8;
+ value += attn8 * attn8 * extrapolate(xsb + 0, ysb + 1, zsb + 1, wsb + 0, dx8, dy8, dz8, dw8);
+ }
+
+ //Contribution (0,1,0,1)
+ double dx9 = dx0 - 0 - 2 * m_squish4d;
+ double dy9 = dy0 - 1 - 2 * m_squish4d;
+ double dz9 = dz0 - 0 - 2 * m_squish4d;
+ double dw9 = dw0 - 1 - 2 * m_squish4d;
+ double attn9 = 2 - dx9 * dx9 - dy9 * dy9 - dz9 * dz9 - dw9 * dw9;
+ if (attn9 > 0)
+ {
+ attn9 *= attn9;
+ value += attn9 * attn9 * extrapolate(xsb + 0, ysb + 1, zsb + 0, wsb + 1, dx9, dy9, dz9, dw9);
+ }
+
+ //Contribution (0,0,1,1)
+ double dx10 = dx0 - 0 - 2 * m_squish4d;
+ double dy10 = dy0 - 0 - 2 * m_squish4d;
+ double dz10 = dz0 - 1 - 2 * m_squish4d;
+ double dw10 = dw0 - 1 - 2 * m_squish4d;
+ double attn10 = 2 - dx10 * dx10 - dy10 * dy10 - dz10 * dz10 - dw10 * dw10;
+ if (attn10 > 0)
+ {
+ attn10 *= attn10;
+ value += attn10 * attn10 * extrapolate(xsb + 0, ysb + 0, zsb + 1, wsb + 1, dx10, dy10, dz10, dw10);
+ }
+ }
+ else
+ { //We're inside the second dispentachoron (Rectified 4-Simplex)
+ double aScore;
+ char aPoint;
+ bool aIsBiggerSide = true;
+ double bScore;
+ char bPoint;
+ bool bIsBiggerSide = true;
+
+ //Decide between (0,0,1,1) and (1,1,0,0)
+ if (xins + yins < zins + wins)
+ {
+ aScore = xins + yins;
+ aPoint = 0x0C;
+ }
+ else
+ {
+ aScore = zins + wins;
+ aPoint = 0x03;
+ }
+
+ //Decide between (0,1,0,1) and (1,0,1,0)
+ if (xins + zins < yins + wins)
+ {
+ bScore = xins + zins;
+ bPoint = 0x0A;
+ }
+ else
+ {
+ bScore = yins + wins;
+ bPoint = 0x05;
+ }
+
+ //Closer between (0,1,1,0) and (1,0,0,1) will replace the further of a and b, if closer.
+ if (xins + wins < yins + zins)
+ {
+ double score = xins + wins;
+ if (aScore <= bScore && score < bScore)
+ {
+ bScore = score;
+ bPoint = 0x06;
+ }
+ else if (aScore > bScore && score < aScore)
+ {
+ aScore = score;
+ aPoint = 0x06;
+ }
+ }
+ else
+ {
+ double score = yins + zins;
+ if (aScore <= bScore && score < bScore)
+ {
+ bScore = score;
+ bPoint = 0x09;
+ }
+ else if (aScore > bScore && score < aScore)
+ {
+ aScore = score;
+ aPoint = 0x09;
+ }
+ }
+
+ //Decide if (0,1,1,1) is closer.
+ double p1 = 3 - inSum + xins;
+ if (aScore <= bScore && p1 < bScore)
+ {
+ bScore = p1;
+ bPoint = 0x0E;
+ bIsBiggerSide = false;
+ }
+ else if (aScore > bScore && p1 < aScore)
+ {
+ aScore = p1;
+ aPoint = 0x0E;
+ aIsBiggerSide = false;
+ }
+
+ //Decide if (1,0,1,1) is closer.
+ double p2 = 3 - inSum + yins;
+ if (aScore <= bScore && p2 < bScore)
+ {
+ bScore = p2;
+ bPoint = 0x0D;
+ bIsBiggerSide = false;
+ }
+ else if (aScore > bScore && p2 < aScore)
+ {
+ aScore = p2;
+ aPoint = 0x0D;
+ aIsBiggerSide = false;
+ }
+
+ //Decide if (1,1,0,1) is closer.
+ double p3 = 3 - inSum + zins;
+ if (aScore <= bScore && p3 < bScore)
+ {
+ bScore = p3;
+ bPoint = 0x0B;
+ bIsBiggerSide = false;
+ }
+ else if (aScore > bScore && p3 < aScore)
+ {
+ aScore = p3;
+ aPoint = 0x0B;
+ aIsBiggerSide = false;
+ }
+
+ //Decide if (1,1,1,0) is closer.
+ double p4 = 3 - inSum + wins;
+ if (aScore <= bScore && p4 < bScore)
+ {
+ bScore = p4;
+ bPoint = 0x07;
+ bIsBiggerSide = false;
+ }
+ else if (aScore > bScore && p4 < aScore)
+ {
+ aScore = p4;
+ aPoint = 0x07;
+ aIsBiggerSide = false;
+ }
+
+ //Where each of the two closest points are determines how the extra three vertices are calculated.
+ if (aIsBiggerSide == bIsBiggerSide)
+ {
+ if (aIsBiggerSide)
+ { //Both closest points on the bigger side
+ char c1 = static_cast(aPoint & bPoint);
+ char c2 = static_cast(aPoint | bPoint);
+
+ //Two contributions are permutations of (0,0,0,1) and (0,0,0,2) based on c1
+ xsv_ext0 = xsv_ext1 = xsb;
+ ysv_ext0 = ysv_ext1 = ysb;
+ zsv_ext0 = zsv_ext1 = zsb;
+ wsv_ext0 = wsv_ext1 = wsb;
+ dx_ext0 = dx0 - m_squish4d;
+ dy_ext0 = dy0 - m_squish4d;
+ dz_ext0 = dz0 - m_squish4d;
+ dw_ext0 = dw0 - m_squish4d;
+ dx_ext1 = dx0 - 2 * m_squish4d;
+ dy_ext1 = dy0 - 2 * m_squish4d;
+ dz_ext1 = dz0 - 2 * m_squish4d;
+ dw_ext1 = dw0 - 2 * m_squish4d;
+ if ((c1 & 0x01) != 0)
+ {
+ xsv_ext0 += 1;
+ dx_ext0 -= 1;
+ xsv_ext1 += 2;
+ dx_ext1 -= 2;
+ }
+ else if ((c1 & 0x02) != 0)
+ {
+ ysv_ext0 += 1;
+ dy_ext0 -= 1;
+ ysv_ext1 += 2;
+ dy_ext1 -= 2;
+ }
+ else if ((c1 & 0x04) != 0)
+ {
+ zsv_ext0 += 1;
+ dz_ext0 -= 1;
+ zsv_ext1 += 2;
+ dz_ext1 -= 2;
+ }
+ else
+ {
+ wsv_ext0 += 1;
+ dw_ext0 -= 1;
+ wsv_ext1 += 2;
+ dw_ext1 -= 2;
+ }
+
+ //One contribution is a permutation of (1,1,1,-1) based on c2
+ xsv_ext2 = xsb + 1;
+ ysv_ext2 = ysb + 1;
+ zsv_ext2 = zsb + 1;
+ wsv_ext2 = wsb + 1;
+ dx_ext2 = dx0 - 1 - 2 * m_squish4d;
+ dy_ext2 = dy0 - 1 - 2 * m_squish4d;
+ dz_ext2 = dz0 - 1 - 2 * m_squish4d;
+ dw_ext2 = dw0 - 1 - 2 * m_squish4d;
+ if ((c2 & 0x01) == 0)
+ {
+ xsv_ext2 -= 2;
+ dx_ext2 += 2;
+ }
+ else if ((c2 & 0x02) == 0)
+ {
+ ysv_ext2 -= 2;
+ dy_ext2 += 2;
+ }
+ else if ((c2 & 0x04) == 0)
+ {
+ zsv_ext2 -= 2;
+ dz_ext2 += 2;
+ }
+ else
+ {
+ wsv_ext2 -= 2;
+ dw_ext2 += 2;
+ }
+ }
+ else
+ { //Both closest points on the smaller side
+ //One of the two extra points is (1,1,1,1)
+ xsv_ext2 = xsb + 1;
+ ysv_ext2 = ysb + 1;
+ zsv_ext2 = zsb + 1;
+ wsv_ext2 = wsb + 1;
+ dx_ext2 = dx0 - 1 - 4 * m_squish4d;
+ dy_ext2 = dy0 - 1 - 4 * m_squish4d;
+ dz_ext2 = dz0 - 1 - 4 * m_squish4d;
+ dw_ext2 = dw0 - 1 - 4 * m_squish4d;
+
+ //Other two points are based on the shared axes.
+ char c = static_cast(aPoint & bPoint);
+
+ if ((c & 0x01) != 0)
+ {
+ xsv_ext0 = xsb + 2;
+ xsv_ext1 = xsb + 1;
+ dx_ext0 = dx0 - 2 - 3 * m_squish4d;
+ dx_ext1 = dx0 - 1 - 3 * m_squish4d;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsb;
+ dx_ext0 = dx_ext1 = dx0 - 3 * m_squish4d;
+ }
+
+ if ((c & 0x02) != 0)
+ {
+ ysv_ext0 = ysv_ext1 = ysb + 1;
+ dy_ext0 = dy_ext1 = dy0 - 1 - 3 * m_squish4d;
+ if ((c & 0x01) == 0)
+ {
+ ysv_ext0 += 1;
+ dy_ext0 -= 1;
+ }
+ else
+ {
+ ysv_ext1 += 1;
+ dy_ext1 -= 1;
+ }
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysb;
+ dy_ext0 = dy_ext1 = dy0 - 3 * m_squish4d;
+ }
+
+ if ((c & 0x04) != 0)
+ {
+ zsv_ext0 = zsv_ext1 = zsb + 1;
+ dz_ext0 = dz_ext1 = dz0 - 1 - 3 * m_squish4d;
+ if ((c & 0x03) == 0)
+ {
+ zsv_ext0 += 1;
+ dz_ext0 -= 1;
+ }
+ else
+ {
+ zsv_ext1 += 1;
+ dz_ext1 -= 1;
+ }
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsb;
+ dz_ext0 = dz_ext1 = dz0 - 3 * m_squish4d;
+ }
+
+ if ((c & 0x08) != 0)
+ {
+ wsv_ext0 = wsb + 1;
+ wsv_ext1 = wsb + 2;
+ dw_ext0 = dw0 - 1 - 3 * m_squish4d;
+ dw_ext1 = dw0 - 2 - 3 * m_squish4d;
+ }
+ else
+ {
+ wsv_ext0 = wsv_ext1 = wsb;
+ dw_ext0 = dw_ext1 = dw0 - 3 * m_squish4d;
+ }
+ }
+ }
+ else
+ { //One point on each "side"
+ char c1, c2;
+ if (aIsBiggerSide)
+ {
+ c1 = aPoint;
+ c2 = bPoint;
+ }
+ else
+ {
+ c1 = bPoint;
+ c2 = aPoint;
+ }
+
+ //Two contributions are the bigger-sided point with each 1 replaced with 2.
+ if ((c1 & 0x01) != 0)
+ {
+ xsv_ext0 = xsb + 2;
+ xsv_ext1 = xsb + 1;
+ dx_ext0 = dx0 - 2 - 3 * m_squish4d;
+ dx_ext1 = dx0 - 1 - 3 * m_squish4d;
+ }
+ else
+ {
+ xsv_ext0 = xsv_ext1 = xsb;
+ dx_ext0 = dx_ext1 = dx0 - 3 * m_squish4d;
+ }
+
+ if ((c1 & 0x02) != 0)
+ {
+ ysv_ext0 = ysv_ext1 = ysb + 1;
+ dy_ext0 = dy_ext1 = dy0 - 1 - 3 * m_squish4d;
+ if ((c1 & 0x01) == 0)
+ {
+ ysv_ext0 += 1;
+ dy_ext0 -= 1;
+ }
+ else
+ {
+ ysv_ext1 += 1;
+ dy_ext1 -= 1;
+ }
+ }
+ else
+ {
+ ysv_ext0 = ysv_ext1 = ysb;
+ dy_ext0 = dy_ext1 = dy0 - 3 * m_squish4d;
+ }
+
+ if ((c1 & 0x04) != 0)
+ {
+ zsv_ext0 = zsv_ext1 = zsb + 1;
+ dz_ext0 = dz_ext1 = dz0 - 1 - 3 * m_squish4d;
+ if ((c1 & 0x03) == 0)
+ {
+ zsv_ext0 += 1;
+ dz_ext0 -= 1;
+ }
+ else
+ {
+ zsv_ext1 += 1;
+ dz_ext1 -= 1;
+ }
+ }
+ else
+ {
+ zsv_ext0 = zsv_ext1 = zsb;
+ dz_ext0 = dz_ext1 = dz0 - 3 * m_squish4d;
+ }
+
+ if ((c1 & 0x08) != 0)
+ {
+ wsv_ext0 = wsb + 1;
+ wsv_ext1 = wsb + 2;
+ dw_ext0 = dw0 - 1 - 3 * m_squish4d;
+ dw_ext1 = dw0 - 2 - 3 * m_squish4d;
+ }
+ else
+ {
+ wsv_ext0 = wsv_ext1 = wsb;
+ dw_ext0 = dw_ext1 = dw0 - 3 * m_squish4d;
+ }
+
+ //One contribution is a permutation of (1,1,1,-1) based on the smaller-sided point
+ xsv_ext2 = xsb + 1;
+ ysv_ext2 = ysb + 1;
+ zsv_ext2 = zsb + 1;
+ wsv_ext2 = wsb + 1;
+ dx_ext2 = dx0 - 1 - 2 * m_squish4d;
+ dy_ext2 = dy0 - 1 - 2 * m_squish4d;
+ dz_ext2 = dz0 - 1 - 2 * m_squish4d;
+ dw_ext2 = dw0 - 1 - 2 * m_squish4d;
+ if ((c2 & 0x01) == 0)
+ {
+ xsv_ext2 -= 2;
+ dx_ext2 += 2;
+ }
+ else if ((c2 & 0x02) == 0)
+ {
+ ysv_ext2 -= 2;
+ dy_ext2 += 2;
+ }
+ else if ((c2 & 0x04) == 0)
+ {
+ zsv_ext2 -= 2;
+ dz_ext2 += 2;
+ }
+ else
+ {
+ wsv_ext2 -= 2;
+ dw_ext2 += 2;
+ }
+ }
+
+ //Contribution (1,1,1,0)
+ double dx4 = dx0 - 1 - 3 * m_squish4d;
+ double dy4 = dy0 - 1 - 3 * m_squish4d;
+ double dz4 = dz0 - 1 - 3 * m_squish4d;
+ double dw4 = dw0 - 3 * m_squish4d;
+ double attn4 = 2 - dx4 * dx4 - dy4 * dy4 - dz4 * dz4 - dw4 * dw4;
+ if (attn4 > 0)
+ {
+ attn4 *= attn4;
+ value += attn4 * attn4 * extrapolate(xsb + 1, ysb + 1, zsb + 1, wsb + 0, dx4, dy4, dz4, dw4);
+ }
+
+ //Contribution (1,1,0,1)
+ double dx3 = dx4;
+ double dy3 = dy4;
+ double dz3 = dz0 - 3 * m_squish4d;
+ double dw3 = dw0 - 1 - 3 * m_squish4d;
+ double attn3 = 2 - dx3 * dx3 - dy3 * dy3 - dz3 * dz3 - dw3 * dw3;
+ if (attn3 > 0)
+ {
+ attn3 *= attn3;
+ value += attn3 * attn3 * extrapolate(xsb + 1, ysb + 1, zsb + 0, wsb + 1, dx3, dy3, dz3, dw3);
+ }
+
+ //Contribution (1,0,1,1)
+ double dx2 = dx4;
+ double dy2 = dy0 - 3 * m_squish4d;
+ double dz2 = dz4;
+ double dw2 = dw3;
+ double attn2 = 2 - dx2 * dx2 - dy2 * dy2 - dz2 * dz2 - dw2 * dw2;
+ if (attn2 > 0)
+ {
+ attn2 *= attn2;
+ value += attn2 * attn2 * extrapolate(xsb + 1, ysb + 0, zsb + 1, wsb + 1, dx2, dy2, dz2, dw2);
+ }
+
+ //Contribution (0,1,1,1)
+ double dx1 = dx0 - 3 * m_squish4d;
+ double dz1 = dz4;
+ double dy1 = dy4;
+ double dw1 = dw3;
+ double attn1 = 2 - dx1 * dx1 - dy1 * dy1 - dz1 * dz1 - dw1 * dw1;
+ if (attn1 > 0)
+ {
+ attn1 *= attn1;
+ value += attn1 * attn1 * extrapolate(xsb + 0, ysb + 1, zsb + 1, wsb + 1, dx1, dy1, dz1, dw1);
+ }
+
+ //Contribution (1,1,0,0)
+ double dx5 = dx0 - 1 - 2 * m_squish4d;
+ double dy5 = dy0 - 1 - 2 * m_squish4d;
+ double dz5 = dz0 - 0 - 2 * m_squish4d;
+ double dw5 = dw0 - 0 - 2 * m_squish4d;
+ double attn5 = 2 - dx5 * dx5 - dy5 * dy5 - dz5 * dz5 - dw5 * dw5;
+ if (attn5 > 0)
+ {
+ attn5 *= attn5;
+ value += attn5 * attn5 * extrapolate(xsb + 1, ysb + 1, zsb + 0, wsb + 0, dx5, dy5, dz5, dw5);
+ }
+
+ //Contribution (1,0,1,0)
+ double dx6 = dx0 - 1 - 2 * m_squish4d;
+ double dy6 = dy0 - 0 - 2 * m_squish4d;
+ double dz6 = dz0 - 1 - 2 * m_squish4d;
+ double dw6 = dw0 - 0 - 2 * m_squish4d;
+ double attn6 = 2 - dx6 * dx6 - dy6 * dy6 - dz6 * dz6 - dw6 * dw6;
+ if (attn6 > 0)
+ {
+ attn6 *= attn6;
+ value += attn6 * attn6 * extrapolate(xsb + 1, ysb + 0, zsb + 1, wsb + 0, dx6, dy6, dz6, dw6);
+ }
+
+ //Contribution (1,0,0,1)
+ double dx7 = dx0 - 1 - 2 * m_squish4d;
+ double dy7 = dy0 - 0 - 2 * m_squish4d;
+ double dz7 = dz0 - 0 - 2 * m_squish4d;
+ double dw7 = dw0 - 1 - 2 * m_squish4d;
+ double attn7 = 2 - dx7 * dx7 - dy7 * dy7 - dz7 * dz7 - dw7 * dw7;
+ if (attn7 > 0)
+ {
+ attn7 *= attn7;
+ value += attn7 * attn7 * extrapolate(xsb + 1, ysb + 0, zsb + 0, wsb + 1, dx7, dy7, dz7, dw7);
+ }
+
+ //Contribution (0,1,1,0)
+ double dx8 = dx0 - 0 - 2 * m_squish4d;
+ double dy8 = dy0 - 1 - 2 * m_squish4d;
+ double dz8 = dz0 - 1 - 2 * m_squish4d;
+ double dw8 = dw0 - 0 - 2 * m_squish4d;
+ double attn8 = 2 - dx8 * dx8 - dy8 * dy8 - dz8 * dz8 - dw8 * dw8;
+ if (attn8 > 0)
+ {
+ attn8 *= attn8;
+ value += attn8 * attn8 * extrapolate(xsb + 0, ysb + 1, zsb + 1, wsb + 0, dx8, dy8, dz8, dw8);
+ }
+
+ //Contribution (0,1,0,1)
+ double dx9 = dx0 - 0 - 2 * m_squish4d;
+ double dy9 = dy0 - 1 - 2 * m_squish4d;
+ double dz9 = dz0 - 0 - 2 * m_squish4d;
+ double dw9 = dw0 - 1 - 2 * m_squish4d;
+ double attn9 = 2 - dx9 * dx9 - dy9 * dy9 - dz9 * dz9 - dw9 * dw9;
+ if (attn9 > 0)
+ {
+ attn9 *= attn9;
+ value += attn9 * attn9 * extrapolate(xsb + 0, ysb + 1, zsb + 0, wsb + 1, dx9, dy9, dz9, dw9);
+ }
+
+ //Contribution (0,0,1,1)
+ double dx10 = dx0 - 0 - 2 * m_squish4d;
+ double dy10 = dy0 - 0 - 2 * m_squish4d;
+ double dz10 = dz0 - 1 - 2 * m_squish4d;
+ double dw10 = dw0 - 1 - 2 * m_squish4d;
+ double attn10 = 2 - dx10 * dx10 - dy10 * dy10 - dz10 * dz10 - dw10 * dw10;
+ if (attn10 > 0)
+ {
+ attn10 *= attn10;
+ value += attn10 * attn10 * extrapolate(xsb + 0, ysb + 0, zsb + 1, wsb + 1, dx10, dy10, dz10, dw10);
+ }
+ }
+
+ //First extra vertex
+ double attn_ext0 = 2 - dx_ext0 * dx_ext0 - dy_ext0 * dy_ext0 - dz_ext0 * dz_ext0 - dw_ext0 * dw_ext0;
+ if (attn_ext0 > 0)
+ {
+ attn_ext0 *= attn_ext0;
+ value += attn_ext0 * attn_ext0 * extrapolate(xsv_ext0, ysv_ext0, zsv_ext0, wsv_ext0, dx_ext0, dy_ext0, dz_ext0, dw_ext0);
+ }
+
+ //Second extra vertex
+ double attn_ext1 = 2 - dx_ext1 * dx_ext1 - dy_ext1 * dy_ext1 - dz_ext1 * dz_ext1 - dw_ext1 * dw_ext1;
+ if (attn_ext1 > 0)
+ {
+ attn_ext1 *= attn_ext1;
+ value += attn_ext1 * attn_ext1 * extrapolate(xsv_ext1, ysv_ext1, zsv_ext1, wsv_ext1, dx_ext1, dy_ext1, dz_ext1, dw_ext1);
+ }
+
+ //Third extra vertex
+ double attn_ext2 = 2 - dx_ext2 * dx_ext2 - dy_ext2 * dy_ext2 - dz_ext2 * dz_ext2 - dw_ext2 * dw_ext2;
+ if (attn_ext2 > 0)
+ {
+ attn_ext2 *= attn_ext2;
+ value += attn_ext2 * attn_ext2 * extrapolate(xsv_ext2, ysv_ext2, zsv_ext2, wsv_ext2, dx_ext2, dy_ext2, dz_ext2, dw_ext2);
+ }
+
+ return value / m_norm4d;
+ }
+
+ double Noise::extrapolate(int xsb, int ysb, double dx, double dy) const
+ {
+ int index = m_perm[(m_perm[xsb & 0xFF] + ysb) & 0xFF] & 0x0E;
+ return m_gradients2d[index] * dx
+ + m_gradients2d[index + 1] * dy;
+ }
+
+ double Noise::extrapolate(int xsb, int ysb, int zsb, double dx, double dy, double dz) const
+ {
+ int index = m_permGradIndex3d[(m_perm[(m_perm[xsb & 0xFF] + ysb) & 0xFF] + zsb) & 0xFF];
+ return m_gradients3d[index] * dx
+ + m_gradients3d[index + 1] * dy
+ + m_gradients3d[index + 2] * dz;
+ }
+
+ double Noise::extrapolate(int xsb, int ysb, int zsb, int wsb, double dx, double dy, double dz, double dw) const
+ {
+ int index = m_perm[(m_perm[(m_perm[(m_perm[xsb & 0xFF] + ysb) & 0xFF] + zsb) & 0xFF] + wsb) & 0xFF] & 0xFC;
+ return m_gradients4d[index] * dx
+ + m_gradients4d[index + 1] * dy
+ + m_gradients4d[index + 2] * dz
+ + m_gradients4d[index + 3] * dw;
+ }
+
+}
\ No newline at end of file
diff --git a/SQCSim2021/opensimplex.h b/SQCSim2021/opensimplex.h
new file mode 100644
index 0000000..4b1b1f4
--- /dev/null
+++ b/SQCSim2021/opensimplex.h
@@ -0,0 +1,51 @@
+/**
+ Open Simple Noise for C++
+
+ Port to C++ from https://gist.github.com/KdotJPG/b1270127455a94ac5d19
+ by Rickard Lundberg, 2019.
+*/
+#ifndef _OPENSIMPLEX_H__
+#define _OPENSIMPLEX_H__
+
+#include
+#include
+
+namespace OpenSimplexNoise
+{
+ class Noise
+ {
+ public:
+ Noise();
+ Noise(int64_t seed);
+ //2D Open Simplex Noise.
+ double eval(const double x, const double y) const;
+ //3D Open Simplex Noise.
+ double eval(double x, double y, double z) const;
+ //4D Open Simplex Noise.
+ double eval(double x, double y, double z, double w) const;
+ private:
+ const double m_stretch2d;
+ const double m_squish2d;
+ const double m_stretch3d;
+ const double m_squish3d;
+ const double m_stretch4d;
+ const double m_squish4d;
+
+ const double m_norm2d;
+ const double m_norm3d;
+ const double m_norm4d;
+
+ const long m_defaultSeed;
+
+ std::array m_perm;
+ std::array m_permGradIndex3d;
+ std::array m_gradients2d;
+ std::array m_gradients3d;
+ std::array m_gradients4d;
+ double extrapolate(int xsb, int ysb, double dx, double dy) const;
+ double extrapolate(int xsb, int ysb, int zsb, double dx, double dy, double dz) const;
+ double extrapolate(int xsb, int ysb, int zsb, int wsb, double dx, double dy, double dz, double dw) const;
+ };
+}
+
+#endif // _OPENSIMPLEX_H__
\ No newline at end of file
diff --git a/SQCSim2021/perlin.cpp b/SQCSim2021/perlin.cpp
deleted file mode 100644
index 6e62717..0000000
--- a/SQCSim2021/perlin.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-/* coherent noise function over 1, 2 or 3 dimensions */
-/* (copyright Ken Perlin) */
-
-#include
-#include
-#include
-
-#include "perlin.h"
-
-#define B SAMPLE_SIZE
-#define BM (SAMPLE_SIZE-1)
-
-#define N 0x1000
-#define NP 12 /* 2^N */
-#define NM 0xfff
-
-#define s_curve(t) ( t * t * (3.0f - 2.0f * t) )
-#define lerp(t, a, b) ( a + t * (b - a) )
-
-#define setup(i,b0,b1,r0,r1)\
- t = vec[i] + N;\
-b0 = ((int)t) & BM;\
-b1 = (b0+1) & BM;\
-r0 = t - (int)t;\
-r1 = r0 - 1.0f;
-
-float Perlin::noise1(float arg)
-{
- int bx0, bx1;
- float rx0, rx1, sx, t, u, v, vec[1];
-
- vec[0] = arg;
-
- if (mStart)
- {
- srand(mSeed);
- mStart = false;
- init();
- }
-
- setup(0, bx0,bx1, rx0,rx1);
-
- sx = s_curve(rx0);
-
- u = rx0 * g1[ p[ bx0 ] ];
- v = rx1 * g1[ p[ bx1 ] ];
-
- return lerp(sx, u, v);
-}
-
-float Perlin::noise2(float vec[2])
-{
- int bx0, bx1, by0, by1, b00, b10, b01, b11;
- float rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
- int i, j;
-
- if (mStart)
- {
- srand(mSeed);
- mStart = false;
- init();
- }
-
- setup(0,bx0,bx1,rx0,rx1);
- setup(1,by0,by1,ry0,ry1);
-
- i = p[bx0];
- j = p[bx1];
-
- b00 = p[i + by0];
- b10 = p[j + by0];
- b01 = p[i + by1];
- b11 = p[j + by1];
-
- sx = s_curve(rx0);
- sy = s_curve(ry0);
-
-#define at2(rx,ry) ( rx * q[0] + ry * q[1] )
-
- q = g2[b00];
- u = at2(rx0,ry0);
- q = g2[b10];
- v = at2(rx1,ry0);
- a = lerp(sx, u, v);
-
- q = g2[b01];
- u = at2(rx0,ry1);
- q = g2[b11];
- v = at2(rx1,ry1);
- b = lerp(sx, u, v);
-
- return lerp(sy, a, b);
-}
-
-float Perlin::noise3(float vec[3])
-{
- int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11;
- float rx0, rx1, ry0, ry1, rz0, rz1, *q, sy, sz, a, b, c, d, t, u, v;
- int i, j;
-
- if (mStart)
- {
- srand(mSeed);
- mStart = false;
- init();
- }
-
- setup(0, bx0,bx1, rx0,rx1);
- setup(1, by0,by1, ry0,ry1);
- setup(2, bz0,bz1, rz0,rz1);
-
- i = p[ bx0 ];
- j = p[ bx1 ];
-
- b00 = p[ i + by0 ];
- b10 = p[ j + by0 ];
- b01 = p[ i + by1 ];
- b11 = p[ j + by1 ];
-
- t = s_curve(rx0);
- sy = s_curve(ry0);
- sz = s_curve(rz0);
-
-#define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] )
-
- q = g3[ b00 + bz0 ] ; u = at3(rx0,ry0,rz0);
- q = g3[ b10 + bz0 ] ; v = at3(rx1,ry0,rz0);
- a = lerp(t, u, v);
-
- q = g3[ b01 + bz0 ] ; u = at3(rx0,ry1,rz0);
- q = g3[ b11 + bz0 ] ; v = at3(rx1,ry1,rz0);
- b = lerp(t, u, v);
-
- c = lerp(sy, a, b);
-
- q = g3[ b00 + bz1 ] ; u = at3(rx0,ry0,rz1);
- q = g3[ b10 + bz1 ] ; v = at3(rx1,ry0,rz1);
- a = lerp(t, u, v);
-
- q = g3[ b01 + bz1 ] ; u = at3(rx0,ry1,rz1);
- q = g3[ b11 + bz1 ] ; v = at3(rx1,ry1,rz1);
- b = lerp(t, u, v);
-
- d = lerp(sy, a, b);
-
- return lerp(sz, c, d);
-}
-
-void Perlin::normalize2(float v[2])
-{
- float s;
-
- s = (float)sqrt(v[0] * v[0] + v[1] * v[1]);
- s = 1.0f/s;
- v[0] = v[0] * s;
- v[1] = v[1] * s;
-}
-
-void Perlin::normalize3(float v[3])
-{
- float s;
-
- s = (float)sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
- s = 1.0f/s;
-
- v[0] = v[0] * s;
- v[1] = v[1] * s;
- v[2] = v[2] * s;
-}
-
-void Perlin::init(void)
-{
- int i, j, k;
-
- for (i = 0 ; i < B ; i++)
- {
- p[i] = i;
- g1[i] = (float)((rand() % (B + B)) - B) / B;
- for (j = 0 ; j < 2 ; j++)
- g2[i][j] = (float)((rand() % (B + B)) - B) / B;
- normalize2(g2[i]);
- for (j = 0 ; j < 3 ; j++)
- g3[i][j] = (float)((rand() % (B + B)) - B) / B;
- normalize3(g3[i]);
- }
-
- while (--i)
- {
- k = p[i];
- p[i] = p[j = rand() % B];
- p[j] = k;
- }
-
- for (i = 0 ; i < B + 2 ; i++)
- {
- p[B + i] = p[i];
- g1[B + i] = g1[i];
- for (j = 0 ; j < 2 ; j++)
- g2[B + i][j] = g2[i][j];
- for (j = 0 ; j < 3 ; j++)
- g3[B + i][j] = g3[i][j];
- }
-
-}
-
-
-float Perlin::perlin_noise_2D(float vec[2])
-{
- int terms = mOctaves;
- //float freq = mFrequency;
- float result = 0.0f;
- float amp = mAmplitude;
-
- vec[0]*=mFrequency;
- vec[1]*=mFrequency;
-
- for( int i=0; i
-
-
-#define SAMPLE_SIZE 1024
-
-class Perlin
-{
-public:
-
- Perlin(int octaves,float freq,float amp,int seed);
-
-
- float Get(float x,float y)
- {
- float vec[2];
- vec[0] = x;
- vec[1] = y;
- return perlin_noise_2D(vec);
- };
-
- float Get(float x,float y, float z)
- {
- float vec[3];
- vec[0] = x;
- vec[1] = y;
- vec[2] = z;
- return perlin_noise_3D(vec);
- };
-
-private:
- void init_perlin(int n,float p);
- float perlin_noise_2D(float vec[2]);
- float perlin_noise_3D(float vec[3]);
-
- float noise1(float arg);
- float noise2(float vec[2]);
- float noise3(float vec[3]);
- void normalize2(float v[2]);
- void normalize3(float v[3]);
- void init(void);
-
- int mOctaves;
- float mFrequency;
- float mAmplitude;
- int mSeed;
-
- int p[SAMPLE_SIZE + SAMPLE_SIZE + 2];
- float g3[SAMPLE_SIZE + SAMPLE_SIZE + 2][3];
- float g2[SAMPLE_SIZE + SAMPLE_SIZE + 2][2];
- float g1[SAMPLE_SIZE + SAMPLE_SIZE + 2];
- bool mStart;
-
-};
-
-#endif
diff --git a/SQCSim2021/world.cpp b/SQCSim2021/world.cpp
index 5fa0880..3042df7 100644
--- a/SQCSim2021/world.cpp
+++ b/SQCSim2021/world.cpp
@@ -125,12 +125,12 @@ void World::GetScope(unsigned int& x, unsigned int& y) {
y = m_center[1];
}
-void World::Update(int& rendercount, Bullet* bullets[MAX_BULLETS], Player& player, Transformation& world, Shader& shader, TextureAtlas& atlas, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]) {
+void World::Update(int& rendercount, Bullet* bullets[MAX_BULLETS], Player& player, Transformation& world, Shader& shader, TextureAtlas& atlas, BlockInfo* blockinfo[BTYPE_LAST]) {
glStencilFunc(GL_EQUAL, 1, 0x00);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
atlas.Bind();
RenderWorld(rendercount, player, world, shader);
- UpdateWorld(player, perlin, blockinfo);
+ UpdateWorld(player, blockinfo);
TransposeWorld(player, bullets);
shader.Disable();
glStencilFunc(GL_GREATER, 1, 0xFF);
@@ -301,7 +301,7 @@ void World::RenderWorld(int& rendercount, Player& player, Transformation& world,
shader.Disable();
};
-void World::UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]) {
+void World::UpdateWorld(Player& player, BlockInfo* blockinfo[BTYPE_LAST]) {
int cx = player.GetPosition().x;
int cy = player.GetPosition().z;
static int frameGenerate = 0;
@@ -466,9 +466,10 @@ void World::UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTY
else m_tbDeleted.pop_back();
}
- for (int x = 0; x < threads; ++x)
+ for (int x = 0; x < threads; ++x) {
delThList[x].wait();
-
+ delThList[x].get();
+ }
}
int World::GettbDeleted() const { return m_tbDeleted.size(); }
\ No newline at end of file
diff --git a/SQCSim2021/world.h b/SQCSim2021/world.h
index ab37cf7..d4b1545 100644
--- a/SQCSim2021/world.h
+++ b/SQCSim2021/world.h
@@ -1,20 +1,19 @@
#ifndef WORLD_H__
#define WORLD_H__
+#include
+#include
+#include
+#include
+#include
#include "define.h"
#include "chunk.h"
#include "array2d.h"
#include "vector3.h"
#include "player.h"
#include "transformation.h"
-#include "perlin.h"
#include "shader.h"
#include "bullet.h"
#include "textureatlas.h"
-#include
-#include
-#include
-#include
-#include
class Chunk;
class Player;
@@ -33,7 +32,7 @@ public:
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
- void Update(int& rendercount, Bullet* bullets[MAX_BULLETS], Player& player, Transformation& world, Shader& shader, TextureAtlas& atlas, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]);
+ void Update(int& rendercount, Bullet* bullets[MAX_BULLETS], Player& player, Transformation& world, Shader& shader, TextureAtlas& atlas, BlockInfo* blockinfo[BTYPE_LAST]);
void GetScope(unsigned int& x, unsigned int& y);
@@ -49,7 +48,7 @@ private:
void UpdateChunk(int& updates, unsigned int chx, unsigned int chy, BlockInfo* blockinfo[BTYPE_LAST]);
void RenderWorld(int& rendercount, Player& player, Transformation& world, Shader& shader);
- void UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]);
+ void UpdateWorld(Player& player, BlockInfo* blockinfo[BTYPE_LAST]);
void TransposeWorld(Player& player, Bullet* bullets[MAX_BULLETS]);
};
diff --git a/SQCSim2021/x64/Debug/SQCSim2021.exe.recipe b/SQCSim2021/x64/Debug/SQCSim2021.exe.recipe
new file mode 100644
index 0000000..2232cc6
--- /dev/null
+++ b/SQCSim2021/x64/Debug/SQCSim2021.exe.recipe
@@ -0,0 +1,11 @@
+
+
+
+
+ D:\Repos\SQCSim2021\x64\Debug\SQCSim2021.exe
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SQCSim2021/x64/Debug/SQCSim2021.tlog/SQCSim2021.lastbuildstate b/SQCSim2021/x64/Debug/SQCSim2021.tlog/SQCSim2021.lastbuildstate
new file mode 100644
index 0000000..34e6419
--- /dev/null
+++ b/SQCSim2021/x64/Debug/SQCSim2021.tlog/SQCSim2021.lastbuildstate
@@ -0,0 +1,2 @@
+PlatformToolSet=ClangCL:VCToolArchitecture=Native64Bit:VCToolsVersion=14.31.31103:TargetPlatformVersion=10.0.22000.0:
+C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\x64|13.0.0|Debug|x64|D:\Repos\SQCSim2021\|
diff --git a/SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.command.1.tlog b/SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.command.1.tlog
new file mode 100644
index 0000000..ea157cc
Binary files /dev/null and b/SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.command.1.tlog differ
diff --git a/SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.read.1.tlog b/SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.read.1.tlog
new file mode 100644
index 0000000..b858ec9
Binary files /dev/null and b/SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.read.1.tlog differ
diff --git a/SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.write.1.tlog b/SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.write.1.tlog
new file mode 100644
index 0000000..4c9e8f8
Binary files /dev/null and b/SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.write.1.tlog differ
diff --git a/SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.command.1.tlog b/SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.command.1.tlog
new file mode 100644
index 0000000..a565f67
Binary files /dev/null and b/SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.command.1.tlog differ
diff --git a/SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.read.2.tlog b/SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.read.2.tlog
new file mode 100644
index 0000000..77dbfff
Binary files /dev/null and b/SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.read.2.tlog differ
diff --git a/SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.write.1.tlog b/SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.write.1.tlog
new file mode 100644
index 0000000..aa288a9
Binary files /dev/null and b/SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.write.1.tlog differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/SQCSim2021.lastbuildstate b/SQCSim2021/x64/Release/SQCSim2021.tlog/SQCSim2021.lastbuildstate
index bc4b8a4..739df84 100644
--- a/SQCSim2021/x64/Release/SQCSim2021.tlog/SQCSim2021.lastbuildstate
+++ b/SQCSim2021/x64/Release/SQCSim2021.tlog/SQCSim2021.lastbuildstate
@@ -1,2 +1,2 @@
-PlatformToolSet=ClangCL:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionATL=14.29.30136:VCServicingVersionCrtHeaders=14.29.30136:TargetPlatformVersion=10.0.19041.0:
-C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\Llvm\x64|12.0.0|Release|x64|D:\Repos\SQCSim2021\|
+PlatformToolSet=ClangCL:VCToolArchitecture=Native64Bit:VCToolsVersion=14.31.31103:TargetPlatformVersion=10.0.22000.0:
+C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\x64|13.0.0|Release|x64|D:\Repos\SQCSim2021\|
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.1032.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.1032.delete.1.tlog
deleted file mode 100644
index 6d4fe6f..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.1032.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.1032.write.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.1032.write.1.tlog
deleted file mode 100644
index 21565a2..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.1032.write.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.11724.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.11724.delete.1.tlog
deleted file mode 100644
index da61ff3..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.11724.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.13204.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.13204.delete.1.tlog
deleted file mode 100644
index 3231980..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.13204.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.14816.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.14816.delete.1.tlog
deleted file mode 100644
index d66ed74..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.14816.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.16024.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.16024.delete.1.tlog
deleted file mode 100644
index 8d70cae..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.16024.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.16472.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.16472.delete.1.tlog
deleted file mode 100644
index 382566f..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.16472.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.18832.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.18832.delete.1.tlog
deleted file mode 100644
index fd4da29..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.18832.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.19712.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.19712.delete.1.tlog
deleted file mode 100644
index 58c3525..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.19712.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.24092.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.24092.delete.1.tlog
deleted file mode 100644
index bd9c2ac..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.24092.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.25324.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.25324.delete.1.tlog
deleted file mode 100644
index 2e69bf4..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.25324.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.26840.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.26840.delete.1.tlog
deleted file mode 100644
index 1033957..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.26840.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.31424.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.31424.delete.1.tlog
deleted file mode 100644
index 691ef96..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.31424.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.33888.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.33888.delete.1.tlog
deleted file mode 100644
index 3ecbd9e..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.33888.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.34004.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.34004.delete.1.tlog
deleted file mode 100644
index 2accc05..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.34004.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.34284.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.34284.delete.1.tlog
deleted file mode 100644
index dd92339..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.34284.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.36512.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.36512.delete.1.tlog
deleted file mode 100644
index 8597888..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.36512.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.7912.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.7912.delete.1.tlog
deleted file mode 100644
index d69b6b2..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.7912.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.command.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.command.1.tlog
index 231c3fa..2eb0f68 100644
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.command.1.tlog and b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.command.1.tlog differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.read.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.read.1.tlog
index b8cf108..4b0edd2 100644
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.read.1.tlog and b/SQCSim2021/x64/Release/SQCSim2021.tlog/clang-cl.read.1.tlog differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.command.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.command.1.tlog
index 4b6827c..69c884a 100644
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.command.1.tlog and b/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.command.1.tlog differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.delete.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.delete.1.tlog
deleted file mode 100644
index 4686627..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.delete.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.read.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.read.1.tlog
deleted file mode 100644
index 7055d6c..0000000
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.read.1.tlog and /dev/null differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.write.1.tlog b/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.write.1.tlog
index c633ce1..d2744c2 100644
Binary files a/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.write.1.tlog and b/SQCSim2021/x64/Release/SQCSim2021.tlog/lld-link.write.1.tlog differ
diff --git a/SQCSim2021/x64/Release/SQCSim2021.vcxproj.FileListAbsolute.txt b/SQCSim2021/x64/Release/SQCSim2021.vcxproj.FileListAbsolute.txt
new file mode 100644
index 0000000..e69de29
diff --git a/x64/Debug/DevIL.dll b/x64/Debug/DevIL.dll
new file mode 100644
index 0000000..51b3450
Binary files /dev/null and b/x64/Debug/DevIL.dll differ
diff --git a/x64/Debug/ILU.dll b/x64/Debug/ILU.dll
new file mode 100644
index 0000000..5959615
Binary files /dev/null and b/x64/Debug/ILU.dll differ
diff --git a/x64/Debug/ILUT.dll b/x64/Debug/ILUT.dll
new file mode 100644
index 0000000..4eaafcb
Binary files /dev/null and b/x64/Debug/ILUT.dll differ
diff --git a/x64/Debug/SQCSim2021.exe b/x64/Debug/SQCSim2021.exe
new file mode 100644
index 0000000..658d5dd
Binary files /dev/null and b/x64/Debug/SQCSim2021.exe differ
diff --git a/x64/Debug/glew32.dll b/x64/Debug/glew32.dll
new file mode 100644
index 0000000..04f9381
Binary files /dev/null and b/x64/Debug/glew32.dll differ
diff --git a/x64/Debug/irrKlang.dll b/x64/Debug/irrKlang.dll
new file mode 100644
index 0000000..3d6fdc5
Binary files /dev/null and b/x64/Debug/irrKlang.dll differ
diff --git a/x64/Debug/openal32.dll b/x64/Debug/openal32.dll
new file mode 100644
index 0000000..7760c05
Binary files /dev/null and b/x64/Debug/openal32.dll differ
diff --git a/x64/Debug/sfml-graphics-d-2.dll b/x64/Debug/sfml-graphics-d-2.dll
new file mode 100644
index 0000000..1cfc619
Binary files /dev/null and b/x64/Debug/sfml-graphics-d-2.dll differ
diff --git a/x64/Debug/sfml-network-d-2.dll b/x64/Debug/sfml-network-d-2.dll
new file mode 100644
index 0000000..140c105
Binary files /dev/null and b/x64/Debug/sfml-network-d-2.dll differ
diff --git a/x64/Debug/sfml-system-d-2.dll b/x64/Debug/sfml-system-d-2.dll
new file mode 100644
index 0000000..3e35a53
Binary files /dev/null and b/x64/Debug/sfml-system-d-2.dll differ
diff --git a/x64/Debug/sfml-window-d-2.dll b/x64/Debug/sfml-window-d-2.dll
new file mode 100644
index 0000000..f6da427
Binary files /dev/null and b/x64/Debug/sfml-window-d-2.dll differ