* Fixed crash in MeshLoader when loading LOD levels

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9012 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Sha..rd 13 years ago
parent 95efa5b2ff
commit c30bc66f76
  1. 24
      engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java

@ -513,21 +513,31 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
private void startLodFaceList(String submeshindex, String numfaces) { private void startLodFaceList(String submeshindex, String numfaces) {
int index = Integer.parseInt(submeshindex); int index = Integer.parseInt(submeshindex);
mesh = geoms.get(index).getMesh();
int faceCount = Integer.parseInt(numfaces); int faceCount = Integer.parseInt(numfaces);
VertexBuffer originalIndexBuffer = mesh.getBuffer(Type.Index);
vb = new VertexBuffer(VertexBuffer.Type.Index); vb = new VertexBuffer(VertexBuffer.Type.Index);
sb = BufferUtils.createShortBuffer(faceCount * 3); if (originalIndexBuffer.getFormat() == Format.UnsignedInt){
ib = null; // LOD buffer should also be integer
vb.setupData(Usage.Static, 3, Format.UnsignedShort, sb); ib = BufferUtils.createIntBuffer(faceCount * 3);
sb = null;
vb.setupData(Usage.Static, 3, Format.UnsignedInt, ib);
}else{
sb = BufferUtils.createShortBuffer(faceCount * 3);
ib = null;
vb.setupData(Usage.Static, 3, Format.UnsignedShort, sb);
}
List<VertexBuffer> levels = lodLevels.get(index); List<VertexBuffer> levels = lodLevels.get(index);
if (levels == null) { if (levels == null) {
// Create the LOD levels list
levels = new ArrayList<VertexBuffer>(); levels = new ArrayList<VertexBuffer>();
Mesh submesh = geoms.get(index).getMesh();
levels.add(submesh.getBuffer(Type.Index)); // Add the first LOD level (always the original index buffer)
levels.add(originalIndexBuffer);
lodLevels.put(index, levels); lodLevels.put(index, levels);
} }
levels.add(vb); levels.add(vb);
} }

Loading…
Cancel
Save