Fix T55964: Direction not normalized in isect_ray_aabb_v3_simple()?
RNA API Object.ray_cast would not normalize direction vector before doing first quick bbox intersection test, while using its returned distance value. This could lead to wrong exclusion of object. Thanks to @codemanx for finding that issue.
This commit is contained in:
@@ -332,8 +332,10 @@ static void rna_Object_ray_cast(
|
|||||||
/* Test BoundBox first (efficiency) */
|
/* Test BoundBox first (efficiency) */
|
||||||
BoundBox *bb = BKE_object_boundbox_get(ob);
|
BoundBox *bb = BKE_object_boundbox_get(ob);
|
||||||
float distmin;
|
float distmin;
|
||||||
if (!bb || (isect_ray_aabb_v3_simple(origin, direction, bb->vec[0], bb->vec[6], &distmin, NULL) && distmin <= distance)) {
|
normalize_v3(direction); /* Needed for valid distance check from isect_ray_aabb_v3_simple() call. */
|
||||||
|
if (!bb ||
|
||||||
|
(isect_ray_aabb_v3_simple(origin, direction, bb->vec[0], bb->vec[6], &distmin, NULL) && distmin <= distance))
|
||||||
|
{
|
||||||
BVHTreeFromMesh treeData = {NULL};
|
BVHTreeFromMesh treeData = {NULL};
|
||||||
|
|
||||||
/* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
|
/* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
|
||||||
@@ -346,9 +348,6 @@ static void rna_Object_ray_cast(
|
|||||||
hit.index = -1;
|
hit.index = -1;
|
||||||
hit.dist = distance;
|
hit.dist = distance;
|
||||||
|
|
||||||
normalize_v3(direction);
|
|
||||||
|
|
||||||
|
|
||||||
if (BLI_bvhtree_ray_cast(treeData.tree, origin, direction, 0.0f, &hit,
|
if (BLI_bvhtree_ray_cast(treeData.tree, origin, direction, 0.0f, &hit,
|
||||||
treeData.raycast_callback, &treeData) != -1)
|
treeData.raycast_callback, &treeData) != -1)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user