Changements pour v143 et autres corrections.
This commit is contained in:
parent
a226d95923
commit
16a67035d0
@ -29,7 +29,7 @@
|
|||||||
<ClInclude Include="engine.h" />
|
<ClInclude Include="engine.h" />
|
||||||
<ClInclude Include="matrix4.h" />
|
<ClInclude Include="matrix4.h" />
|
||||||
<ClInclude Include="openglcontext.h" />
|
<ClInclude Include="openglcontext.h" />
|
||||||
<ClInclude Include="perlin.h" />
|
<ClInclude Include="opensimplex.h" />
|
||||||
<ClInclude Include="player.h" />
|
<ClInclude Include="player.h" />
|
||||||
<ClInclude Include="shader.h" />
|
<ClInclude Include="shader.h" />
|
||||||
<ClInclude Include="skybox.h" />
|
<ClInclude Include="skybox.h" />
|
||||||
@ -49,7 +49,7 @@
|
|||||||
<ClCompile Include="engine.cpp" />
|
<ClCompile Include="engine.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="openglcontext.cpp" />
|
<ClCompile Include="openglcontext.cpp" />
|
||||||
<ClCompile Include="perlin.cpp" />
|
<ClCompile Include="opensimplex.cpp" />
|
||||||
<ClCompile Include="player.cpp" />
|
<ClCompile Include="player.cpp" />
|
||||||
<ClCompile Include="shader.cpp" />
|
<ClCompile Include="shader.cpp" />
|
||||||
<ClCompile Include="skybox.cpp" />
|
<ClCompile Include="skybox.cpp" />
|
||||||
@ -72,13 +72,13 @@
|
|||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>ClangCL</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>ClangCL</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
@ -117,8 +117,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<IncludePath>$(ProjectDir)\external\irrKlang-1.6.0\include$(MSBuildProjectDirectory)$(MSBuildProjectDirectory);external\devil178\include;external\sfml23\include;$(IncludePath)</IncludePath>
|
<IncludePath>external\irrKlang-64bit-1.6.0\include;external\devil180\include;external\sfml251\include;external\glew210\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>external\devil178\lib;external\sfml23\lib;$(LibraryPath);D:\Repos\SQCSim2021\SQCSim2021\external\irrKlang-1.6.0\lib\Win32-visualStudio</LibraryPath>
|
<LibraryPath>external\devil180\lib\x64\Release;external\glew210\lib\Release\x64;external\sfml251\lib;$(LibraryPath);external\irrKlang-64bit-1.6.0\lib\Winx64-visualStudio</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
@ -68,10 +68,10 @@
|
|||||||
<ClInclude Include="world.h">
|
<ClInclude Include="world.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="perlin.h">
|
<ClInclude Include="bullet.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="bullet.h">
|
<ClInclude Include="opensimplex.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -121,10 +121,10 @@
|
|||||||
<ClCompile Include="world.cpp">
|
<ClCompile Include="world.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="perlin.cpp">
|
<ClCompile Include="bullet.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="bullet.cpp">
|
<ClCompile Include="opensimplex.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -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);
|
std::ifstream input(pos.str(), std::fstream::binary);
|
||||||
|
|
||||||
if (input.fail()) {
|
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);
|
m_blocks.Reset(BTYPE_AIR);
|
||||||
|
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Montagnes
|
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Montagnes
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
||||||
float xnoiz, ynoiz;
|
float xnoiz, ynoiz;
|
||||||
xnoiz = (double)(ix + x * CHUNK_SIZE_X) / (double)UINT16_MAX;
|
xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 256.;
|
||||||
ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / (double)UINT16_MAX;
|
ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 256.;
|
||||||
float height = (perlin.Get(xnoiz, ynoiz)) * 20.f + 5.f;
|
float height = (simplex.eval(xnoiz, ynoiz)) * 60.f + 5.f;
|
||||||
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy)
|
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy)
|
||||||
SetBlock(ix, iy, iz, BTYPE_METAL, nullptr);
|
SetBlock(ix, iy, iz, BTYPE_METAL, nullptr);
|
||||||
}
|
}
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Collines
|
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Collines
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
||||||
float xnoiz, ynoiz;
|
float xnoiz, ynoiz;
|
||||||
xnoiz = (double)(ix + x * CHUNK_SIZE_X) / (double)UINT16_MAX;
|
xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 64.;
|
||||||
ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / (double)UINT16_MAX;
|
ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 64.;
|
||||||
float height = perlin.Get(xnoiz, ynoiz) * 5.f + 24.f;
|
float height = simplex.eval(xnoiz, ynoiz) * 5.f + 24.f;
|
||||||
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy) {
|
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy) {
|
||||||
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
||||||
SetBlock(ix, iy, iz, BTYPE_GRASS, nullptr);
|
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 ix = 0; ix < CHUNK_SIZE_X; ++ix) // "Lacs"
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
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)
|
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
||||||
SetBlock(ix, iy, iz, BTYPE_ICE, nullptr);
|
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 ix = 0; ix < CHUNK_SIZE_X; ++ix) // "Arbres"
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
||||||
float xnoiz, ynoiz;
|
float xnoiz, ynoiz;
|
||||||
xnoiz = (double)(iz * CHUNK_SIZE_Y + x * CHUNK_SIZE_X) / (double)UINT16_MAX;
|
xnoiz = (double)(iz * CHUNK_SIZE_Y + x * CHUNK_SIZE_X) / 256.;
|
||||||
ynoiz = (double)(ix * CHUNK_SIZE_Y + y * CHUNK_SIZE_Z) / (double)UINT16_MAX;
|
ynoiz = (double)(ix * CHUNK_SIZE_Y + y * CHUNK_SIZE_Z) / 256.;
|
||||||
bool tree = (int)(abs(perlin.Get(xnoiz, ynoiz)) * 17933.f) % CHUNK_SIZE_Y > 126 ? true : false;
|
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)
|
for (int iy = 0; iy < CHUNK_SIZE_Y - 10; ++iy)
|
||||||
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
||||||
if (GetBlock(ix, iy - 1, iz) == BTYPE_GRASS)
|
if (GetBlock(ix, iy - 1, iz) == BTYPE_GRASS)
|
||||||
if (tree) {
|
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);
|
SetBlock(ix, iy + i, iz, BTYPE_DIRT, nullptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include "array2d.h"
|
#include "array2d.h"
|
||||||
#include "vertexbuffer.h"
|
#include "vertexbuffer.h"
|
||||||
#include "blockinfo.h"
|
#include "blockinfo.h"
|
||||||
|
#include "perlin.h"
|
||||||
|
#include "opensimplex.h"
|
||||||
|
|
||||||
class World;
|
class World;
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define WORLD_SIZE_X 128
|
#define WORLD_SIZE_X 64
|
||||||
#define WORLD_SIZE_Y 128
|
#define WORLD_SIZE_Y 64
|
||||||
|
|
||||||
#define FRAMES_RENDER_CHUNKS 1
|
#define FRAMES_RENDER_CHUNKS 1
|
||||||
#define FRAMES_UPDATE_CHUNKS 1
|
#define FRAMES_UPDATE_CHUNKS 1
|
||||||
@ -47,7 +47,7 @@
|
|||||||
#define THREADS_UPDATE_CHUNKS 8
|
#define THREADS_UPDATE_CHUNKS 8
|
||||||
#define THREADS_DELETE_CHUNKS 10
|
#define THREADS_DELETE_CHUNKS 10
|
||||||
|
|
||||||
#define VIEW_DISTANCE 1024
|
#define VIEW_DISTANCE 512
|
||||||
#define TEXTURE_SIZE 512
|
#define TEXTURE_SIZE 512
|
||||||
#define MAX_BULLETS 512
|
#define MAX_BULLETS 512
|
||||||
#endif
|
#endif
|
||||||
|
@ -186,12 +186,14 @@ int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; }
|
|||||||
|
|
||||||
void Engine::Render(float elapsedTime) {
|
void Engine::Render(float elapsedTime) {
|
||||||
static float gameTime = elapsedTime;
|
static float gameTime = elapsedTime;
|
||||||
|
static float pollTime = 0;
|
||||||
static float bulletTime = 0;
|
static float bulletTime = 0;
|
||||||
static BlockType bloc = 1;
|
static BlockType bloc = 1;
|
||||||
|
|
||||||
if (elapsedTime > 0.1f) return;
|
if (elapsedTime > 0.1f) return;
|
||||||
|
|
||||||
gameTime += elapsedTime;
|
gameTime += elapsedTime;
|
||||||
|
pollTime += elapsedTime;
|
||||||
|
|
||||||
Transformation all;
|
Transformation all;
|
||||||
Transformation skybox;
|
Transformation skybox;
|
||||||
@ -205,9 +207,13 @@ void Engine::Render(float elapsedTime) {
|
|||||||
if (bulletTime > 0.f) bulletTime -= elapsedTime;
|
if (bulletTime > 0.f) bulletTime -= elapsedTime;
|
||||||
if (bulletTime < 0.f) bulletTime = 0.f;
|
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_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
|
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)
|
// son vecteur de vélocité (pour l'effet Doppler)
|
||||||
|
pollTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
m_player.ApplyTransformation(all);
|
m_player.ApplyTransformation(all);
|
||||||
|
|
||||||
m_player.ApplyTransformation(skybox, false); // Version d'ApplyTransformation qui ne tient compte que de la rotation
|
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_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);
|
if (m_isSkybox) m_skybox.Render(skybox);
|
||||||
|
|
||||||
|
2542
SQCSim2021/opensimplex.cpp
Normal file
2542
SQCSim2021/opensimplex.cpp
Normal file
File diff suppressed because it is too large
Load Diff
51
SQCSim2021/opensimplex.h
Normal file
51
SQCSim2021/opensimplex.h
Normal file
@ -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 <cstdint>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
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<short, 256> m_perm;
|
||||||
|
std::array<short, 256> m_permGradIndex3d;
|
||||||
|
std::array<char, 16> m_gradients2d;
|
||||||
|
std::array<char, 72> m_gradients3d;
|
||||||
|
std::array<char, 256> 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__
|
@ -1,262 +0,0 @@
|
|||||||
/* coherent noise function over 1, 2 or 3 dimensions */
|
|
||||||
/* (copyright Ken Perlin) */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#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<terms; i++ )
|
|
||||||
{
|
|
||||||
result += noise2(vec)*amp;
|
|
||||||
vec[0] *= 2.0f;
|
|
||||||
vec[1] *= 2.0f;
|
|
||||||
amp*=0.5f;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Perlin::perlin_noise_3D(float vec[3])
|
|
||||||
{
|
|
||||||
int terms = mOctaves;
|
|
||||||
//float freq = mFrequency;
|
|
||||||
float result = 0.0f;
|
|
||||||
float amp = mAmplitude;
|
|
||||||
|
|
||||||
vec[0]*=mFrequency;
|
|
||||||
vec[1]*=mFrequency;
|
|
||||||
vec[2]*=mFrequency;
|
|
||||||
|
|
||||||
for( int i=0; i<terms; i++ )
|
|
||||||
{
|
|
||||||
result += noise3(vec)*amp;
|
|
||||||
vec[0] *= 2.0f;
|
|
||||||
vec[1] *= 2.0f;
|
|
||||||
vec[2] *= 2.0f;
|
|
||||||
amp*=0.5f;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Perlin::Perlin(int octaves,float freq,float amp,int seed)
|
|
||||||
{
|
|
||||||
mOctaves = octaves;
|
|
||||||
mFrequency = freq;
|
|
||||||
mAmplitude = amp;
|
|
||||||
mSeed = seed;
|
|
||||||
mStart = true;
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
//http://www.flipcode.com/archives/Perlin_Noise_Class.shtml
|
|
||||||
#ifndef PERLIN_H_
|
|
||||||
|
|
||||||
#define PERLIN_H_
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
#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
|
|
@ -125,12 +125,12 @@ void World::GetScope(unsigned int& x, unsigned int& y) {
|
|||||||
y = m_center[1];
|
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);
|
glStencilFunc(GL_EQUAL, 1, 0x00);
|
||||||
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||||
atlas.Bind();
|
atlas.Bind();
|
||||||
RenderWorld(rendercount, player, world, shader);
|
RenderWorld(rendercount, player, world, shader);
|
||||||
UpdateWorld(player, perlin, blockinfo);
|
UpdateWorld(player, blockinfo);
|
||||||
TransposeWorld(player, bullets);
|
TransposeWorld(player, bullets);
|
||||||
shader.Disable();
|
shader.Disable();
|
||||||
glStencilFunc(GL_GREATER, 1, 0xFF);
|
glStencilFunc(GL_GREATER, 1, 0xFF);
|
||||||
@ -301,7 +301,7 @@ void World::RenderWorld(int& rendercount, Player& player, Transformation& world,
|
|||||||
shader.Disable();
|
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 cx = player.GetPosition().x;
|
||||||
int cy = player.GetPosition().z;
|
int cy = player.GetPosition().z;
|
||||||
static int frameGenerate = 0;
|
static int frameGenerate = 0;
|
||||||
@ -466,9 +466,10 @@ void World::UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTY
|
|||||||
else m_tbDeleted.pop_back();
|
else m_tbDeleted.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = 0; x < threads; ++x)
|
for (int x = 0; x < threads; ++x) {
|
||||||
delThList[x].wait();
|
delThList[x].wait();
|
||||||
|
delThList[x].get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int World::GettbDeleted() const { return m_tbDeleted.size(); }
|
int World::GettbDeleted() const { return m_tbDeleted.size(); }
|
@ -1,20 +1,19 @@
|
|||||||
#ifndef WORLD_H__
|
#ifndef WORLD_H__
|
||||||
#define WORLD_H__
|
#define WORLD_H__
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <future>
|
||||||
|
#include <thread>
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include "chunk.h"
|
#include "chunk.h"
|
||||||
#include "array2d.h"
|
#include "array2d.h"
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "transformation.h"
|
#include "transformation.h"
|
||||||
#include "perlin.h"
|
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
#include "bullet.h"
|
#include "bullet.h"
|
||||||
#include "textureatlas.h"
|
#include "textureatlas.h"
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <future>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
class Chunk;
|
class Chunk;
|
||||||
class Player;
|
class Player;
|
||||||
@ -33,7 +32,7 @@ public:
|
|||||||
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
|
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
|
||||||
BlockType BlockAt(const Vector3f& pos, 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);
|
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 UpdateChunk(int& updates, unsigned int chx, unsigned int chy, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||||
void RenderWorld(int& rendercount, Player& player, Transformation& world, Shader& shader);
|
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]);
|
void TransposeWorld(Player& player, Bullet* bullets[MAX_BULLETS]);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
11
SQCSim2021/x64/Debug/SQCSim2021.exe.recipe
Normal file
11
SQCSim2021/x64/Debug/SQCSim2021.exe.recipe
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project>
|
||||||
|
<ProjectOutputs>
|
||||||
|
<ProjectOutput>
|
||||||
|
<FullPath>D:\Repos\SQCSim2021\x64\Debug\SQCSim2021.exe</FullPath>
|
||||||
|
</ProjectOutput>
|
||||||
|
</ProjectOutputs>
|
||||||
|
<ContentFiles />
|
||||||
|
<SatelliteDlls />
|
||||||
|
<NonRecipeFileRefs />
|
||||||
|
</Project>
|
@ -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\|
|
BIN
SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.command.1.tlog
Normal file
BIN
SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.command.1.tlog
Normal file
Binary file not shown.
BIN
SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.read.1.tlog
Normal file
BIN
SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.read.1.tlog
Normal file
Binary file not shown.
BIN
SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.write.1.tlog
Normal file
BIN
SQCSim2021/x64/Debug/SQCSim2021.tlog/clang-cl.write.1.tlog
Normal file
Binary file not shown.
BIN
SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.command.1.tlog
Normal file
BIN
SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.command.1.tlog
Normal file
Binary file not shown.
BIN
SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.read.2.tlog
Normal file
BIN
SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.read.2.tlog
Normal file
Binary file not shown.
BIN
SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.write.1.tlog
Normal file
BIN
SQCSim2021/x64/Debug/SQCSim2021.tlog/lld-link.write.1.tlog
Normal file
Binary file not shown.
@ -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:
|
PlatformToolSet=ClangCL:VCToolArchitecture=Native64Bit:VCToolsVersion=14.31.31103:TargetPlatformVersion=10.0.22000.0:
|
||||||
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\Llvm\x64|12.0.0|Release|x64|D:\Repos\SQCSim2021\|
|
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\x64|13.0.0|Release|x64|D:\Repos\SQCSim2021\|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
x64/Debug/DevIL.dll
Normal file
BIN
x64/Debug/DevIL.dll
Normal file
Binary file not shown.
BIN
x64/Debug/ILU.dll
Normal file
BIN
x64/Debug/ILU.dll
Normal file
Binary file not shown.
BIN
x64/Debug/ILUT.dll
Normal file
BIN
x64/Debug/ILUT.dll
Normal file
Binary file not shown.
BIN
x64/Debug/SQCSim2021.exe
Normal file
BIN
x64/Debug/SQCSim2021.exe
Normal file
Binary file not shown.
BIN
x64/Debug/glew32.dll
Normal file
BIN
x64/Debug/glew32.dll
Normal file
Binary file not shown.
BIN
x64/Debug/irrKlang.dll
Normal file
BIN
x64/Debug/irrKlang.dll
Normal file
Binary file not shown.
BIN
x64/Debug/openal32.dll
Normal file
BIN
x64/Debug/openal32.dll
Normal file
Binary file not shown.
BIN
x64/Debug/sfml-graphics-d-2.dll
Normal file
BIN
x64/Debug/sfml-graphics-d-2.dll
Normal file
Binary file not shown.
BIN
x64/Debug/sfml-network-d-2.dll
Normal file
BIN
x64/Debug/sfml-network-d-2.dll
Normal file
Binary file not shown.
BIN
x64/Debug/sfml-system-d-2.dll
Normal file
BIN
x64/Debug/sfml-system-d-2.dll
Normal file
Binary file not shown.
BIN
x64/Debug/sfml-window-d-2.dll
Normal file
BIN
x64/Debug/sfml-window-d-2.dll
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user