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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-08-22 18:27:06 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-08-22 18:27:06 +0400
commitd3f1222d3809d7a893de4cee541e24b3636563c5 (patch)
tree65840a36ebb10f566de91dcee210aa8d32cdb203 /source/blender/bmesh/operators/bmo_connect.c
parent0fbd15df0ffc7e14cba808df41e50d35e534a5a1 (diff)
Fix #32262: mesh bridge between edge loops failed to find a good edge matching
in some cases, in particular when the the edge loops were not planar. Now rather than finding the shortest distance between two vertices, one from each edge loop and using that as a starting point, it now finds the smallest sum of distances between all vertex pairs that would be connected.
Diffstat (limited to 'source/blender/bmesh/operators/bmo_connect.c')
-rw-r--r--source/blender/bmesh/operators/bmo_connect.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c
index 7418be3565c..a9599a48589 100644
--- a/source/blender/bmesh/operators/bmo_connect.c
+++ b/source/blender/bmesh/operators/bmo_connect.c
@@ -370,39 +370,36 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
}
}
- /* Find the shortest distance from a vert in vv1 to vv2[0]. Use that
- * vertex in vv1 as a starting point in the first loop, while starting
- * from vv2[0] in the second loop. This is a simplistic attempt to get
- * a better edge-to-edge match between the two loops. */
+ /* Find the smallest sum of distances from verts in vv1 to verts in vv2,
+ * finding a starting point in the first loop, to start with vv2[0] in the
+ * second loop. This is a simplistic attempt to get a better edge-to-edge
+ * match between two loops. */
if (cl1) {
- int previ, nexti;
float min = 1e32;
- /* BMESH_TODO: Would be nice to do a more thorough analysis of all
- * the vertices in both loops to find a more accurate match for the
- * starting point and winding direction of the bridge generation. */
-
- for (i = 0; i < BLI_array_count(vv1); i++) {
- if (len_v3v3(vv1[i]->co, vv2[0]->co) < min) {
- min = len_v3v3(vv1[i]->co, vv2[0]->co);
+ for (i = 0; i < lenv1; i++) {
+ float len;
+
+ /* compute summed length between vertices in forward direction */
+ len = 0.0f;
+ for (j = 0; j < lenv2; j++)
+ len += len_v3v3(vv1[clamp_index(i+j, lenv1)]->co, vv2[j]->co);
+
+ if (len < min) {
+ min = len;
starti = i;
}
- }
- /* Reverse iteration order for the first loop if the distance of
- * the (starti - 1) vert from vv1 is a better match for vv2[1] than
- * the (starti + 1) vert.
- *
- * This is not always going to be right, but it will work better in
- * the average case.
- */
- previ = clamp_index(starti - 1, lenv1);
- nexti = clamp_index(starti + 1, lenv1);
-
- /* avoid sqrt for comparison */
- if (len_squared_v3v3(vv1[nexti]->co, vv2[1]->co) > len_squared_v3v3(vv1[previ]->co, vv2[1]->co)) {
- /* reverse direction for reading vv1 (1 is forward, -1 is backward) */
- dir1 = -1;
+ /* compute summed length between vertices in backward direction */
+ len = 0.0f;
+ for (j = 0; j < lenv2; j++)
+ len += len_v3v3(vv1[clamp_index(i-j, lenv1)]->co, vv2[j]->co);
+
+ if (len < min) {
+ min = len;
+ starti = i;
+ dir1 = -1;
+ }
}
}