Possible bug with Node.findPick?

Hello.



I'm a Java developer by trade, but I've recently started looking at jME for fun in my spare time, and I've come across something that looks like a bug to me, although most likely I've got it all wrong somehow.



I reckon there may be a bug in Node.findPick:

    @Override
    public void findPick(Ray toTest, PickResults results, int requiredOnBits) {
        if(children == null) {
            return;
        }
        if (getWorldBound() != null && isCollidable(requiredOnBits)) {
            if (getWorldBound().intersects(toTest)) {
                // further checking needed.
                for (int i = 0; i < getQuantity(); i++) {
                    ( children.get(i)).findPick(toTest, results);
                }
            }
        }
    }

Shouldn't the last line, the call to findPick on the node's children, be:

( children.get(i)).findPick(toTest, results, requiredOnBits);


Because, if I understand the point of the collision mask, you only want to get those children that have any of those bits set. But, by not including requiredOnBits in the method call, it gets defaulted to 1 (in Spatial), which may not be the collision mask (requiredOnBits) that you called Node.findPick with.

I think I've got a workaround for this, but if this is a bug, I'm suprised that no one's spotted it and fixed it by now, as I'm not really doing anything that complex. All that happens in my "game" is that you walk (instead of flying) on top of any objects below you (instead of flying through them), and surely every other jME game must have code to do that as well?

So, the reason I'm using collision masks is because sometimes the IntersectionRecord tells me that the "down" skybox mesh is right below the camera, when, in fact, it should be at -200. This only happens at the beginning of my "game" if I press "A" or "D" to move left or right (for reasons that elude me). So, the reason I decided to use collision masks was so that I could just ignore the skybox meshes when "finding picks" (things that collide with a Ray going straight down from the camera).

As I say, I'm new to jME, so I may well have just not done something the blindingly obvious way it was supposed to be done. But, one way or another, is that findPick method supposed to work like that?

Thanks!

Yeah that certainly looks like an oversight. Collision masks were a pretty recent change, and to differentiate types of collidable objects. Most people probably use the original method that uses the default…



Why not just set the skybox to non-collidable so an intersection with it gets ignored in the beginning?

I hadn't thought of that, but it's easy to workaround anyway. As my "game" only has 3 Boxes and a Skybox so far, I'd just added everything to rootNode, so findPick was looking at the Boxes and the Skybox. Workaround was just to put the Boxes into a child node (which I'd have started to do anyway once my game got a bit more complex) and call findPick on that instead, thereby ignoring the Skybox.



Thanks for the second opinion though. I'll add the bug to the Tracker.