clear Clipper when layer is compiled

This commit is contained in:
Hannes Janetzek 2013-01-04 09:50:30 +01:00
parent 1887d753c8
commit c2f5755e64

View File

@ -39,6 +39,8 @@ public class ExtrusionLayer extends Layer {
private VertexPoolItem mIndices[], mCurIndices[]; private VertexPoolItem mIndices[], mCurIndices[];
private LineClipper mClipper; private LineClipper mClipper;
// indices for:
// 0. even sides, 1. odd sides, 2. roof, 3. roof outline
public int mIndiceCnt[] = { 0, 0, 0, 0 }; public int mIndiceCnt[] = { 0, 0, 0, 0 };
public int mIndicesBufferID; public int mIndicesBufferID;
public int mVertexBufferID; public int mVertexBufferID;
@ -54,11 +56,7 @@ public class ExtrusionLayer extends Layer {
this.layer = level; this.layer = level;
mVertices = mCurVertices = VertexPool.get(); mVertices = mCurVertices = VertexPool.get();
// indices for
// 0. even sides
// 1. odd sides
// 2. roof
// 3. roof outline
mIndices = new VertexPoolItem[4]; mIndices = new VertexPoolItem[4];
mCurIndices = new VertexPoolItem[4]; mCurIndices = new VertexPoolItem[4];
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
@ -271,7 +269,6 @@ public class ExtrusionLayer extends Layer {
if (convex) { if (convex) {
// TODO simple polys with only one concave arc // TODO simple polys with only one concave arc
// could be handled without special triangulation // could be handled without special triangulation
if ((ux < 0 ? 1 : -1) != (vx < 0 ? 1 : -1)) if ((ux < 0 ? 1 : -1) != (vx < 0 ? 1 : -1))
changeX++; changeX++;
if ((uy < 0 ? 1 : -1) != (vy < 0 ? 1 : -1)) if ((uy < 0 ? 1 : -1) != (vy < 0 ? 1 : -1))
@ -291,6 +288,7 @@ public class ExtrusionLayer extends Layer {
short[] indices = mCurIndices[even].vertices; short[] indices = mCurIndices[even].vertices;
// index id relative to mCurIndices item // index id relative to mCurIndices item
int ind = mCurIndices[even].used; int ind = mCurIndices[even].used;
// indices for current face
short vert = (short) (vOffset + (i - 2)); short vert = (short) (vOffset + (i - 2));
short s0 = vert++; short s0 = vert++;
short s1 = vert++; short s1 = vert++;
@ -322,7 +320,7 @@ public class ExtrusionLayer extends Layer {
mCurIndices[even].used += 6; mCurIndices[even].used += 6;
even = (even + 1) % 2; even = (even + 1) % 2;
// add outline indices // add roof outline indices
VertexPoolItem it = mCurIndices[IND_OUTLINE]; VertexPoolItem it = mCurIndices[IND_OUTLINE];
if (it.used == VertexPoolItem.SIZE) { if (it.used == VertexPoolItem.SIZE) {
it.next = VertexPool.get(); it.next = VertexPool.get();
@ -383,6 +381,8 @@ public class ExtrusionLayer extends Layer {
VertexPool.release(mVertices); VertexPool.release(mVertices);
mClipper = null;
compiled = true; compiled = true;
} }