I found a picking bug, or at least I think so:
At line 395 to 408 in PickingLibaray
List<PickResult> intersecting = getPickCandidates(groups, pickRay);
//Collections.sort(intersecting);
if (intersecting.size() > 0)
{
checkGeomIntersections(intersecting, pickRay, true);
Collections.sort(intersecting);
if (intersecting.size() > 0)
return(intersecting.get(0));
else
return(null);
}
else
return(null);
inside checkGeomIntersections (261 to 272 in PickingLibaray)
if (intersects) {
// write the distance into the PickResult
Point3f p = new Point3f();
p.scaleAdd((float)Math.sqrt(pr.getMinimumDistance()), pickRay.direction, pickRay.origin);
pr.setPos(p);
if (onlyNearest)
return;
} else {
// remove from candidates list
it.remove();
}
and inside PickResult at 248 to 256.
public int compareTo(PickResult pr)
{
if (minDistance - pr.minDistance > 0)
return( 1 );
else if (minDistance - pr.minDistance < 0)
return( -1 );
else
return( 0 );
}
Looking at these the pices of code the following can happen.
A and B both both canidates (in that order)
B is closer to the camera than A
A intersect and B does not
checkGeomIntersections will return after checking that A intersects leaving B in the List to be sorted to the top
I'm not sure what the inteneded way to implement this was however I think swaping the call to checkGeomIntersections and the call to Collectsions.sort would fix this problem. However I thought I'd bring this up before I (or someone else) fixed it.