fix: ExtrusionLayer get correct sumIndices

This commit is contained in:
Hannes Janetzek 2014-03-22 03:54:21 +01:00
parent 3b65983706
commit e900b4243d
2 changed files with 20 additions and 19 deletions

View File

@ -219,7 +219,7 @@ public class ExtrusionRenderer extends LayerRenderer {
el.vboVertices.loadBufferData(vbuf.flip(), size); el.vboVertices.loadBufferData(vbuf.flip(), size);
el.vboVertices.unbind(); el.vboVertices.unbind();
GLUtils.checkGlError("compile extrusion layer"); GLUtils.checkGlError("extrusion layer");
return true; return true;
} }

View File

@ -594,7 +594,7 @@ public class ExtrusionLayer extends RenderElement {
/* check if face is within tile */ /* check if face is within tile */
if (mClipper.clipNext((int) nx, (int) ny) == 0) { if (mClipper.clipNext((int) nx, (int) ny) == 0) {
even = (even == 0 ? 1 : 0); even = ++even % 2;
continue; continue;
} }
@ -611,37 +611,38 @@ public class ExtrusionLayer extends RenderElement {
s3 -= len; s3 -= len;
} }
short[] indices = mCurIndices[even].vertices; VertexItem it = mCurIndices[even];
// index id relative to mCurIndices item if (it.used == VertexItem.SIZE) {
int ind = mCurIndices[even].used; it = VertexItem.pool.getNext(it);
mCurIndices[even] = it;
if (ind == VertexItem.SIZE) {
mCurIndices[even].next = VertexItem.pool.get();
mCurIndices[even] = mCurIndices[even].next;
indices = mCurIndices[even].vertices;
ind = 0;
} }
int ind = it.used;
short[] indices = it.vertices;
indices[ind + 0] = s0; indices[ind + 0] = s0;
indices[ind + 1] = s2; indices[ind + 1] = s2;
indices[ind + 2] = s1; indices[ind + 2] = s1;
indices[ind + 3] = s1; indices[ind + 3] = s1;
indices[ind + 4] = s2; indices[ind + 4] = s2;
indices[ind + 5] = s3; indices[ind + 5] = s3;
it.used += 6;
sumIndices += 6; sumIndices += 6;
mCurIndices[even].used += 6; /* flipp even-odd */
even = (even == 0 ? 1 : 0); even = ++even % 2;
/* add roof outline indices */ /* add roof outline indices */
VertexItem it = mCurIndices[IND_OUTLINE]; it = mCurIndices[IND_OUTLINE];
if (it.used == VertexItem.SIZE) { if (it.used == VertexItem.SIZE) {
it.next = VertexItem.pool.get(); it = VertexItem.pool.getNext(it);
it = mCurIndices[IND_OUTLINE] = it.next; mCurIndices[IND_OUTLINE] = it;
} }
it.vertices[it.used++] = s1; ind = it.used;
it.vertices[it.used++] = s3; indices = it.vertices;
indices[ind + 0] = s1;
indices[ind + 1] = s3;
it.used += 2;
sumIndices += 2;
} }
mCurVertices.used = v; mCurVertices.used = v;