Monde de max de UINT_MAX * UINT_MAX

This commit is contained in:
MarcEricMartel
2021-12-18 15:24:57 -05:00
parent 5dc05167de
commit 5f50f5f87e
5 changed files with 40 additions and 40 deletions

View File

@@ -1,7 +1,7 @@
#include "chunk.h"
#include "world.h"
Chunk::Chunk(int x, int y) : m_posX(x), m_posY(y) {
Chunk::Chunk(unsigned int x, unsigned int y) : m_posX(x), m_posY(y) {
std::ostringstream pos; // V<>rifie l'existence d'un fichier .chunk avec sa position.
pos << CHUNK_PATH << x << '_' << y << ".chunk";
std::ifstream input(pos.str(), std::fstream::binary);
@@ -13,8 +13,8 @@ Chunk::Chunk(int x, int y) : m_posX(x), m_posY(y) {
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)INT16_MAX;
ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / (double)INT16_MAX;
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;
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy)
SetBlock(ix, iy, iz, BTYPE_METAL, nullptr);
@@ -22,8 +22,8 @@ Chunk::Chunk(int x, int y) : m_posX(x), m_posY(y) {
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)INT16_MAX;
ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / (double)INT16_MAX;
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;
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy) {
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
@@ -40,8 +40,8 @@ Chunk::Chunk(int x, 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)INT16_MAX;
ynoiz = (double)(ix * CHUNK_SIZE_Y + y * CHUNK_SIZE_Z) / (double)INT16_MAX;
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;
for (int iy = 0; iy < CHUNK_SIZE_Y - 10; ++iy)
@@ -102,8 +102,8 @@ void Chunk::SetBlock(int x, int y, int z, BlockType type, World* world) {
BlockType Chunk::GetBlock(int x, int y, int z) { return m_blocks.Get(x, y, z); }
void Chunk::CheckNeighbors(int x, int z, World* world) {
int cx, cy;
void Chunk::CheckNeighbors(unsigned int x, unsigned int z, World* world) {
unsigned int cx, cy;
world->GetScope(cx, cy);
@@ -122,7 +122,7 @@ void Chunk::CheckNeighbors(int x, int z, World* world) {
world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy + 1) * CHUNK_SIZE_Z)->MakeDirty();
}
void Chunk::GetPosition(int& x, int& y) const { x = m_posX; y = m_posY; }
void Chunk::GetPosition(unsigned int& x, unsigned int& y) const { x = m_posX; y = m_posY; }
void Chunk::FlushMeshToVBO() {
m_vertexBuffer.SetMeshData(m_vd, m_vcount);
@@ -167,7 +167,7 @@ void Chunk::Update(BlockInfo* blockinfo[BTYPE_LAST], World* world) {
void Chunk::AddBlockToMesh(VertexBuffer::VertexData* vd, int& count, BlockType bt,
int x, int y, int z, float u, float v, float s, World* world) {
int cex, cey;
unsigned int cex, cey;
world->GetScope(cex, cey);