diff options
author | mano-wii <germano.costa@ig.com.br> | 2020-01-04 14:34:10 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2020-01-04 14:34:10 +0300 |
commit | 8314e201398a22522e25eb3254d5b47f4f3f65f4 (patch) | |
tree | 012eb0531ea669041c2d46d714160bc5afc869dc | |
parent | aad09525fb554ed023419d1c4fd12a5b8da72660 (diff) |
BLI_bvhtree_overlap: Don't use BLI_task API when not needed
No functional change.
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdopbvh.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 7ac4a362cf4..d5bedaadb8b 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -113,7 +113,6 @@ BLI_STATIC_ASSERT((sizeof(void *) == 8 && sizeof(BVHTree) <= 48) || typedef struct BVHOverlapData_Shared { const BVHTree *tree1, *tree2; axis_t start_axis, stop_axis; - bool use_threading; /* use for callbacks */ BVHTree_OverlapCallback callback; @@ -1252,11 +1251,8 @@ static void bvhtree_overlap_task_cb(void *__restrict userdata, const int j, const TaskParallelTLS *__restrict UNUSED(tls)) { - BVHOverlapData_Thread *data = (BVHOverlapData_Thread *)userdata; + BVHOverlapData_Thread *data = &((BVHOverlapData_Thread *)userdata)[j]; BVHOverlapData_Shared *data_shared = data->shared; - if (data_shared->use_threading) { - data += j; - } if (data_shared->callback) { tree_overlap_traverse_cb(data, @@ -1274,11 +1270,8 @@ static void bvhtree_overlap_num_task_cb(void *__restrict userdata, const int j, const TaskParallelTLS *__restrict UNUSED(tls)) { - BVHOverlapData_Thread *data = (BVHOverlapData_Thread *)userdata; + BVHOverlapData_Thread *data = &((BVHOverlapData_Thread *)userdata)[j]; BVHOverlapData_Shared *data_shared = data->shared; - if (data_shared->use_threading) { - data += j; - } tree_overlap_num_recursive(data, data_shared->tree1->nodes[data_shared->tree1->totleaf]->children[j], @@ -1333,7 +1326,6 @@ BVHTreeOverlap *BLI_bvhtree_overlap_ex( data_shared.tree2 = tree2; data_shared.start_axis = start_axis; data_shared.stop_axis = stop_axis; - data_shared.use_threading = use_threading; /* can be NULL */ data_shared.callback = callback; @@ -1349,14 +1341,27 @@ BVHTreeOverlap *BLI_bvhtree_overlap_ex( data[j].thread = j; } - TaskParallelSettings settings; - BLI_parallel_range_settings_defaults(&settings); - settings.use_threading = use_threading; - BLI_task_parallel_range(0, - root_node_len, - data, - max_interactions ? bvhtree_overlap_num_task_cb : bvhtree_overlap_task_cb, - &settings); + if (use_threading) { + TaskParallelSettings settings; + BLI_parallel_range_settings_defaults(&settings); + BLI_task_parallel_range(0, + root_node_len, + data, + max_interactions ? bvhtree_overlap_num_task_cb : + bvhtree_overlap_task_cb, + &settings); + } + else { + if (max_interactions) { + tree_overlap_num_recursive(data, root1, root2); + } + else if (callback) { + tree_overlap_traverse_cb(data, root1, root2); + } + else { + tree_overlap_traverse(data, root1, root2); + } + } if (overlap_pairs) { for (j = 0; j < thread_num; j++) { |