File tree 1 file changed +14
-9
lines changed
jme3-core/src/main/java/com/jme3/collision/bih
1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -411,15 +411,20 @@ public final int intersectWhere(Ray r,
411
411
t = t_world ;
412
412
}
413
413
414
- Vector3f contactNormal = Triangle .computeTriangleNormal (v1 , v2 , v3 , null );
415
- Vector3f contactPoint = new Vector3f (d ).multLocal (t ).addLocal (o );
416
- float worldSpaceDist = o .distance (contactPoint );
417
-
418
- CollisionResult cr = new CollisionResult (contactPoint , worldSpaceDist );
419
- cr .setContactNormal (contactNormal );
420
- cr .setTriangleIndex (tree .getTriangleIndex (i ));
421
- results .addCollision (cr );
422
- cols ++;
414
+ // this second isInfinite test is unlikely to fail but due to numeric precision it might
415
+ // be the case that in local coordinates it just hits and in world coordinates it just misses
416
+ // this filters those cases out (treating them as misses).
417
+ if (!Float .isInfinite (t )){
418
+ Vector3f contactNormal = Triangle .computeTriangleNormal (v1 , v2 , v3 , null );
419
+ Vector3f contactPoint = new Vector3f (d ).multLocal (t ).addLocal (o );
420
+ float worldSpaceDist = o .distance (contactPoint );
421
+
422
+ CollisionResult cr = new CollisionResult (contactPoint , worldSpaceDist );
423
+ cr .setContactNormal (contactNormal );
424
+ cr .setTriangleIndex (tree .getTriangleIndex (i ));
425
+ results .addCollision (cr );
426
+ cols ++;
427
+ }
423
428
}
424
429
}
425
430
}
You can’t perform that action at this time.
0 commit comments