(fixed in nightly builds) Ray still infinite long after setLimit

Why does this always returns true when I point the camera at the terrain, even when I use setLimit and I’m like 500f away from the point it hits?



[java]

CollisionResults results = new CollisionResults();

Ray ray = new Ray( cam.getLocation(), cam.getDirection().normalize() );

ray.setLimit( 1f );



rootNode.collideWith( ray, results );



System.out.println( (results > 0) );

[/java]



I could fix this myself by checking the range of the first object it hits, but still, shouldn’t ray.setLimit work like this?

Good catch. I just committed a fix to SVN. You will be able to grab it in the latest nightly.



You will have to use the returned count from collideWith():

[java]int numCollisions = rootNode.collideWith( ray, results );

if (numCollisions > 0)

// dance the funky chicken

[/java]

Please stop posting in the developers forum.