Changements pour v143 et autres corrections.

This commit is contained in:
MarcEricMartel
2022-04-02 15:26:55 -04:00
parent a226d95923
commit 16a67035d0
57 changed files with 2655 additions and 364 deletions

View File

@@ -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;
}