jME3 Ray Picking null pointers occasionaly

Hey - I have written a bit of code which lists the intersections a ray from the mouse cursor to infinity touches.



The problem is - it occasionally null pointers on the getName() call on geometry. I am presuming this is because some geometry's have no name?? This is probably normal though i would imagine but not necessarily good practice. I get round it with a try catch - however the detail I really want is the node's name , not the geometry's.



Does anybody know how to get that based upon the code I am currently using :



   CollisionResults results = new CollisionResults();
        System.out.println("


Collisions? " + results.size() + "
");
        SnowReference.getRootNode().collideWith(ray, results);
        for (int p = 0; p < results.size(); p++) {
            // For each hit, we know distance, impact point, name of geometry.
            try {
                float dist = results.getCollision(p).getDistance();
                Vector3f pt = results.getCollision(p).getContactPoint();
                String hit = results.getCollision(p).getGeometry().getName();
                System.out.println("* Collision #" + p);
                System.out.println("  You shot " + hit + " at " + pt + ", " + dist + " wu away.");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

Yes, its normal that geometrys have null names. With spatial.getParent() you can get the parent node of any spatial.

Well actually its not normal. Names are a very useful debugging tool, so ideally finding where a null name is being generated and fixing it would be a good idea.

So I am guessing I was right when i said geometrys if they are 3d models usually have their name set by the artists themselves - in which case i should go beat up my artists and modellers!?



Thanks



Andy

XD

Heh no, actually the names for imported models are usually automatically generated and are based on the filename of the model.

It's probably either something in your code, like new Geometry(null, …) or in some internal jME3 code.

Ahh i see - well in that case we may well have a bug! If i can ever locate what or why this is happening Ill post on this thread