Просмотр исходного кода

fix issue #1382 (LODGeomap index buffers with elements too small) (#1418)

Stephen Gold 4 лет назад
Родитель
Сommit
507cc2213f

+ 4 - 9
jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/LODGeomap.java

@@ -158,14 +158,11 @@ public class LODGeomap extends GeoMap {
      * @return the LOD-ified index buffer
      */
     public IndexBuffer writeIndexArrayLodDiff(int lod, boolean rightLod, boolean topLod, boolean leftLod, boolean bottomLod, int totalSize) {
-
-        
+        int numVertices = getWidth() * getHeight();
         int numIndexes = calculateNumIndexesLodDiff(lod);
-        
-        IndexBuffer ib = IndexBuffer.createIndexBuffer(numIndexes, numIndexes);
+        IndexBuffer ib = IndexBuffer.createIndexBuffer(numVertices, numIndexes);
         VerboseBuffer buffer = new VerboseBuffer(ib);
 
-
         // generate center squares minus the edges
         //System.out.println("for (x="+lod+"; x<"+(getWidth()-(2*lod))+"; x+="+lod+")");
         //System.out.println("	for (z="+lod+"; z<"+(getWidth()-(1*lod))+"; z+="+lod+")");
@@ -360,13 +357,11 @@ public class LODGeomap extends GeoMap {
     }
 
     public IndexBuffer writeIndexArrayLodVariable(int lod, int rightLod, int topLod, int leftLod, int bottomLod, int totalSize) {
-
+        int numVertices = getWidth() * getHeight();
         int numIndexes = calculateNumIndexesLodDiff(lod);
-        
-        IndexBuffer ib = IndexBuffer.createIndexBuffer(numIndexes, numIndexes);
+        IndexBuffer ib = IndexBuffer.createIndexBuffer(numVertices, numIndexes);
         VerboseBuffer buffer = new VerboseBuffer(ib);
 
-
         // generate center squares minus the edges
         //System.out.println("for (x="+lod+"; x<"+(getWidth()-(2*lod))+"; x+="+lod+")");
         //System.out.println("	for (z="+lod+"; z<"+(getWidth()-(1*lod))+"; z+="+lod+")");