Revision: 47766
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47766
Author: psy-fi
Date: 2012-06-11 23:16:05 +0000 (Mon, 11 Jun 2012)
Log Message:
-----------
UV transform correction tool
=============================
* Sort UVs according to island, this will save some time and pain when
flushing uvs of separate uv islands
* Cleanup unneeded assert code and old variables
Modified Paths:
--------------
branches/soc-2012-bratwurst/source/blender/editors/transform/transform.c
branches/soc-2012-bratwurst/source/blender/editors/transform/transform.h
branches/soc-2012-bratwurst/source/blender/editors/transform/transform_conversions.c
branches/soc-2012-bratwurst/source/blender/editors/transform/transform_generics.c
Modified:
branches/soc-2012-bratwurst/source/blender/editors/transform/transform.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/transform/transform.c
2012-06-11 23:03:08 UTC (rev 47765)
+++ branches/soc-2012-bratwurst/source/blender/editors/transform/transform.c
2012-06-11 23:16:05 UTC (rev 47766)
@@ -1887,9 +1887,7 @@
/* stay here for now, maybe will find some other way to aviod
duplicating in every transform
* apply funtion */
if(t->flag & T_IMAGE_PRESERVE_CALC) {
- /* can be invalidated if for instance we change the radius of
proportional editing */
- //if(!t->uvtc->init)
- calculateUVTransformCorrection(t);
+ calculateUVTransformCorrection(t);
}
/* If auto confirm is on, break after one pass */
Modified:
branches/soc-2012-bratwurst/source/blender/editors/transform/transform.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/transform/transform.h
2012-06-11 23:03:08 UTC (rev 47765)
+++ branches/soc-2012-bratwurst/source/blender/editors/transform/transform.h
2012-06-11 23:16:05 UTC (rev 47766)
@@ -226,14 +226,16 @@
float init_uv[2]; /* initial uv value */
float *uv; /* pointer to the corresponding luv->uv */
struct UVTransCorrInfoUV *next; /* next uv for same vertex */
+ int island_index; /* index of the per-vertex uv island */
}UVTransCorrInfoUV;
/* unwrap transform correction structure, will contain mesh elements that will
be used for unwrapping */
typedef struct UVTransCorrect {
UVTransCorrInfoUV **initial_uvs;
- float (*init_vec)[3]; /* initial vertex value */
+ /* initial vertex value. We have to store it here too because for
proportional editing
+ * we can't correlate vertex indices to transdata anymore due to
sorting */
+ float (*init_vec)[3];
int total_verts;
- char init;
} UVTransCorrect;
typedef struct TransData {
Modified:
branches/soc-2012-bratwurst/source/blender/editors/transform/transform_conversions.c
===================================================================
---
branches/soc-2012-bratwurst/source/blender/editors/transform/transform_conversions.c
2012-06-11 23:03:08 UTC (rev 47765)
+++
branches/soc-2012-bratwurst/source/blender/editors/transform/transform_conversions.c
2012-06-11 23:16:05 UTC (rev 47766)
@@ -89,6 +89,7 @@
#include "BKE_tessmesh.h"
#include "BKE_tracking.h"
#include "BKE_mask.h"
+#include "BKE_mesh.h"
#include "ED_anim_api.h"
@@ -2050,7 +2051,6 @@
/* now we need to allocate store for affected verts if we do maintain
image */
if(t->flag & T_IMAGE_PRESERVE_CALC) {
uvtc = t->uvtc = MEM_callocN(sizeof(*t->uvtc),
"UVTransformCorrect");
-// uvtc->affected_verts = affected_verts = MEM_mallocN(t->total *
sizeof(*t->uvtc->affected_verts), "uvtc_verts");
uvtc->initial_uvs = initial_uvs = MEM_mallocN(bm->totvert *
sizeof(*t->uvtc->initial_uvs), "uvtc_inituvs");
uvtc->init_vec = MEM_mallocN(bm->totvert *
sizeof(*t->uvtc->init_vec), "uvtc_initial_vertexes");
uvtc->total_verts = bm->totvert;
@@ -2124,16 +2124,14 @@
tx++;
if(t->flag & T_IMAGE_PRESERVE_CALC) {
+ int island = 0;
BMIter iter2;
UVTransCorrInfoUV **uvtcuv =
initial_uvs + a;
UVTransCorrInfoUV *uvprev = NULL;
+ UVTransCorrInfoUV *uviter = NULL,
*uviter2 = NULL;
tob->eve = eve;
- if(propmode)
- BLI_assert(i == a);
- BLI_assert(BM_elem_index_get(eve) == a);
-
BM_ITER_ELEM(l, &iter2, eve,
BM_LOOPS_OF_VERT) {
MLoopUV *luv =
CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -2147,6 +2145,47 @@
(*uvtcuv)->next = NULL;
uvtcuv = &((*uvtcuv)->next);
}
+
+ /* Now we need to sort uvs according to
uv island */
+ uviter2 = initial_uvs[a];
+ while(uviter2) {
+ uviter2->island_index = island;
+ uviter = uviter2->next;
+ uvprev = uviter2;
+
+ while(uviter) {
+ UVTransCorrInfoUV
*tmpuv = uviter->next;
+ float diff[2];
+ sub_v2_v2v2(diff,
uviter->uv, uviter2->uv);
+ if(len_v2(diff) <
STD_UV_CONNECT_LIMIT) {
+
uviter->island_index = island;
+
+ /* this avoids
circular queue */
+
if(uviter2->next != uviter) {
+
uviter->next = uviter2->next;
+ /*
change after if test to avoid altering the result
+ * in
case uviter2 equals uvprev */
+
uvprev->next = tmpuv;
+ } else {
+ /*
change before altering uvprev */
+
uvprev->next = tmpuv;
+ /* if
iter is equal to iter2, uvprev must move or
+ * it
will still point to iter2 */
+ uvprev
= uviter;
+ }
+
+ /* if uvprev
and uviter2 are the same this overrides previous */
+ uviter2->next =
uviter;
+ uviter2 =
uviter;
+ } else {
+ uvprev = uviter;
+ }
+ uviter = tmpuv;
+ }
+
+ uviter2 = uviter2->next;
+ island++;
+ }
}
/* selected */
Modified:
branches/soc-2012-bratwurst/source/blender/editors/transform/transform_generics.c
===================================================================
---
branches/soc-2012-bratwurst/source/blender/editors/transform/transform_generics.c
2012-06-11 23:03:08 UTC (rev 47765)
+++
branches/soc-2012-bratwurst/source/blender/editors/transform/transform_generics.c
2012-06-11 23:16:05 UTC (rev 47766)
@@ -1696,8 +1696,13 @@
}
}
-int bmesh_disk_facevert_count(BMVert *v);
+/* flush the calculated displacement to uvs of the same uv island */
+static void flushUVdisplacement(UVTransCorrInfoUV *first, float disp[2], int
optimal)
+{
+}
+
+
/* this function detects boundary mesh elements that will encompass the faces
to send to the unwrapper.
* These elements will be artificially pinned for this first attempt at the
algorithm */
void calculateUVTransformCorrection(TransInfo *t)
@@ -1719,6 +1724,13 @@
/* iterate through loops of vert and calculate image space diff of uvs
*/
for (i = 0 ; i < t->total; i++) {
if(not_prop_edit || td[i].factor > 0.0) {
+ /* last island visited, if this changes without an
optimal face found,
+ * we flush the result */
+ int last_insland = 0;
+
+ float min_angles[2] = {100.0, 100.0} /* arbitrary, just
bigger than 2PI */;
+ BMLoop *boundary_loops[2];
+
char optimal_found = FALSE;
char nochange = FALSE;
int index;
@@ -1969,9 +1981,4 @@
}
t->proptext[0] = '\0';
}
-
- /* we need to redetect boundaries for uv */
- if(t->flag & T_IMAGE_PRESERVE_CALC) {
- t->uvtc->init = 0;
- }
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs