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:
authorCampbell Barton <ideasman42@gmail.com>2015-08-24 01:13:58 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-08-24 01:23:24 +0300
commit231ee60ab5373bb2e5676fc4f5c6dea476fc1d42 (patch)
treeb1c590e63c91b38f183344471f99eca63a978860
parent8a623b066eb0f5ac280ff50db3052c4f9e97734c (diff)
mathutils.BVHTree: support overlap self-intersect
Use same logic as BKE_bmbvh_overlap
-rw-r--r--source/blender/python/mathutils/mathutils_bvhtree.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c
index 4d18d7b67bc..8a488fdfd08 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -460,8 +460,27 @@ static bool py_bvhtree_overlap_cb(void *userdata, int index_a, int index_b, int
const unsigned int *tri_b = tree_b->tris[index_b];
const float *tri_a_co[3] = {tree_a->coords[tri_a[0]], tree_a->coords[tri_a[1]], tree_a->coords[tri_a[2]]};
const float *tri_b_co[3] = {tree_b->coords[tri_b[0]], tree_b->coords[tri_b[1]], tree_b->coords[tri_b[2]]};
+ float ix_pair[2][3];
+ int verts_shared = 0;
- return isect_tri_tri_epsilon_v3(UNPACK3(tri_a_co), UNPACK3(tri_b_co), NULL, NULL, data->epsilon);
+ if (tree_a == tree_b) {
+ if (UNLIKELY(index_a == index_b)) {
+ return false;
+ }
+
+ verts_shared = (
+ ELEM(tri_a_co[0], UNPACK3(tri_b_co)) +
+ ELEM(tri_a_co[1], UNPACK3(tri_b_co)) +
+ ELEM(tri_a_co[2], UNPACK3(tri_b_co)));
+
+ /* if 2 points are shared, bail out */
+ if (verts_shared >= 2) {
+ return false;
+ }
+ }
+
+ return (isect_tri_tri_epsilon_v3(UNPACK3(tri_a_co), UNPACK3(tri_b_co), ix_pair[0], ix_pair[1], data->epsilon) &&
+ ((verts_shared == 0) || (len_squared_v3v3(ix_pair[0], ix_pair[1]) > data->epsilon)));
}
PyDoc_STRVAR(py_bvhtree_overlap_doc,