Need help find the issue raycasting dont catch some guiNode Quads

Hello :slight_smile:

I need your help to understand what might be wrong. Overall it works, but noticed recently that my grid layout have some odd issues where raycast pick dont see Quad geometries even when his Quads are visible on screen. Below is code i use and video:

quad = new Quad(1, 1);
quadGeo = new Geometry("BoxQuad", quad); // using Quad object

all i do is:

CollisionResults results = new CollisionResults();

getGuiNode().collideWith(ray, results);
if (results.size() > 0) {
    int i = 0;
    for (CollisionResult result : results) {
        System.out.println("result"+i+": " + result);
        System.out.println("result"+i+" parent: " + result.getGeometry().getParent());
//rest of code

where using:

new Ray(new Vector3f(app.getInputManager().getCursorPosition().getX(), app.getInputManager().getCursorPosition().getY(), 100000), (new Vector3f(0, 0, -1)).normalizeLocal())

but some of Quad even when visible on screen are not caught by this raycast.

if there is just result0, then it catch only global background alpha window.

if there are result0 and result1 it catch both grid Quad and global background alpha window.

video below:

  • please look at results and raycast params. (z index might be wrong sometimes because i tested, but anyway it just dont see this BoxQuad for some of areas, and i really dont know the reason)

belive it might be something related to positioning(because only this grid layout seems to have issues), but since Quad is visible directly on screen it should be raycasted right?

also not sure why it is always for first, some middle and 2 last boxes.

I understand its probably some mistake i made, but hope you will help me find it :slight_smile:

just one more note:

quad is updated this way:

quad.updateGeometry(boxTransform.getWidth(), boxTransform.getHeight());

and it is always in 0,0 in its parent node that only this parent change position.

btw. i dont use pictures because Quads are more universal.

i think i solved it since it work, but not sure what happend.

not 100% sure but Seems like setting

quad.updateGeometry(boxTransform.getWidth(), boxTransform.getHeight());

caused issue when i set like 1 width/height for Culled out of grid elements.

when i setup same sizes for “not visible Quads”, it works now…

trully, i dont even need to cull this elements to have issue, just setting it different than first time made issue for me.

Not sure if JME bug or something…


so you say i should run this “mesh.clearCollisionData” each quad.updateGeometry right?

i thought it will do it itself.

thanks :slight_smile: might try it later

JME usually doesn’t call methods like this unnecessarily if it can avoid it.

You might change the size of your quad a million times before ever doing any collision related stuff… no reason to needlessly clear the data in that case.

And anyway, the code is always two clicks away if you want to ever check these things.

1 Like