LodGenerator now properly shift short indexes so that there is no negative value when assigned to an int and used as an index in an array

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10783 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
rem..om 11 years ago
parent a14b6a3a50
commit 3800db318c
  1. 6
      engine/src/tools/jme3tools/optimize/LodGenerator.java

@ -326,12 +326,14 @@ public class LodGenerator {
while (b.remaining() != 0) {
Triangle tri = new Triangle();
tri.isRemoved = false;
triangleList.add(tri);
triangleList.add(tri);
for (int i = 0; i < 3; i++) {
if (b instanceof IntBuffer) {
tri.vertexId[i] = ((IntBuffer) b).get();
} else {
tri.vertexId[i] = ((ShortBuffer) b).get();
//bit shift to avoid negative values due to conversion form short to int.
//we need an unsigned int here.
tri.vertexId[i] = ((ShortBuffer) b).get()& 0xffff;
}
// assert (tri.vertexId[i] < vertexLookup.size());
tri.vertex[i] = vertexLookup.get(tri.vertexId[i]);

Loading…
Cancel
Save