[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41339] branches/soc-2011-onion-uv-tools/ source/blender/editors/uvedit/uvedit_ops.c: smart stitching
Antony Riakiotakis
kalast at gmail.com
Fri Oct 28 15:51:06 CEST 2011
Revision: 41339
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41339
Author: psy-fi
Date: 2011-10-28 13:51:06 +0000 (Fri, 28 Oct 2011)
Log Message:
-----------
smart stitching
===================
*Now T key toggles between edge/vert stitcning
*M key toggles between stitch at middle point or on static island
Modified Paths:
--------------
branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c
Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c 2011-10-28 13:09:43 UTC (rev 41338)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c 2011-10-28 13:51:06 UTC (rev 41339)
@@ -1293,6 +1293,8 @@
float limitDist;
/* snap uv islands together during stitching */
char snapIslands;
+ /* stich at midpoints or at islands */
+ char midpoints;
/* editmesh, cached for use in modal handler */
EditMesh *em;
/* element map for getting info about uv connectivity */
@@ -1397,7 +1399,7 @@
/* This function updates the header of the UV editor when the stitch tool updates its settings */
static void stitch_update_header(StitchState *stitch_state, bContext *C)
{
- static char str[] = "Select(V {+Ctrl deselect}) Mode(M): %c Vertex %c Edge %c Preview(P) %c Limit(L) %c Snap(S) Ctrl+Wheel(limit adjust): %.2f";
+ static char str[] = "Select(V {+Ctrl deselect}) Toggle(T) %c Vertex %c Edge, %c Preview(P), %c Limit(L), %c Snap(S), %c Midpoints(M), Ctrl+Wheel(limit adjust): %.2f";
char msg[256];
ScrArea *sa= CTX_wm_area(C);
char mode = (stitch_state->mode == VERT_STITCH);
@@ -1408,6 +1410,7 @@
uv_get_stitch_previewer()->enabled?'*':' ',
stitch_state->use_limit?'*':' ',
stitch_state->snapIslands?'*' :' ',
+ stitch_state->midpoints?'*' :' ' ,
stitch_state->limitDist);
ED_area_headerprint(sa, msg);
}
@@ -2262,6 +2265,7 @@
short preview_enabled = preview->enabled;
EditFace *efa;
EditVert *ev;
+ char stitchAtMidpoints = state->midpoints;
/* cleanup previous preview */
stitch_preview_delete();
@@ -2544,17 +2548,27 @@
if(element->flag & STITCH_STITCHABLE){
UvElement *element_iter = state->elementMap->vert[(*(&element->face->v1 + element->tfindex))->tmp.l];
for(;element_iter; element_iter = element_iter->next){
- if((element_iter->flag & STITCH_STITCHABLE) && (element_iter->island == state->static_island)){
+ if(element_iter->flag & STITCH_STITCHABLE){
MTFace *mt;
efa = element_iter->face;
mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
-
- averageUvPosition[i].uv[0] = mt->uv[element_iter->tfindex][0];
- averageUvPosition[i].uv[1] = mt->uv[element_iter->tfindex][1];
+ if(stitchAtMidpoints){
+ averageUvPosition[i].uv[0] += mt->uv[element_iter->tfindex][0];
+ averageUvPosition[i].uv[1] += mt->uv[element_iter->tfindex][1];
+ averageUvPosition[i].count++;
+ }else if(element_iter->island == state->static_island){
+ averageUvPosition[i].uv[0] = mt->uv[element_iter->tfindex][0];
+ averageUvPosition[i].uv[1] = mt->uv[element_iter->tfindex][1];
+ }
}
}
}
+ if(stitchAtMidpoints){
+ averageUvPosition[i].uv[0] /= averageUvPosition[i].count;
+ averageUvPosition[i].uv[1] /= averageUvPosition[i].count;
+ }
}
+
/* Second pass, propagate changes to stitchable uvs */
for(i = 0; i < state->selection_size; i++){
char stitchable = 0;
@@ -2671,6 +2685,7 @@
stitch_state->mode = RNA_enum_get(op->ptr, "mode");
stitch_state->snapIslands = RNA_boolean_get(op->ptr, "snap_islands");
stitch_state->static_island = RNA_int_get(op->ptr, "static_island");
+ stitch_state->midpoints = RNA_boolean_get(op->ptr, "midpoint_snap");
/* in uv synch selection, all uv's are visible */
if(ts->uv_flag & UV_SYNC_SELECTION){
stitch_state->elementMap = EM_make_uv_element_map(stitch_state->em, 0, 1);
@@ -2872,6 +2887,7 @@
RNA_boolean_set(op->ptr, "snap_islands", stitch_state->snapIslands);
RNA_int_set(op->ptr, "static_island", stitch_state->static_island);
RNA_enum_set(op->ptr, "mode", stitch_state->mode);
+ RNA_boolean_set(op->ptr, "midpoint_snap", stitch_state->midpoints);
/* Store selection for re-execution of stitch */
for(i = 0; i < stitch_state->selection_size; i++){
PointerRNA itemptr;
@@ -3083,9 +3099,18 @@
}
return OPERATOR_RUNNING_MODAL;
- /* Use Edge selection */
case MKEY:
if(event->val == KM_PRESS){
+ stitch_state->midpoints = !stitch_state->midpoints;
+ if(!stitch_process_data(stitch_state, scene, 0)){
+ return stitch_cancel(C, op);
+ }
+ }
+ break;
+
+ /* Use Edge selection */
+ case TKEY:
+ if(event->val == KM_PRESS){
EditVert *ev;
int i;
@@ -3160,9 +3185,8 @@
if(!stitch_process_data(stitch_state, scene, 0)){
return stitch_cancel(C, op);
}
- break;
}
- return OPERATOR_RUNNING_MODAL;
+ break;
/* Select geometry based on mode (vertex or edges)*/
@@ -3280,6 +3304,7 @@
RNA_def_enum(ot->srna, "mode", mode, VERT_STITCH, "Mode", "Vertex or edge stitching mode. In Edge stitching, both uv's must be stitchable to stitch");
RNA_def_float(ot->srna, "limit", 0.01f, 0.0f, FLT_MAX, "Limit", "Limit distance in normalized coordinates", 0.0, FLT_MAX);
RNA_def_int(ot->srna, "static_island", 0, 0, INT_MAX, "Static Island", "Island that stays in place when stitching islands", 0, INT_MAX);
+ RNA_def_boolean(ot->srna, "midpoint_snap", 1, "Snap At Midpoint", "Uv's are stitched at midpoint instead of at static island");
prop = RNA_def_collection_runtime(ot->srna, "selection", &RNA_SelectedUvElement, "Selection", "");
/* Selection should not be editable or viewed in toolbar */
RNA_def_property_flag(prop, PROP_HIDDEN);
More information about the Bf-blender-cvs
mailing list