Corrections dans le générateur pour le MakeDirty au bout du monde

This commit is contained in:
MarcEricMartel 2021-12-14 17:16:14 -05:00
parent cdc926bb39
commit 2ec9170fe3

View File

@ -54,7 +54,8 @@ void World::TransposeWorld(Player& player, Bullet* bullets[MAX_BULLETS]) {
if (ax - x >= 0) {
m_chunks.Set(ax - x, ay,
m_chunks.Remove(ax, ay));
if (ax == WORLD_SIZE_X - 1) m_chunks.Get(ax - x, ay)->MakeDirty();
if (ax == WORLD_SIZE_X - 1 && m_chunks.Get(ax - x, ay))
m_chunks.Get(ax - x, ay)->MakeDirty();
}
else if (m_chunks.Get(ax, ay)) m_tbDeleted.emplace_back(m_chunks.Remove(ax, ay));
}
@ -64,7 +65,8 @@ void World::TransposeWorld(Player& player, Bullet* bullets[MAX_BULLETS]) {
if (ax - x < WORLD_SIZE_X) {
m_chunks.Set(ax - x, ay,
m_chunks.Remove(ax, ay));
if (ax + x == 0) m_chunks.Get(ax + x, ay)->MakeDirty();
if (ax == 0 && m_chunks.Get(ax - x, ay))
m_chunks.Get(ax - x, ay)->MakeDirty();
}
else if (m_chunks.Get(ax, ay)) m_tbDeleted.emplace_back(m_chunks.Remove(ax, ay));
}
@ -75,7 +77,8 @@ void World::TransposeWorld(Player& player, Bullet* bullets[MAX_BULLETS]) {
if (ay - y >= 0) {
m_chunks.Set(ax, ay - y,
m_chunks.Remove(ax, ay));
if (ay == WORLD_SIZE_Y) m_chunks.Get(ax, ay - y)->MakeDirty();
if (ay == WORLD_SIZE_Y - 1 && m_chunks.Get(ax, ay - y))
m_chunks.Get(ax, ay - y)->MakeDirty();
}
else if (m_chunks.Get(ax, ay)) m_tbDeleted.emplace_back(m_chunks.Remove(ax, ay));
}
@ -85,7 +88,8 @@ void World::TransposeWorld(Player& player, Bullet* bullets[MAX_BULLETS]) {
if (ay - y < WORLD_SIZE_Y) {
m_chunks.Set(ax, ay - y,
m_chunks.Remove(ax, ay));
if (ay - x == 0) m_chunks.Get(ax, ay - y)->MakeDirty();
if (ay == 0 && m_chunks.Get(ax, ay - y))
m_chunks.Get(ax, ay - y)->MakeDirty();
}
else if (m_chunks.Get(ax, ay)) m_tbDeleted.emplace_back(m_chunks.Remove(ax, ay));
}
@ -194,12 +198,12 @@ void World::ChangeBlockAtCursor(BlockType blockType, Player& player, bool& block
}
void World::ChangeBlockAtPosition(BlockType blockType, Vector3f pos) {
int bx = (int)pos.x % CHUNK_SIZE_X;
int by = (int)pos.y % CHUNK_SIZE_Y;
int bz = (int)pos.z % CHUNK_SIZE_Z;
int bx = (int)pos.x % CHUNK_SIZE_X;
int by = (int)pos.y % CHUNK_SIZE_Y;
int bz = (int)pos.z % CHUNK_SIZE_Z;
ChunkAt(pos)->SetBlock(bx, by, bz, blockType, this);
ChunkAt(pos)->MakeModified();
ChunkAt(pos)->SetBlock(bx, by, bz, blockType, this);
ChunkAt(pos)->MakeModified();
}
void World::RenderWorld(int& rendercount, Player& player, Transformation& world, Shader& shader) {
@ -361,7 +365,7 @@ void World::UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTY
for (int i = 0; i < threads; ++i) {
int x, y;
Chunk* chunk = genThList[i].get();
chunk->GetPosition(x,y);
chunk->GetPosition(x, y);
m_chunks.Set(x - m_center[0], y - m_center[1], chunk);
}
}