better way of checking if a chunk needs VBO creation

old way had some concurrency issues on slower hardware
This commit is contained in:
Gered 2014-03-16 11:14:34 -04:00
parent c7505cb8ce
commit 620dc275d1
2 changed files with 6 additions and 2 deletions

View file

@ -167,8 +167,8 @@ public class TileMap extends TileContainer implements Disposable {
if (!isUpdating()) if (!isUpdating())
return true; // done updating (or we were never updating in the first place ...) return true; // done updating (or we were never updating in the first place ...)
TileChunk chunkNeedingVboCreation = updater.chunkNeedingVboCreation; if (updater.isWaitingForVboCreation()) {
if (chunkNeedingVboCreation != null) { TileChunk chunkNeedingVboCreation = updater.chunkNeedingVboCreation;
ChunkVertexGenerator.GeneratedChunkMeshes meshes = vertexGenerator.createMeshFromVertices(); ChunkVertexGenerator.GeneratedChunkMeshes meshes = vertexGenerator.createMeshFromVertices();
chunkNeedingVboCreation.setMeshes(meshes); chunkNeedingVboCreation.setMeshes(meshes);
updater.signalDoneVboCreation(); updater.signalDoneVboCreation();

View file

@ -24,6 +24,10 @@ public class TileMapUpdater implements Runnable {
return chunkNeedingVboCreation; return chunkNeedingVboCreation;
} }
public boolean isWaitingForVboCreation() {
return waitingForVboCreation;
}
public synchronized void signalDoneVboCreation() { public synchronized void signalDoneVboCreation() {
waitingForVboCreation = false; waitingForVboCreation = false;
} }