Ray intersection distances returning Infinity

I have a slight problem whereby any of my collisions are returning Infinity as the distance between the Ray origin and the Geom in question. See code extract below:



results = new TrianglePickResults();
results.setCheckDistance(true);

...

ArrayList<Spatial> children = objectNode.getChildren();
SpaceObject collidedObject = null;
SpaceObject spaceObject;
Laser laser;
Node node;
float distanceTravelled;
float distance;
float min = Float.MAX_VALUE;

if(children != null) {
   for(int i=0; i<children.size(); i++) {
      if(children.get(i) instanceof Laser) {

         laser = (Laser) children.get(i);
         laser.getRay().getDirection().set(laser.getLocalTranslation());
         laser.getRay().getDirection().subtractLocal(laser.getRay().getOrigin());
         laser.getRay().getDirection().normalizeLocal();

         distanceTravelled = FastMath.abs(laser.getRay().getOrigin().distance(laser.getRay().getDirection()));

         for(int j=0; j<objectCollection.size(); j++) {
            if(objectCollection.get(j) instanceof Vessel) {
               spaceObject = objectCollection.get(j);

               results.clear();

               node = (Node) spaceObject.getSpatial();
               node.findPick(laser.getRay(), results);

               for(int k=0; k<results.getNumber(); k++) {
                  distance = results.getPickData(k).getDistance();
System.out.println("Checking laser agains SO: "+spaceObject.getSpatial().getName() + " - Distance: " + distance);
               }
            }
         }
         
         laser.getRay().setOrigin(laser.getLocalTranslation());
      }
   }
}



The result is always: Checking laser agains SO: Model - Distance: Infinity
What would cause this?

Thats exactly what I thought. I tracked it down to a class I've forgotten and it was due to an empty array of Tri's - if that helps anybody  :smiley:

Infinity should mean it didn't intersect the object?

whatever it is, maybe i've found it as well:

http://www.jmonkeyengine.com/jmeforum/index.php?topic=6492.0



in some cases, i found 0.0 and infinity in my pickresults. if either of these values means "no contact", then there shouldn't be a pickresulst at all.