VertexData: float params add() versions

This commit is contained in:
Hannes Janetzek 2014-10-04 00:33:32 +02:00
parent 03f6f96988
commit 9d86c6306d
2 changed files with 28 additions and 7 deletions

View File

@ -68,19 +68,19 @@ public class MeshBucket extends RenderBucket {
return;
}
vertexItems.add((short) (geom.points[0] * COORD_SCALE),
(short) (geom.points[1] * COORD_SCALE));
vertexItems.add(geom.points[0] * COORD_SCALE,
geom.points[1] * COORD_SCALE);
vertexItems.add((short) (geom.points[2] * COORD_SCALE),
(short) (geom.points[3] * COORD_SCALE));
vertexItems.add(geom.points[2] * COORD_SCALE,
geom.points[3] * COORD_SCALE);
short prev = (short) (start + 1);
numVertices += 2;
for (int i = 4; i < geom.index[0]; i += 2) {
vertexItems.add((short) (geom.points[i + 0] * COORD_SCALE),
(short) (geom.points[i + 1] * COORD_SCALE));
vertexItems.add(geom.points[i + 0] * COORD_SCALE,
geom.points[i + 1] * COORD_SCALE);
indiceItems.add(start, prev, ++prev);
numVertices++;

View File

@ -19,6 +19,7 @@ package org.oscim.renderer.bucket;
import java.nio.ShortBuffer;
import org.oscim.renderer.bucket.VertexData.Chunk;
import org.oscim.utils.FastMath;
import org.oscim.utils.pool.Inlist;
import org.oscim.utils.pool.SyncPool;
import org.slf4j.Logger;
@ -150,6 +151,14 @@ public class VertexData extends Inlist.List<Chunk> {
vertices[used++] = a;
}
static final short toShort(float v) {
return (short) FastMath.clamp(v, Short.MIN_VALUE, Short.MAX_VALUE);
}
public void add(float a, float b) {
add(toShort(a), toShort(b));
}
public void add(short a, short b) {
if (used == SIZE)
getNext();
@ -159,6 +168,10 @@ public class VertexData extends Inlist.List<Chunk> {
used += 2;
}
public void add(float a, float b, float c) {
add(toShort(a), toShort(b), toShort(c));
}
public void add(short a, short b, short c) {
if (used == SIZE)
getNext();
@ -169,6 +182,10 @@ public class VertexData extends Inlist.List<Chunk> {
used += 3;
}
public void add(float a, float b, float c, float d) {
add(toShort(a), toShort(b), toShort(c), toShort(d));
}
public void add(short a, short b, short c, short d) {
if (used == SIZE)
getNext();
@ -180,6 +197,10 @@ public class VertexData extends Inlist.List<Chunk> {
used += 4;
}
public void add(float a, float b, float c, float d, float e, float f) {
add(toShort(a), toShort(b), toShort(c), toShort(d), toShort(e), toShort(f));
}
public void add(short a, short b, short c, short d, short e, short f) {
if (used == SIZE)
getNext();
@ -216,7 +237,7 @@ public class VertexData extends Inlist.List<Chunk> {
used = size;
}
/* Do not use! */
/** Do not use! */
public void seek(int offset) {
used += offset;
cur.used = used;