make convexity test more restrictive

This commit is contained in:
Hannes Janetzek 2013-05-09 12:15:28 +02:00
parent ff8e1801bf
commit 1ab3a5e174

View File

@ -104,9 +104,6 @@ public class ExtrusionLayer extends Layer {
int length = 0, ipos = 0, ppos = 0; int length = 0, ipos = 0, ppos = 0;
boolean complexOutline = false; boolean complexOutline = false;
int geomIndexPos = 0;
int geomPointPos = 0;
boolean simpleOutline = true; boolean simpleOutline = true;
// current vertex id // current vertex id
@ -121,9 +118,6 @@ public class ExtrusionLayer extends Layer {
// start next polygon // start next polygon
if (length == 0) { if (length == 0) {
if (complexOutline)
addRoof(startVertex, element, geomIndexPos, geomPointPos);
startVertex = mNumVertices; startVertex = mNumVertices;
simpleOutline = true; simpleOutline = true;
complexOutline = false; complexOutline = false;
@ -151,22 +145,16 @@ public class ExtrusionLayer extends Layer {
boolean convex = addOutline(points, ppos, len, minHeight, height, simpleOutline); boolean convex = addOutline(points, ppos, len, minHeight, height, simpleOutline);
if (simpleOutline && (convex || len <= 8)) if (simpleOutline && (convex || len <= 8)){
addRoofSimple(startVertex, len); addRoofSimple(startVertex, len);
else if (!complexOutline) { } else if (!complexOutline) {
complexOutline = true; complexOutline = true;
// keep start postion of polygon and defer roof building addRoof(startVertex, element, ipos, ppos);
// as it modifies the geometry array.
geomIndexPos = ipos;
geomPointPos = ppos;
} }
} }
if (complexOutline)
addRoof(startVertex, element, geomIndexPos, geomPointPos);
} }
private void addRoofSimple(int startVertex, int len) { private void addRoofSimple(int startVertex, int len) {
// roof indices for convex shapes // roof indices for convex shapes
int i = mCurIndices[IND_ROOF].used; int i = mCurIndices[IND_ROOF].used;
short[] indices = mCurIndices[IND_ROOF].vertices; short[] indices = mCurIndices[IND_ROOF].vertices;
@ -248,6 +236,7 @@ public class ExtrusionLayer extends Layer {
int even = 0; int even = 0;
int changeX = 0; int changeX = 0;
int changeY = 0; int changeY = 0;
int angleSign = 0;
// vertex offset for all vertices in layer // vertex offset for all vertices in layer
int vOffset = mNumVertices; int vOffset = mNumVertices;
@ -322,6 +311,18 @@ public class ExtrusionLayer extends Layer {
if (changeX > 2 || changeY > 2) if (changeX > 2 || changeY > 2)
convex = false; convex = false;
float cross = ux * vy - uy * vy;
if (cross > 0) {
if (angleSign == -1)
convex = false;
angleSign = 1;
} else if (cross < 0) {
if (angleSign == 1)
convex = false;
angleSign = -1;
}
} }
/* check if face is within tile */ /* check if face is within tile */