diff options
author | Andre Susano Pinto <andresusanopinto@gmail.com> | 2008-07-19 19:22:38 +0400 |
---|---|---|
committer | Andre Susano Pinto <andresusanopinto@gmail.com> | 2008-07-19 19:22:38 +0400 |
commit | 0703d9aad1aa3f1233389c462cdb90414fbe31ae (patch) | |
tree | 7fb20531a53f1cfedd3fbebce2931a7271115441 /source/blender/blenlib/intern/BLI_kdopbvh.c | |
parent | 59a2b5017185369836678b14325666f62dba9311 (diff) |
Following the same optimization as bvh raycast:
*Made nearest surface also use "quad" bvh tree (instead of splitting quads in 2 bvh nodes).
Again that leaded to improvements in build and query time.
*BLI_bvhtree_find_nearest api is now following the same concept as BLI_bvhtree_ray_cast
removed code relative to bvhtree_from_mesh_tris.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_kdopbvh.c')
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdopbvh.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 58a8f9f845c..d9c24853236 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -897,6 +897,7 @@ static float calc_nearest_point(BVHNearestData *data, BVHNode *node, float *near } +// TODO: use a priority queue to reduce the number of nodes looked on static void dfs_find_nearest(BVHNearestData *data, BVHNode *node) { int i; @@ -908,20 +909,18 @@ static void dfs_find_nearest(BVHNearestData *data, BVHNode *node) if(node->totnode == 0) { if(data->callback) - sdist = data->callback(data->userdata , node->index, data->co, nearest); - - if(sdist >= data->nearest.dist) return; - - data->nearest.index = node->index; - VECCOPY(data->nearest.nearest, nearest); - data->nearest.dist = sdist; + data->callback(data->userdata , node->index, data->co, &data->nearest); + else + { + data->nearest.index = node->index; + VECCOPY(data->nearest.co, nearest); + data->nearest.dist = sdist; + } } else { for(i=0; i != node->totnode; i++) - { dfs_find_nearest(data, node->children[i]); - } } } |