You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let ray_dir:Vec3A = world_to_model.transform_vector3(*ray.direction).into();
let ray_origin:Vec3A = world_to_model.transform_point3(ray.origin).into();
// Check if the ray intersects the mesh's AABB. It's useful to work in model space
// because we can do an AABB intersection test, instead of an OBB intersection test.
let t_0:Vec3A = (aabb.min() - ray_origin) / ray_dir;
let t_1:Vec3A = (aabb.max() - ray_origin) / ray_dir;
let t_min:Vec3A = t_0.min(t_1);
let t_max:Vec3A = t_0.max(t_1);
letmut hit_near = t_min.x;
letmut hit_far = t_max.x;
if hit_near > t_max.y || t_min.y > hit_far {
returnNone;
}
if t_min.y > hit_near {
hit_near = t_min.y;
}
if t_max.y < hit_far {
hit_far = t_max.y;
}
if(hit_near > t_max.z) || (t_min.z > hit_far){
returnNone;
}
if t_min.z > hit_near {
hit_near = t_min.z;
}
if t_max.z < hit_far {
hit_far = t_max.z;
}
Some([hit_near, hit_far])
}
}
intersects_aabb returns [NaN, NaN] because of a divide by 0 when the intersection check is right on the edge of a mesh, thus failing the filter predicate far > 0.0 here:
It was not apparent to me what the right approach to prevent intersects_aabb from returning NaN. It's possible I'm being naive, and there's a more obvious fix, however, this diff seems to solve the symptom of that issue. (I have no idea if this introduces other side effects, but all the tests seem to pass?)
From investigating aevyrie/bevy_mod_picking#341, I've discovered that:
bevy_mod_raycast/src/primitives.rs
Lines 165 to 204 in dbc5ef3
intersects_aabb
returns[NaN, NaN]
because of a divide by 0 when the intersection check is right on the edge of a mesh, thus failing the filter predicatefar > 0.0
here:bevy_mod_raycast/src/immediate.rs
Line 260 in dbc5ef3
It was not apparent to me what the right approach to prevent
intersects_aabb
from returningNaN
. It's possible I'm being naive, and there's a more obvious fix, however, this diff seems to solve the symptom of that issue. (I have no idea if this introduces other side effects, but all the tests seem to pass?)The text was updated successfully, but these errors were encountered: