Fix: Object.raycast: error to free treedata

This commit is contained in:
Germano Cavalcante 2017-04-15 02:24:04 -03:00
parent 97d2f63bfe
commit 34ea8058b9
1 changed files with 9 additions and 12 deletions

View File

@ -326,6 +326,8 @@ static void rna_Object_ray_cast(
return;
}
*r_success = false;
/* Test BoundBox first (efficiency) */
BoundBox *bb = BKE_object_boundbox_get(ob);
if (bb) {
@ -333,11 +335,9 @@ static void rna_Object_ray_cast(
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;
}
}
@ -365,20 +365,17 @@ static void rna_Object_ray_cast(
copy_v3_v3(r_location, hit.co);
copy_v3_v3(r_normal, hit.no);
*r_index = dm_looptri_to_poly_index(ob->derivedFinal, &treeData.looptri[hit.index]);
goto finally;
}
}
free_bvhtree_from_mesh(&treeData);
}
*r_success = false;
zero_v3(r_location);
zero_v3(r_normal);
*r_index = -1;
finally:
free_bvhtree_from_mesh(&treeData);
if (*r_success == false) {
zero_v3(r_location);
zero_v3(r_normal);
*r_index = -1;
}
}
static void rna_Object_closest_point_on_mesh(