GeometryBuffer: switch to int[] indices
This commit is contained in:
parent
7be8155939
commit
990e04477c
@ -369,7 +369,7 @@ public class TileDecoder extends PbfDecoder {
|
||||
|
||||
decodeVarintArray(indexCnt, mElem.index);
|
||||
|
||||
short[] index = mElem.index;
|
||||
int[] index = mElem.index;
|
||||
int coordCnt = 0;
|
||||
|
||||
for (int i = 0; i < indexCnt; i++) {
|
||||
|
@ -65,7 +65,7 @@ public class OSciMap2TileSource extends UrlTileSource {
|
||||
private static final int TAG_ELEM_MIN_HEIGHT = 32;
|
||||
private static final int TAG_ELEM_PRIORITY = 41;
|
||||
|
||||
private short[] mSArray;
|
||||
private int[] mSArray;
|
||||
private final TagSet mTileTags;
|
||||
private final MapElement mElem;
|
||||
|
||||
@ -82,7 +82,7 @@ public class OSciMap2TileSource extends UrlTileSource {
|
||||
mTileTags = new TagSet(20);
|
||||
|
||||
// temp array for decoding shorts
|
||||
mSArray = new short[100];
|
||||
mSArray = new int[100];
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -115,7 +115,7 @@ public class OSciMap2TileSource extends UrlTileSource {
|
||||
case TAG_TILE_TAG_KEYS:
|
||||
int len = numTags;
|
||||
if (mSArray.length < len)
|
||||
mSArray = new short[len];
|
||||
mSArray = new int[len];
|
||||
|
||||
decodeVarintArray(numTags, mSArray);
|
||||
break;
|
||||
@ -163,7 +163,7 @@ public class OSciMap2TileSource extends UrlTileSource {
|
||||
mElem.ensureIndexSize(indexCnt, false);
|
||||
decodeVarintArray(indexCnt, mElem.index);
|
||||
|
||||
short[] index = mElem.index;
|
||||
int[] index = mElem.index;
|
||||
int coordCnt = 0;
|
||||
|
||||
for (int i = 0; i < indexCnt; i++) {
|
||||
|
@ -56,7 +56,7 @@ public class GeometryBuffer {
|
||||
public float[] points;
|
||||
|
||||
/** The indexes. */
|
||||
public short[] index;
|
||||
public int[] index;
|
||||
|
||||
/** The current index position. */
|
||||
public int indexPos;
|
||||
@ -76,11 +76,11 @@ public class GeometryBuffer {
|
||||
* @param points the points
|
||||
* @param index the index
|
||||
*/
|
||||
public GeometryBuffer(float[] points, short[] index) {
|
||||
public GeometryBuffer(float[] points, int[] index) {
|
||||
if (points == null)
|
||||
points = new float[GROW_POINTS];
|
||||
if (index == null)
|
||||
index = new short[GROW_INDICES];
|
||||
index = new int[GROW_INDICES];
|
||||
|
||||
this.points = points;
|
||||
this.index = index;
|
||||
@ -129,7 +129,7 @@ public class GeometryBuffer {
|
||||
* @param numIndices the num indices
|
||||
*/
|
||||
public GeometryBuffer(int numPoints, int numIndices) {
|
||||
this(new float[numPoints * 2], new short[numIndices]);
|
||||
this(new float[numPoints * 2], new int[numIndices]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -304,11 +304,11 @@ public class GeometryBuffer {
|
||||
* @param copy the copy
|
||||
* @return the short[] array holding current index
|
||||
*/
|
||||
public short[] ensureIndexSize(int size, boolean copy) {
|
||||
public int[] ensureIndexSize(int size, boolean copy) {
|
||||
if (size < index.length)
|
||||
return index;
|
||||
|
||||
short[] newIndex = new short[size + GROW_INDICES];
|
||||
int[] newIndex = new int[size + GROW_INDICES];
|
||||
if (copy)
|
||||
System.arraycopy(index, 0, newIndex, 0, index.length);
|
||||
|
||||
|
@ -40,7 +40,7 @@ class S3DBTileLoader extends TileLoader {
|
||||
4096, 0, 0,
|
||||
0, 4096, 0,
|
||||
4096, 4096, 0 };
|
||||
g.index = new short[] { 0, 1, 2, 2, 1, 3 };
|
||||
g.index = new int[] { 0, 1, 2, 2, 1, 3 };
|
||||
mTilePlane.tags.add(new Tag("c", "transparent"));
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class ExtrusionLayer extends RenderElement {
|
||||
if (element.type != GeometryType.TRIS)
|
||||
return;
|
||||
|
||||
short[] index = element.index;
|
||||
int[] index = element.index;
|
||||
float[] points = element.points;
|
||||
|
||||
int vertexCnt = sumVertices;
|
||||
@ -338,7 +338,7 @@ public class ExtrusionLayer extends RenderElement {
|
||||
|
||||
public void add(MapElement element, float height, float minHeight) {
|
||||
|
||||
short[] index = element.index;
|
||||
int[] index = element.index;
|
||||
float[] points = element.points;
|
||||
|
||||
/* 10 cm steps */
|
||||
@ -415,7 +415,7 @@ public class ExtrusionLayer extends RenderElement {
|
||||
|
||||
/** roof indices for concave shapes */
|
||||
private void addRoof(int startVertex, GeometryBuffer geom, int ipos, int ppos) {
|
||||
short[] index = geom.index;
|
||||
int[] index = geom.index;
|
||||
float[] points = geom.points;
|
||||
|
||||
int len = 0;
|
||||
|
@ -43,7 +43,7 @@ public final class LineLayer extends RenderElement {
|
||||
/** scale factor mapping extrusion vector to short values */
|
||||
public static final float DIR_SCALE = 2048;
|
||||
|
||||
/** maximal resoultion */
|
||||
/** maximal resolution */
|
||||
private static final float MIN_DIST = 1 / 8f;
|
||||
|
||||
/**
|
||||
@ -110,7 +110,7 @@ public final class LineLayer extends RenderElement {
|
||||
addLine(points, null, numPoints, closed);
|
||||
}
|
||||
|
||||
private void addLine(float[] points, short[] index, int numPoints, boolean closed) {
|
||||
private void addLine(float[] points, int[] index, int numPoints, boolean closed) {
|
||||
|
||||
boolean rounded = false;
|
||||
boolean squared = false;
|
||||
|
@ -105,7 +105,7 @@ public final class LineTexLayer extends RenderElement {
|
||||
addLine(geom.points, geom.index);
|
||||
}
|
||||
|
||||
public void addLine(float[] points, short[] index) {
|
||||
public void addLine(float[] points, int[] index) {
|
||||
|
||||
if (vertexItems.empty()) {
|
||||
/* HACK add one vertex offset when compiling
|
||||
|
@ -78,7 +78,7 @@ public final class PolygonLayer extends IndexedRenderElement {
|
||||
float ymax = Short.MIN_VALUE;
|
||||
float[] bbox = new float[8];
|
||||
|
||||
public void addPolygon(float[] points, short[] index) {
|
||||
public void addPolygon(float[] points, int[] index) {
|
||||
short center = (short) ((Tile.SIZE >> 1) * S);
|
||||
|
||||
short id = (short) numVertices;
|
||||
|
@ -319,7 +319,7 @@ public abstract class PbfDecoder implements ITileDecoder {
|
||||
return ((val >>> 1) ^ -(val & 1));
|
||||
}
|
||||
|
||||
public void decodeVarintArray(int num, short[] array) throws IOException {
|
||||
public void decodeVarintArray(int num, int[] array) throws IOException {
|
||||
int bytes = decodeVarint32();
|
||||
fillBuffer(bytes);
|
||||
|
||||
@ -353,7 +353,7 @@ public abstract class PbfDecoder implements ITileDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
array[cnt] = (short) val;
|
||||
array[cnt] = val;
|
||||
}
|
||||
|
||||
if (pos != bufferPos + bytes)
|
||||
|
@ -554,7 +554,7 @@ public class MapDatabase implements ITileDataSource {
|
||||
}
|
||||
|
||||
//short[] wayLengths = new short[numBlocks];
|
||||
short[] wayLengths = mElem.ensureIndexSize(numBlocks, false);
|
||||
int[] wayLengths = mElem.ensureIndexSize(numBlocks, false);
|
||||
if (wayLengths.length > numBlocks)
|
||||
wayLengths[numBlocks] = -1;
|
||||
|
||||
@ -962,7 +962,7 @@ public class MapDatabase implements ITileDataSource {
|
||||
private boolean projectToTile(GeometryBuffer geom) {
|
||||
|
||||
float[] coords = geom.points;
|
||||
short[] indices = geom.index;
|
||||
int[] indices = geom.index;
|
||||
|
||||
long x = mTile.tileX * Tile.SIZE;
|
||||
long y = mTile.tileY * Tile.SIZE + Tile.SIZE;
|
||||
|
@ -59,7 +59,7 @@ public class TileDecoder extends PbfDecoder {
|
||||
private static final int TAG_ELEM_COORDS = 13;
|
||||
private static final int TAG_ELEM_LAYER = 21;
|
||||
|
||||
private short[] mSArray = new short[100];
|
||||
private int[] mSArray = new int[100];
|
||||
|
||||
private Tile mTile;
|
||||
|
||||
@ -153,7 +153,7 @@ public class TileDecoder extends PbfDecoder {
|
||||
case TAG_TILE_TAGS:
|
||||
int len = numTags * 2;
|
||||
if (mSArray.length < len)
|
||||
mSArray = new short[len];
|
||||
mSArray = new int[len];
|
||||
|
||||
decodeVarintArray(len, mSArray);
|
||||
if (!decodeTileTags(numTags, mSArray, keys, values)) {
|
||||
@ -181,7 +181,7 @@ public class TileDecoder extends PbfDecoder {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean decodeTileTags(int numTags, short[] tagIdx,
|
||||
private boolean decodeTileTags(int numTags, int[] tagIdx,
|
||||
String[] keys, String[] vals) {
|
||||
|
||||
Tag tag;
|
||||
@ -234,7 +234,7 @@ public class TileDecoder extends PbfDecoder {
|
||||
mElem.ensureIndexSize(indexCnt, false);
|
||||
decodeVarintArray(indexCnt, mElem.index);
|
||||
|
||||
short[] index = mElem.index;
|
||||
int[] index = mElem.index;
|
||||
int coordCnt = 0;
|
||||
|
||||
if (shift) {
|
||||
@ -373,8 +373,8 @@ public class TileDecoder extends PbfDecoder {
|
||||
|
||||
private boolean decodeElementTags(int numTags) throws IOException {
|
||||
if (mSArray.length < numTags)
|
||||
mSArray = new short[numTags];
|
||||
short[] tagIds = mSArray;
|
||||
mSArray = new int[numTags];
|
||||
int[] tagIds = mSArray;
|
||||
|
||||
decodeVarintArray(numTags, tagIds);
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class Tessellator {
|
||||
* Special version for ExtrusionLayer to match indices with vertex
|
||||
* positions.
|
||||
*/
|
||||
public static int tessellate(float[] points, int ppos, int plen, short[] index,
|
||||
public static int tessellate(float[] points, int ppos, int plen, int[] index,
|
||||
int ipos, int rings, int vertexOffset, VertexData outTris) {
|
||||
|
||||
int[] result = new int[2];
|
||||
@ -156,6 +156,7 @@ public class Tessellator {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* FIXME This modifies geom ?! */
|
||||
public static int tessellate(GeometryBuffer geom, float scale,
|
||||
VertexData outPoints, VertexData outTris, int vertexOffset) {
|
||||
|
||||
@ -180,6 +181,7 @@ public class Tessellator {
|
||||
numPoints += geom.index[idx];
|
||||
}
|
||||
|
||||
/* FIXME !!! */
|
||||
for (int i = pointPos; i < pointPos + numPoints; i += 2) {
|
||||
geom.points[i + 0] = (int) (geom.points[i + 0] * s);
|
||||
geom.points[i + 1] = (int) (geom.points[i + 1] * s);
|
||||
@ -257,7 +259,7 @@ public class Tessellator {
|
||||
* @return context - must be freed with tessFinish()
|
||||
*/
|
||||
protected static native long tessellate(float[] points, int pos,
|
||||
short[] index, int ipos, int numRings, int[] result);
|
||||
int[] index, int ipos, int numRings, int[] result);
|
||||
|
||||
protected static native void tessFinish(long ctx);
|
||||
|
||||
@ -268,7 +270,7 @@ public class Tessellator {
|
||||
|
||||
protected static native int tessGetVerticesFloat(long ctx, float[] coordinates);
|
||||
|
||||
protected static native int tessGetIndices(long ctx, short[] indices);
|
||||
protected static native int tessGetIndices(long ctx, int[] indices);
|
||||
|
||||
protected static native int tessGetIndicesWO(long ctx, short[] indices, int offset);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class SimplifyDP {
|
||||
int[] stack = new int[32];
|
||||
|
||||
public void simplify(GeometryBuffer geom, float sqTolerance) {
|
||||
short[] idx = geom.index;
|
||||
int[] idx = geom.index;
|
||||
|
||||
int inPos = 0;
|
||||
int outPos = 0;
|
||||
|
@ -79,7 +79,7 @@ public class TileClipper {
|
||||
|
||||
int numLines = mLineClipper.clipLine(geom, out);
|
||||
|
||||
short idx[] = geom.ensureIndexSize(numLines + 1, false);
|
||||
int idx[] = geom.ensureIndexSize(numLines + 1, false);
|
||||
System.arraycopy(out.index, 0, idx, 0, numLines);
|
||||
geom.index[numLines] = -1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user