GeometryBatchFactory is loosing HWSkinning buffers

Hi all,

I am using the GeometraBatchfactory for my animated models to be optimized. This worked quite well a long time ago. With the new HW Skinning code in place something is missing in the batch factory I guess, as they do not play well together.

You get null pointer exceptions in the prepare for hw anim code, when you run the mesh through an optimizer.

It can be tested by adding the optimize line in the TestHWSkinning.java file

            Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
            model.setLocalScale(0.1f);
            model.setLocalTranslation(i - SIZE / 2, 0, j - SIZE / 2);
            <strong>GeometryBatchFactory.optimize((Node) model);</strong>

Debugging shows, the buffers are present before optimize, but not thereafter.

Error you get is:

java.lang.NullPointerException
at com.jme3.scene.Mesh.prepareForAnim(Mesh.java:392)
at com.jme3.animation.SkeletonControl.switchToHardware(SkeletonControl.java:126)
at com.jme3.animation.SkeletonControl.testHardwareSupported(SkeletonControl.java:158)
at com.jme3.animation.SkeletonControl.controlRender(SkeletonControl.java:298)
at com.jme3.scene.control.AbstractControl.render(AbstractControl.java:119)
at com.jme3.scene.Spatial.runControlRender(Spatial.java:590)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:655)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:665)
at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:640)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:974)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1029)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:252)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:722)

I guess the cause lies with the following lines. please mind, this is not the suggested patch.
The HWSkinning buffers have 0 components, cence will not be created.

Index: src/tools/jme3tools/optimize/GeometryBatchFactory.java

— src/tools/jme3tools/optimize/GeometryBatchFactory.java (revision 10748)
+++ src/tools/jme3tools/optimize/GeometryBatchFactory.java (working copy)
@@ -163,9 +163,9 @@

     // generate output buffers based on retrieved info
     for (int i = 0; i &lt; compsForBuf.length; i++) {
  •        if (compsForBuf[i] == 0) {
    
  •            continue;
    
  •        }
    

+// if (compsForBuf[i] == 0) {
+// continue;
+// }

         Buffer data;
         if (i == Type.Index.ordinal()) {

Regards
ghoust