Strange PickData results (solved)

Here is a strange one. I have a block of code that does distance checking and when I run the code in my main class it works fine. Now I'm trying to refactor my code a little so I moved the code block into a public static method in another class in another package. Now when the code is called it still detects a clollision with the correct object but the distance given by getDistance is always 0.0.



Anyone got any ideas why this sems to break when I move it to another class/package. I've moved it into a seperate method in my main class and it still functions fine. :?



TrianglePickResults results = new TrianglePickResults();
                Ray mouseRay = new Ray(cam.getLocation(), UP);
                results.clear();
                collisionNode.findPick(mouseRay, results);
                // Sorts results into nearest first
                results.setCheckDistance(true);
                if (results.getNumber() >= 1)
                {
                    data = results.getPickData(0);
                    geom = data.getTargetMesh().getParentGeom();
                    terrainHeight = cam.getLocation().getY() + data.getDistance();
                }

OK, I've solved the problem but I don't understand why it works like this, might be a bug.



If you declare TrianglePickResults as a class variable everything works perfectly. If you declare it within your method then distances always come back as 0.



Hope this saves someone else some time.



Jarec