From 176b806626ed62cb1bb9f609f927dc27e6e9c268 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 20 Aug 2015 17:32:25 +1000 Subject: BVH-overlap: add callback to BLI_bvhtree_overlap The callback checks if 2 nodes intersect (not just their AABB). Advantages: - theres no need to allocate overlaps which are later ignored. - expensive intersection tests will run multi-threaded. Currently only used for Python API. --- source/blender/blenlib/BLI_kdopbvh.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/blenlib/BLI_kdopbvh.h') diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h index 9f16b02da33..6fc93ca9cdb 100644 --- a/source/blender/blenlib/BLI_kdopbvh.h +++ b/source/blender/blenlib/BLI_kdopbvh.h @@ -74,6 +74,9 @@ typedef void (*BVHTree_NearestPointCallback)(void *userdata, int index, const fl /* callback must update hit in case it finds a nearest successful hit */ typedef void (*BVHTree_RayCastCallback)(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit); +/* callback to check if 2 nodes overlap (use thread if intersection results need to be stored) */ +typedef bool (*BVHTree_OverlapCallback)(void *userdata, int index_a, int index_b, unsigned int thread); + /* callback to range search query */ typedef void (*BVHTree_RangeQuery)(void *userdata, int index, float dist_sq); @@ -88,8 +91,12 @@ void BLI_bvhtree_balance(BVHTree *tree); bool BLI_bvhtree_update_node(BVHTree *tree, int index, const float co[3], const float co_moving[3], int numpoints); void BLI_bvhtree_update_tree(BVHTree *tree); +unsigned int BLI_bvhtree_overlap_thread_num(const BVHTree *tree); + /* collision/overlap: check two trees if they overlap, alloc's *overlap with length of the int return value */ -BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int *r_overlap_tot); +BVHTreeOverlap *BLI_bvhtree_overlap( + const BVHTree *tree1, const BVHTree *tree2, unsigned int *r_overlap_tot, + BVHTree_OverlapCallback callback, void *userdata); float BLI_bvhtree_getepsilon(const BVHTree *tree); -- cgit v1.2.3