PolygonBucket: reenable per bucket visibility test
This commit is contained in:
parent
33c48b3d53
commit
c632b865b0
@ -40,6 +40,7 @@ import org.oscim.renderer.GLUtils;
|
|||||||
import org.oscim.renderer.GLViewport;
|
import org.oscim.renderer.GLViewport;
|
||||||
import org.oscim.renderer.MapRenderer;
|
import org.oscim.renderer.MapRenderer;
|
||||||
import org.oscim.theme.styles.AreaStyle;
|
import org.oscim.theme.styles.AreaStyle;
|
||||||
|
import org.oscim.utils.ArrayUtils;
|
||||||
import org.oscim.utils.geom.LineClipper;
|
import org.oscim.utils.geom.LineClipper;
|
||||||
import org.oscim.utils.math.Interpolation;
|
import org.oscim.utils.math.Interpolation;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -75,7 +76,8 @@ public final class PolygonBucket extends RenderBucket {
|
|||||||
float ymin = Short.MAX_VALUE;
|
float ymin = Short.MAX_VALUE;
|
||||||
float xmax = Short.MIN_VALUE;
|
float xmax = Short.MIN_VALUE;
|
||||||
float ymax = Short.MIN_VALUE;
|
float ymax = Short.MIN_VALUE;
|
||||||
float[] bbox = new float[8];
|
|
||||||
|
final float[] bbox = new float[8];
|
||||||
|
|
||||||
public void addPolygon(float[] points, int[] index) {
|
public void addPolygon(float[] points, int[] index) {
|
||||||
short center = (short) ((Tile.SIZE >> 1) * S);
|
short center = (short) ((Tile.SIZE >> 1) * S);
|
||||||
@ -101,15 +103,10 @@ public final class PolygonBucket extends RenderBucket {
|
|||||||
for (int j = 0; j < length; j += 2) {
|
for (int j = 0; j < length; j += 2) {
|
||||||
float x = (points[inPos++] * S);
|
float x = (points[inPos++] * S);
|
||||||
float y = (points[inPos++] * S);
|
float y = (points[inPos++] * S);
|
||||||
if (x > xmax)
|
xmax = Math.max(xmax, x);
|
||||||
xmax = x;
|
xmin = Math.min(xmin, x);
|
||||||
if (x < xmin)
|
ymax = Math.max(ymax, y);
|
||||||
xmin = x;
|
ymin = Math.min(ymin, y);
|
||||||
|
|
||||||
if (y > ymax)
|
|
||||||
ymax = y;
|
|
||||||
if (y < ymin)
|
|
||||||
ymin = y;
|
|
||||||
|
|
||||||
if (outline) {
|
if (outline) {
|
||||||
indiceItems.add((short) numVertices);
|
indiceItems.add((short) numVertices);
|
||||||
@ -133,29 +130,20 @@ public final class PolygonBucket extends RenderBucket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME move to prepare
|
@Override
|
||||||
|
protected void prepare() {
|
||||||
|
ArrayUtils.setBox2D(bbox, xmin, ymin, xmax, ymax);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void compile(ShortBuffer vboData, ShortBuffer iboData) {
|
protected void compile(ShortBuffer vboData, ShortBuffer iboData) {
|
||||||
if (area.strokeWidth == 0) {
|
if (area.strokeWidth == 0) {
|
||||||
/* add vertices to shared VBO */
|
/* add vertices to shared VBO */
|
||||||
compileVertexItems(vboData);
|
compileVertexItems(vboData);
|
||||||
return;
|
} else {
|
||||||
|
/* compile with indexed outline */
|
||||||
|
super.compile(vboData, iboData);
|
||||||
}
|
}
|
||||||
|
|
||||||
bbox[0] = xmin;
|
|
||||||
bbox[1] = ymin;
|
|
||||||
|
|
||||||
bbox[2] = xmax;
|
|
||||||
bbox[3] = ymin;
|
|
||||||
|
|
||||||
bbox[4] = xmax;
|
|
||||||
bbox[5] = ymax;
|
|
||||||
|
|
||||||
bbox[6] = xmin;
|
|
||||||
bbox[7] = xmax;
|
|
||||||
|
|
||||||
/* compile with indexed outline */
|
|
||||||
super.compile(vboData, iboData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Shader extends GLShader {
|
static class Shader extends GLShader {
|
||||||
@ -361,6 +349,8 @@ public final class PolygonBucket extends RenderBucket {
|
|||||||
|
|
||||||
byte stencilMask = 0;
|
byte stencilMask = 0;
|
||||||
|
|
||||||
|
float[] box = mBBox;
|
||||||
|
|
||||||
RenderBucket b = buckets;
|
RenderBucket b = buckets;
|
||||||
for (; b != null && b.type == POLYGON; b = b.next) {
|
for (; b != null && b.type == POLYGON; b = b.next) {
|
||||||
PolygonBucket pb = (PolygonBucket) b;
|
PolygonBucket pb = (PolygonBucket) b;
|
||||||
@ -370,19 +360,37 @@ public final class PolygonBucket extends RenderBucket {
|
|||||||
if (area.fadeScale > 0 && area.fadeScale > zoom)
|
if (area.fadeScale > 0 && area.fadeScale > zoom)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// v.mvp.prj2D(pl.bbox, 0, mBBox, 0, 4);
|
v.mvp.prj2D(pb.bbox, 0, box, 0, 4);
|
||||||
// mScreenClip.clipStart(mBBox[0], mBBox[1]);
|
boolean clipRect = true;
|
||||||
//
|
int out = 0;
|
||||||
// if (mScreenClip.clipNext(mBBox[2], mBBox[3]) == 0 &&
|
|
||||||
// mScreenClip.clipNext(mBBox[4], mBBox[5]) == 0 &&
|
for (int i = 0; i < 8; i += 2) {
|
||||||
// mScreenClip.clipNext(mBBox[6], mBBox[7]) == 0 &&
|
int o = mScreenClip.outcode(box[i], box[i + 1]);
|
||||||
// mScreenClip.clipNext(mBBox[0], mBBox[1]) == 0) {
|
|
||||||
//
|
if (o == 0) {
|
||||||
// /* check the very unlikely case where the view might be
|
/* at least one corner is inside */
|
||||||
// * completly contained within mBBox */
|
clipRect = false;
|
||||||
// if (!ArrayUtils.withinRange(mBBox, -1f, 1f))
|
break;
|
||||||
// continue;
|
}
|
||||||
// }
|
out |= o;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if any polygon-bucket edge intersects the screen.
|
||||||
|
* Also check the very unlikely case where the view might be
|
||||||
|
* completly contained within box */
|
||||||
|
if (clipRect && (out != 0xF)) {
|
||||||
|
mScreenClip.clipStart(box[0], box[1]);
|
||||||
|
|
||||||
|
if (mScreenClip.clipNext(box[2], box[3]) == 0 &&
|
||||||
|
mScreenClip.clipNext(box[4], box[5]) == 0 &&
|
||||||
|
mScreenClip.clipNext(box[6], box[7]) == 0 &&
|
||||||
|
mScreenClip.clipNext(box[0], box[1]) == 0) {
|
||||||
|
// log.debug("outside {} {} {}", out,
|
||||||
|
// Arrays.toString(box),
|
||||||
|
// Arrays.toString(pb.bbox));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mClear) {
|
if (mClear) {
|
||||||
clearStencilRegion();
|
clearStencilRegion();
|
||||||
|
@ -147,4 +147,11 @@ public class ArrayUtils {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setBox2D(float[] bbox, float xmin, float ymin, float xmax, float ymax) {
|
||||||
|
bbox[0] = bbox[2] = xmin;
|
||||||
|
bbox[4] = bbox[6] = xmax;
|
||||||
|
bbox[1] = bbox[5] = ymin;
|
||||||
|
bbox[3] = bbox[7] = ymax;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user