Lemur layer comparators not being initiated for gui viewport

I’ve been trying to use the layers system to keep things right on a panel rotation in the guiNode. However, it didn’t work until I added the comparators to the gui viewport. The GuiGlobals constructor adds the layer comparator for the Gui Bucket in the main viewport instead of the gui viewport.

    protected GuiGlobals( Application app ) {
        ...........
        ViewPort main = app.getViewPort();
        setupGuiComparators(main);
    }

....

    public void setupGuiComparators( ViewPort view ) {
        RenderQueue rq = view.getQueue();

        rq.setGeometryComparator(Bucket.Opaque,
                                 new LayerComparator(rq.getGeometryComparator(Bucket.Opaque), -1));
        rq.setGeometryComparator(Bucket.Transparent,
                                 new LayerComparator(rq.getGeometryComparator(Bucket.Transparent), -1));
        rq.setGeometryComparator(Bucket.Gui,
                                 new LayerComparator(rq.getGeometryComparator(Bucket.Gui), -1));
    }

Adding it to the gui viewport instead seems to solve the problem.

Good catch…

Not “instead”… “in addition to”… the one for the gui bucket of the main viewport should stay, too, I think.

Do note that it’s somewhat less critical in the GUI buckets as they are sorted by straight Z and its easier to manage. But it should still work like it’s supposed to… so it’s definitely a bug that I missed it.

Well, each time I try to add something to the Gui bucket in the main viewport that thing disappears (I though it wasn’t meant to be used in main) but yeah, it doesn’t harm anyone to add it in that viewport too.

It wasn’t critical until I faced the need of it :wink:

The Gui bucket should work fine in the 3D scene graph… but you have to remember the position is always in screen space in the Gui bucket.

(Note: this is true even in the gui viewport because the x,y in that viewport are all messed up… it’s only the fact that things are in the Gui bucket that makes it work since that bucket totally overrides the viewport settings.)

1 Like