Batching GUI elements

Sounded like it was already overridden… else how are the invisible-but-still-there children traversed?

But yeah, it seems logical to me to exclude the batch geoms. I can’t think of a use-case where that would be a good thing.

Like with any other node really. When a geom is batched it’s marked as grouped, which in turn mark it as culled (forced culled on checkCulling, not through the cullHint). But the geom is still there in the scene graph so the collision occur as usual.
IMO OP’s issue is with the batch geoms that interfere. Indeed I can’t see a use case where you need to collide with them.

So I have made some changes in BatchNode class (added collideWith) and prepared a pull request:
https://github.com/jMonkeyEngine/jmonkeyengine/pull/426
Could someone review it?
Thanks. :smile:

I merged it btw

2 Likes

Yes I have noticed, thank you! :smile:

How did you fix that?. I’m having the exact same issue, which can be seen with the next piece of code:

public class LemurBatchingIssue extends SimpleApplication {

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

    BatchNode batchNode;
    float batchDelay = Float.MAX_VALUE;

    @Override
    public void simpleInitApp() {
        GuiGlobals.initialize(this);
        BaseStyles.loadGlassStyle();
        GuiGlobals.getInstance().getStyles().setDefaultStyle("glass");

        Container container = new Container(new SpringGridLayout());
        Panel panel = container.addChild(new Panel());
        panel.setInsets(new Insets3f(300, 300, 300, 300));
        container.setPreferredSize(new Vector3f(cam.getWidth(), cam.getHeight(), 1));
        container.setLocalTranslation(0, cam.getHeight(), 0);

        batchNode = new BatchNode();

        batchNode.attachChild(container);

        container.getControl(GuiControl.class).addListener(new AbstractGuiControlListener() {
            @Override
            public void reshape(GuiControl source, Vector3f pos, Vector3f size) {
                batchDelay = 1;
            }
        });

        guiNode.attachChild(batchNode);
    }

    @Override
    public void simpleUpdate(float tpf) {
        if((batchDelay -= tpf) <= 0) {
            System.out.println("BATCHED");
            batchNode.batch();
            batchDelay = Float.MAX_VALUE;
        }
    }
}

Without looking into this in detail, I can say that generally if you want to batch something like UI elements then you need to sort them by Z before batching. This would be the same for any GUI objects, not just Lemur’s.

When they are batched, they still need to be drawn back to front or you will have issues.

Ok, thanks.

This part is the one my mind couldn’t figure out xD.