v0.6.0a: improved tilemap update logic
This commit is contained in:
parent
670c0d9f98
commit
3b689da833
|
@ -21,8 +21,7 @@
|
||||||
|
|
||||||
package com.watabou.noosa;
|
package com.watabou.noosa;
|
||||||
|
|
||||||
import java.nio.FloatBuffer;
|
import android.graphics.RectF;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import com.watabou.gltextures.SmartTexture;
|
import com.watabou.gltextures.SmartTexture;
|
||||||
import com.watabou.gltextures.TextureCache;
|
import com.watabou.gltextures.TextureCache;
|
||||||
|
@ -30,7 +29,8 @@ import com.watabou.glwrap.Quad;
|
||||||
import com.watabou.glwrap.Vertexbuffer;
|
import com.watabou.glwrap.Vertexbuffer;
|
||||||
import com.watabou.utils.Rect;
|
import com.watabou.utils.Rect;
|
||||||
|
|
||||||
import android.graphics.RectF;
|
import java.nio.FloatBuffer;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Tilemap extends Visual {
|
public class Tilemap extends Visual {
|
||||||
|
|
||||||
|
@ -105,16 +105,20 @@ public class Tilemap extends Visual {
|
||||||
protected void updateVertices() {
|
protected void updateVertices() {
|
||||||
|
|
||||||
moveToUpdating();
|
moveToUpdating();
|
||||||
|
|
||||||
|
float x1, y1, x2, y2;
|
||||||
|
int pos;
|
||||||
|
RectF uv;
|
||||||
|
|
||||||
float y1 = cellH * updating.top;
|
y1 = cellH * updating.top;
|
||||||
float y2 = y1 + cellH;
|
y2 = y1 + cellH;
|
||||||
|
|
||||||
for (int i=updating.top; i < updating.bottom; i++) {
|
for (int i=updating.top; i < updating.bottom; i++) {
|
||||||
|
|
||||||
float x1 = cellW * updating.left;
|
x1 = cellW * updating.left;
|
||||||
float x2 = x1 + cellW;
|
x2 = x1 + cellW;
|
||||||
|
|
||||||
int pos = i * mapWidth + updating.left;
|
pos = i * mapWidth + updating.left;
|
||||||
|
|
||||||
for (int j=updating.left; j < updating.right; j++) {
|
for (int j=updating.left; j < updating.right; j++) {
|
||||||
|
|
||||||
|
@ -124,9 +128,10 @@ public class Tilemap extends Visual {
|
||||||
bottomRightUpdating = pos + 1;
|
bottomRightUpdating = pos + 1;
|
||||||
|
|
||||||
quads.position(pos*16);
|
quads.position(pos*16);
|
||||||
|
|
||||||
if (needsRender(pos)) {
|
uv = tileset.get(data[pos]);
|
||||||
RectF uv = tileset.get(data[pos]);
|
|
||||||
|
if (needsRender(pos) && uv != null) {
|
||||||
|
|
||||||
vertices[0] = x1;
|
vertices[0] = x1;
|
||||||
vertices[1] = y1;
|
vertices[1] = y1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user