v0.4.2: fixes to tilemap

This commit is contained in:
Evan Debenham 2016-08-27 15:23:56 -04:00 committed by Evan Debenham
parent 0b30263236
commit e87ce8949e

View File

@ -51,6 +51,7 @@ public class Tilemap extends Visual {
protected Vertexbuffer buffer; protected Vertexbuffer buffer;
private volatile Rect updated; private volatile Rect updated;
private boolean fullUpdate;
private Rect updating; private Rect updating;
private int topLeftUpdating; private int topLeftUpdating;
private int bottomRightUpdating; private int bottomRightUpdating;
@ -94,10 +95,7 @@ public class Tilemap extends Visual {
//forces a full update, including new buffer and culling recalculation //forces a full update, including new buffer and culling recalculation
public synchronized void updateMap(){ public synchronized void updateMap(){
updated.set( 0, 0, mapWidth, mapHeight ); updated.set( 0, 0, mapWidth, mapHeight );
if (buffer != null) { fullUpdate = true;
buffer.delete();
}
buffer = null;
camX = null; camX = null;
} }
@ -202,10 +200,16 @@ public class Tilemap extends Visual {
quads.limit(bufferLength*16); quads.limit(bufferLength*16);
if (buffer == null) if (buffer == null)
buffer = new Vertexbuffer(quads); buffer = new Vertexbuffer(quads);
else else {
if (fullUpdate) {
buffer.updateVertices(quads);
fullUpdate = false;
} else {
buffer.updateVertices(quads, buffer.updateVertices(quads,
topLeftUpdating * 16, topLeftUpdating * 16,
bottomRightUpdating * 16); bottomRightUpdating * 16);
}
}
topLeftUpdating = 0; topLeftUpdating = 0;
updating.setEmpty(); updating.setEmpty();
} }