Ray Mesh Interesection NaN values on edge

Hi :slightly_smiling_face:,

I’d like to quickly point out that I’ve come across an issue with ray-mesh intersection. In some cases when the ray hits an edge of a triangle in a mesh, the system registers the collision and adds its collision results.
But the contact point of the collision is eg. (NaN, -Infinity, NaN).

Currently, I use a workaround, where I check if the result is NaN or Inf and reconstruct the triangle’s plane and calculate the intersection with the method ray.intersectsWherePlane

Regarding the location of the issue BIHNode.java

 public final int intersectWhere(Ray r,
            Matrix4f worldMatrix,
            BIHTree tree,
            float sceneMin,
            float sceneMax,
            CollisionResults results) {
 float t = r.intersects(v1, v2, v3);
                if (!Float.isInfinite(t)) {
                    if (worldMatrix != null) {
                        worldMatrix.mult(v1, v1);
                        worldMatrix.mult(v2, v2);
                        worldMatrix.mult(v3, v3);
                        float t_world = new Ray(o, d).intersects(v1, v2, v3);
                        t = t_world;

The condition if (!Float.isInfinite(t)) passes and if (worldMatrix != null) passes as well and float t_world = new Ray(o, d).intersects(v1, v2, v3); returns Infinity.