Lemur collision info null in cursorButtonEvent

I’m trying to use lemur to pick a specified square on a board that is divided into squares:

    CursorEventControl.addListenersToSpatial(board, new CursorListener() {
        public void cursorButtonEvent(CursorButtonEvent event, Spatial target, Spatial capture) {
            if (boardClickListener != null && event.getCollision() != null) {
                Vector3f point = event.getCollision().getContactPoint();
                board.getWorldTransform().transformVector(point, working);
                boardClickListener.accept(event, (int)working.x, (int)working.y);

I’m using a CursorEventControl rather than a MouseEventControl to get the collision data so I can read the collision point where the mouse click ray hits the board.

Unfortunately though event.getCollision() is always null. I even dug into the code and so far as I can see it always will be:

            event1 = new CursorButtonEvent(buttonIndex, pressed, findViewPort(hitTarget), hitTarget, x, y, null);

Am I trying to use this wrong or have I missed a step somewhere?


No… you are being 100% logical. It’s just that for a variety of reasons, button events don’t have the collision info. I hope to fix this someday but it’s not quite as simple as it sounds.

Generally, I just hold onto the last one from the move event which is guaranteed to be current.

Yep, that’s working perfectly thanks.