Browse Source

* Ensure the statistics properly represent number of objects / triangles / vertices rendered when using instancing

shadowislord 11 năm trước cách đây
mục cha
commit
c925104f5e

+ 11 - 5
jme3-core/src/main/java/com/jme3/renderer/Statistics.java

@@ -120,15 +120,21 @@ public class Statistics {
 
 
     /**
     /**
      * Called by the Renderer when a mesh has been drawn.
      * Called by the Renderer when a mesh has been drawn.
-     * 
      */
      */
-    public void onMeshDrawn(Mesh mesh, int lod){
+    public void onMeshDrawn(Mesh mesh, int lod, int count){
         if( !enabled )
         if( !enabled )
             return;
             return;
             
             
-        numObjects ++;
-        numTriangles += mesh.getTriangleCount(lod);
-        numVertices += mesh.getVertexCount();
+        numObjects += count;
+        numTriangles += mesh.getTriangleCount(lod) * count;
+        numVertices += mesh.getVertexCount() * count;
+    }
+    
+    /**
+     * Called by the Renderer when a mesh has been drawn.
+     */
+    public void onMeshDrawn(Mesh mesh, int lod){
+        onMeshDrawn(mesh, lod, 1);
     }
     }
 
 
     /**
     /**

+ 1 - 1
jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java

@@ -2545,7 +2545,7 @@ public class LwjglRenderer implements Renderer {
             context.lineWidth = mesh.getLineWidth();
             context.lineWidth = mesh.getLineWidth();
         }
         }
 
 
-        statistics.onMeshDrawn(mesh, lod);
+        statistics.onMeshDrawn(mesh, lod, count);
 //        if (GLContext.getCapabilities().GL_ARB_vertex_array_object){
 //        if (GLContext.getCapabilities().GL_ARB_vertex_array_object){
 //            renderMeshVertexArray(mesh, lod, count);
 //            renderMeshVertexArray(mesh, lod, count);
 //        }else{
 //        }else{