Geometry's Transformation not updated under specific configuration

Okay I found this bug that happens under a specific configuration. When a Geometry, that has more than 1 light and has a local transform (meaning that both RF_LIGHTLIST and RF_TRANSFORM flags are active), is added directly to a viewport, the cachedWorldMat will never be updated. This means that the geometry will not render using the provided transform, until the RF_TRANSFORM flag is marked for a refresh again.
Here is a simple test case:


package mygame;

import com.jme3.app.FlyCamAppState;
import com.jme3.app.SimpleApplication;
import com.jme3.app.StatsAppState;
import com.jme3.light.AmbientLight;
import com.jme3.light.PointLight;
import com.jme3.light.SpotLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;

public class Main extends SimpleApplication {

    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }

    Geometry rootGeo;

    @Override
    public void simpleInitApp() {
        Box b = new Box(1, 1, 1);
        rootGeo = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);
        rootGeo.setMaterial(mat);
        viewPort.detachScene(rootNode);

        rootGeo.move(1, 0, 0);
        rootGeo.addLight(new PointLight());
        rootGeo.addLight(new SpotLight());
        viewPort.attachScene(rootGeo);

    }

    @Override
    public void simpleUpdate(float tpf) {
        rootGeo.updateLogicalState(tpf);
        rootGeo.updateGeometricState();
    }

    @Override
    public void simpleRender(RenderManager rm) {
        //TODO: add render code
    }
}

If you run the provided class, you will see the demo blue box in the middle of the viewport. However, if you read the code right, you will see that the box should had moved of 1 unit to the right. Removing one of the added light in the code will re enable the proper placement of the geometry.

What happens here is that when there is more than 1 light, the LightList will need to sort the lights based on the transform of the Geometry. This will then update the world bound of the geometry, which then depends on the transform of the geometry. The method checkDoTransformUpdate() will be called, where the RF_TRANSFORM flag will be cleared without actually updating the cachedWorldMat.

Changing the method Spatial#checkDoTransformUpdate() from

void checkDoTransformUpdate() {
        if ((refreshFlags & RF_TRANSFORM) == 0) {
            return;
        }

        if (parent == null) {
            worldTransform.set(localTransform);
            refreshFlags &= ~RF_TRANSFORM;
        } else {
          ...
        }
}

to

void checkDoTransformUpdate() {
        if ((refreshFlags & RF_TRANSFORM) == 0) {
            return;
        }

        if (parent == null) {
           updateWorldTransforms();
        } else {
          ...
        }
}

will solve the problem. However I don’t actually think that this is the best solution since the geometry’s implementation of updateWorldTransforms() will call a refresh of the worldLightList . . . which is what we are currently doing.