Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2017-04-15 07:31:24 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2017-04-15 07:31:24 +0300
commit97d2f63bfe6d166eca12f7dec0e6525806990f49 (patch)
treed3c03af2371aa39ee4d9e01a5148c56908375647 /source/blender/makesrna/intern
parent480473f1f1008168e7784221b852a6d370a0f4f5 (diff)
Object.raycast: Also test distance from BoundBox
If `isect_ray_aabb_v3_simple` provides this information, why not take advantage of it?
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 3b2e57a06e5..42d1b78784f 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -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};