During picking I get the following exception in some of my 3D models:
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(TimSort.java:899)
at java.util.TimSort.mergeAt(TimSort.java:516)
at java.util.TimSort.mergeForceCollapse(TimSort.java:457)
at java.util.TimSort.sort(TimSort.java:254)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.ArrayList.sort(ArrayList.java:1454)
at java.util.Collections.sort(Collections.java:175)
at com.ardor3d.intersection.PickResults.getPickData(PickResults.java:73)
I tracked it to the following file:
https://github.com/gouessej/Ardor3D/blob/master/ardor3d-core/src/main/java/com/ardor3d/intersection/PickResults.javaIn particular the following code:
private static class DistanceComparator implements Comparator<PickData> {
@Override
public int compare(final PickData o1, final PickData o2) {
if (o1.getIntersectionRecord().getClosestDistance() <= o2.getIntersectionRecord().getClosestDistance()) {
return -1;
}
return 1;
}
}
Shouldn't the above code return zero when o1 and o2 distances are equal?