Corrections dans le générateur pour le MakeDirty au bout du monde
This commit is contained in:
		| @@ -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)); | ||||
| 	} | ||||
| @@ -133,7 +137,7 @@ void World::UpdateChunk(int& updates, int chx, int chy, BlockInfo* blockinfo[BTY | ||||
| 		ChunkAt(chx, 1, chy)->Update(blockinfo, this); | ||||
| 		updates = FRAMES_UPDATE_CHUNKS; | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| } | ||||
|  | ||||
| void World::ChangeBlockAtCursor(BlockType blockType, Player& player, bool& block) { | ||||
| @@ -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) { | ||||
| @@ -232,7 +236,7 @@ void World::RenderWorld(int& rendercount, Player& player, Transformation& world, | ||||
| 			cosinus = .99993365506; // cos(2/3 degr<67>) | ||||
| 			echantillons = 120; | ||||
| 		} | ||||
| 		else if (dist > VIEW_DISTANCE * .3f) {  | ||||
| 		else if (dist > VIEW_DISTANCE * .3f) { | ||||
| 			sinus = .01745240643; // sin(1 degr<67>) | ||||
| 			cosinus = .99984769515; // cos(1 degr<67>) | ||||
| 			echantillons = 90; | ||||
| @@ -269,7 +273,7 @@ void World::RenderWorld(int& rendercount, Player& player, Transformation& world, | ||||
| 				int chx, chy; | ||||
| 				ChunkAt(cursor)->GetPosition(chx, chy); | ||||
| 				for (int index = 0; index < rendercount; ++index) // Permet de v<>rifier seulement contre celles ajout<75>es dans la frame, et ne pas avoir <20> refaire l'array <20> chaque frame. | ||||
| 					if (renderManifest[index].x == chx && renderManifest[index].z == chy)  | ||||
| 					if (renderManifest[index].x == chx && renderManifest[index].z == chy) | ||||
| 						valide = false; | ||||
|  | ||||
| 				if (valide) renderManifest[rendercount++] = Vector3f(chx, (VIEW_DISTANCE - (pos - cursor).Length() * 2.f + 128) / (float)VIEW_DISTANCE, chy); | ||||
| @@ -357,11 +361,11 @@ void World::UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTY | ||||
| 	if (threads > 0) { | ||||
| 		for (int i = 0; i < threads; ++i) | ||||
| 			genThList[i].wait(); | ||||
| 		 | ||||
|  | ||||
| 		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); | ||||
| 		} | ||||
| 	} | ||||
| @@ -378,7 +382,7 @@ void World::UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTY | ||||
| 					break; | ||||
| 				int chx = cx + tx * CHUNK_SIZE_X; | ||||
| 				int chy = cy + ty * CHUNK_SIZE_Z; | ||||
| 				if (ChunkAt(chx, 1, chy) &&  | ||||
| 				if (ChunkAt(chx, 1, chy) && | ||||
| 					ChunkAt(chx, 1, chy)->IsDirty()) { | ||||
| 					updateThList[threads++] = | ||||
| 						std::async(std::launch::async, | ||||
| @@ -386,13 +390,13 @@ void World::UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTY | ||||
| 								chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this); | ||||
| 					if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS; | ||||
| 				} | ||||
| 			}	 | ||||
| 			} | ||||
| 			for (; ty <= side; ++ty) { | ||||
| 				if (frameUpdate) | ||||
| 					break; | ||||
| 				int chx = cx + tx * CHUNK_SIZE_X; | ||||
| 				int chy = cy + ty * CHUNK_SIZE_Z; | ||||
| 				if (ChunkAt(chx, 1, chy) &&  | ||||
| 				if (ChunkAt(chx, 1, chy) && | ||||
| 					ChunkAt(chx, 1, chy)->IsDirty()) { | ||||
| 					updateThList[threads++] = | ||||
| 						std::async(std::launch::async, | ||||
| @@ -400,13 +404,13 @@ void World::UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTY | ||||
| 								chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this); | ||||
| 					if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS; | ||||
| 				} | ||||
| 			}	 | ||||
| 			} | ||||
| 			for (; tx >= -side; --tx) { | ||||
| 				if (frameUpdate) | ||||
| 					break; | ||||
| 				int chx = cx + tx * CHUNK_SIZE_X; | ||||
| 				int chy = cy + ty * CHUNK_SIZE_Z; | ||||
| 				if (ChunkAt(chx, 1, chy) &&  | ||||
| 				if (ChunkAt(chx, 1, chy) && | ||||
| 					ChunkAt(chx, 1, chy)->IsDirty()) { | ||||
| 					updateThList[threads++] = | ||||
| 						std::async(std::launch::async, | ||||
| @@ -414,13 +418,13 @@ void World::UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTY | ||||
| 								chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this); | ||||
| 					if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS; | ||||
| 				} | ||||
| 			}	 | ||||
| 			} | ||||
| 			for (; ty >= -side; --ty) { | ||||
| 				if (frameUpdate) | ||||
| 					break; | ||||
| 				int chx = cx + tx * CHUNK_SIZE_X; | ||||
| 				int chy = cy + ty * CHUNK_SIZE_Z; | ||||
| 				if (ChunkAt(chx, 1, chy) &&  | ||||
| 				if (ChunkAt(chx, 1, chy) && | ||||
| 					ChunkAt(chx, 1, chy)->IsDirty()) { | ||||
| 					updateThList[threads++] = | ||||
| 						std::async(std::launch::async, | ||||
| @@ -428,7 +432,7 @@ void World::UpdateWorld(Player& player, Perlin& perlin, BlockInfo* blockinfo[BTY | ||||
| 								chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this); | ||||
| 					if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS; | ||||
| 				} | ||||
| 			}		 | ||||
| 			} | ||||
| 			if (frameUpdate) | ||||
| 				break; | ||||
| 			++side; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user