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 file

            Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
            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:

at com.jme3.scene.Mesh.prepareForAnim(
at com.jme3.animation.SkeletonControl.switchToHardware(
at com.jme3.animation.SkeletonControl.testHardwareSupported(
at com.jme3.animation.SkeletonControl.controlRender(
at com.jme3.scene.control.AbstractControl.render(
at com.jme3.scene.Spatial.runControlRender(
at com.jme3.renderer.RenderManager.renderSubScene(
at com.jme3.renderer.RenderManager.renderSubScene(
at com.jme3.renderer.RenderManager.renderScene(
at com.jme3.renderer.RenderManager.renderViewPort(
at com.jme3.renderer.RenderManager.render(
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(

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/

— src/tools/jme3tools/optimize/ (revision 10748)
+++ src/tools/jme3tools/optimize/ (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()) {