Maybe an error in lemurs V1.11 PickState?

I am still struggling with Lemur V1.11 so I decided to rewrite my current project. I have run into a problem, that I believe I have tracked down after spending some time in searching and analyzing.

I have found, that after attaching an AppState to my project lemurs MouseAppState is leading to a Nullpointer exception and thus crashing the code.

The error is produced here:

I have not completely understood why but what I can say is:
If the AppState is attached “rootEntry.root” somehow produces a GuiNode that is empty (has a lot of empty parameters) in that case

has no Worldbound and returns a null value that finally is crashing the code.

If the AppState is not attached we also find a GuiNode but somehow it has parameters e.g. Worldbound.

In lemur V1.10 this was no issue as the code differs at that point

 this.trace("Creating GuiBucket ray.");
--> no getBounds() here
 result = new Ray(new Vector3f(cursor.x, cursor.y, 1000.0F), new Vector3f(0.0F, 0.0F, -1.0F));

Could someone (maybe @pspeed) can try to reproduce the behaviour? Is it me or the code that is wrong?

This are the two classes I have used:

import com.jme3.app.SimpleApplication;
import com.jme3.system.AppSettings;
import com.simsilica.lemur.GuiGlobals;



public class Editor_Main extends SimpleApplication {


    @Override
    public void simpleInitApp() {
        GuiGlobals.initialize(this);
        //     GuiGlobals globals = GuiGlobals.getInstance();
        //      globals.setCursorEventsEnabled(false);
        //       BaseStyles.loadGlassStyle();
        //   globals.getStyles().setDefaultStyle("glass");
    }


    @Override
    public void simpleUpdate(float tpf) {

    }


    public Editor_Main(){
        super(new Test_AppState());
    }


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

}

and the AppState is empty


import com.jme3.app.Application;
import com.jme3.app.state.BaseAppState;

public class Test_AppState extends BaseAppState {
    @Override
    protected void initialize(Application app) {

    }

    @Override
    protected void cleanup(Application app) {

    }

    @Override
    protected void onEnable() {

    }

    @Override
    protected void onDisable() {

    }
    @Override
    public void update(float tpf) {
     }
}

Does this help?

1 Like

JME has a “bug” where it returns null for nodes with no children… like the guiNode.

So you have two choices:

  1. if you don’t plan to use the GUI node then remove it from Lemur’s pick targets.
  2. if you do plan to use the GUI node then put something in it… like the StatsAppState does.

That must be the issue! The size of child was always shown as “0”. Adding a child to the guiNode solves the issue.

I will try to work around it - hard as I had sometimes detached all childs from GuiNode to rebuild the whole GUI and thus is also removing the StatsAppState (content, not the State of course).

if you don’t plan to use the GUI node then remove it from Lemur’s pick targets.<

How? I have seen a method here

I tried to remove it in SimpleApplication directly after initializing lemur with the following line

getStateManager().getState(MouseAppState.class).removeCollisionRoot(getGuiNode());

but it did not work. Where should I call this method? Is this the right way?

So…

  1. if you start using JME 3.2.2 beta you will not even have this issue.

  2. to remove the guiNode as a pick handler you need to reverse what Lemur does when it automatically adds the pick root.

You can see how Lemur’s automatic setup does it here:

So if you don’t want any default handling you could always call that method with false as a parameter… else just reverse what you don’t want:
removeCollisionRoot(app.getGuiViewPort)

I think you’re referring to issue 954.
The fix for that issue was not included in 3.2.2-beta1, so the issue still exists there.

D’oh. Yes, you are correct.

1 Like

I hope it is resolved soon - even by using the

getState(PopupState.class).showPopup(exitmain, null);

I have this issue now. I need to add a child to GuiNode first…

Yes, or just make sure you have the stats state attached and turn the stats off. Then there will always be something invisible in the guiNode.

…this is why most people don’t run into this.