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>2012-11-14 06:58:43 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-14 06:58:43 +0400
commit54ff14c29ded160c05389a0ca08c771aa01a41ab (patch)
tree8e2c58490f2bf3baea8fe4def3303e54b6d927d4 /source/blender/editors
parentcc8a43fb22e714953a347533f87402148f48e6e4 (diff)
speedup to uv remove doubles.
- no need to copy the UV vectors, just point to them. - calculate the midpoint once and copy rather then mid_v2_v2v2() on each UV. - reduce the number of comparisons by only checking the remaining uv's in the nested loop.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 52f36da7be4..0ca25096359 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -1570,8 +1570,8 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
MTexPoly *tf;
int uv_a_index;
int uv_b_index;
- float uv_a[2];
- float uv_b[2];
+ float *uv_a;
+ float *uv_b;
float weld_dist;
MLoopUV **loop_arr = NULL;
BLI_array_declare(loop_arr);
@@ -1616,16 +1616,15 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
BLI_array_empty(loop_arr);
BLI_array_append(loop_arr, vert_arr[uv_a_index].uv_loop);
- copy_v2_v2(uv_a, vert_arr[uv_a_index].uv_loop->uv);
+ uv_a = vert_arr[uv_a_index].uv_loop->uv;
copy_v2_v2(uv_max, uv_a);
copy_v2_v2(uv_min, uv_a);
vert_arr[uv_a_index].weld = TRUE;
- for (uv_b_index = 0; uv_b_index < BLI_array_count(vert_arr); uv_b_index++) {
- copy_v2_v2(uv_b, vert_arr[uv_b_index].uv_loop->uv);
- if ((uv_a_index != uv_b_index) &&
- (vert_arr[uv_b_index].weld == FALSE) &&
+ for (uv_b_index = uv_a_index + 1; uv_b_index < BLI_array_count(vert_arr); uv_b_index++) {
+ uv_b = vert_arr[uv_b_index].uv_loop->uv;
+ if ((vert_arr[uv_b_index].weld == FALSE) &&
(len_manhattan_v2v2(uv_a, uv_b) < weld_dist))
{
minmax_v2v2_v2(uv_max, uv_min, uv_b);
@@ -1633,8 +1632,12 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
vert_arr[uv_b_index].weld = TRUE;
}
}
- for (uv_b_index = 0; uv_b_index < BLI_array_count(loop_arr); uv_b_index++) {
- mid_v2_v2v2(loop_arr[uv_b_index]->uv, uv_min, uv_max);
+ if (BLI_array_count(loop_arr)) {
+ float uv_mid[2];
+ mid_v2_v2v2(uv_mid, uv_min, uv_max);
+ for (uv_b_index = 0; uv_b_index < BLI_array_count(loop_arr); uv_b_index++) {
+ copy_v2_v2(loop_arr[uv_b_index]->uv, uv_mid);
+ }
}
}
}