Object.raycast: Also test distance from BoundBox
If `isect_ray_aabb_v3_simple` provides this information, why not take advantage of it?
This commit is contained in:
parent
480473f1f1
commit
97d2f63bfe
|
@ -326,10 +326,19 @@ static void rna_Object_ray_cast(
|
|||
return;
|
||||
}
|
||||
|
||||
/* Test BoundBox */
|
||||
/* Test BoundBox first (efficiency) */
|
||||
BoundBox *bb = BKE_object_boundbox_get(ob);
|
||||
if (bb && !isect_ray_aabb_v3_simple(origin, direction, bb->vec[0], bb->vec[6], NULL, NULL)) {
|
||||
goto finally;
|
||||
if (bb) {
|
||||
float distmin, distmax;
|
||||
if (isect_ray_aabb_v3_simple(origin, direction, bb->vec[0], bb->vec[6], &distmin, &distmax)) {
|
||||
float dist = distmin >= 0 ? distmin : distmax;
|
||||
if (dist > distance) {
|
||||
goto finally;
|
||||
}
|
||||
}
|
||||
else {
|
||||
goto finally;
|
||||
}
|
||||
}
|
||||
|
||||
BVHTreeFromMesh treeData = {NULL};
|
||||
|
|
Loading…
Reference in New Issue