[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40972] branches/soc-2011-onion-uv-tools/ source/blender/editors/uvedit: smart stitching
Antony Riakiotakis
kalast at gmail.com
Thu Oct 13 00:46:51 CEST 2011
Revision: 40972
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40972
Author: psy-fi
Date: 2011-10-12 22:46:51 +0000 (Wed, 12 Oct 2011)
Log Message:
-----------
smart stitching
================
*edge preview sanity check. Checks simply if edge is border.
Modified Paths:
--------------
branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_draw.c
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_draw.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_draw.c 2011-10-12 22:42:13 UTC (rev 40971)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_draw.c 2011-10-12 22:46:51 UTC (rev 40972)
@@ -911,11 +911,11 @@
/* draw edge preview */
UI_ThemeColor4(TH_STITCH_PREVIEW_STITCHABLE);
glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewStitchable);
- glDrawArrays(GL_POINTS, 0, 2*stitch_preview->numOfStitchable);
+ glDrawArrays(GL_LINES, 0, 2*stitch_preview->numOfStitchable);
UI_ThemeColor4(TH_STITCH_PREVIEW_UNSTITCHABLE);
glVertexPointer(2, GL_FLOAT, 0, stitch_preview->previewUnstitchable);
- glDrawArrays(GL_POINTS, 0, 2*stitch_preview->numOfUnstitchable);
+ glDrawArrays(GL_LINES, 0, 2*stitch_preview->numOfUnstitchable);
}
glPopClientAttrib();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
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-12 22:42:13 UTC (rev 40971)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c 2011-10-12 22:46:51 UTC (rev 40972)
@@ -1396,7 +1396,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): %f Static Island(I): %d";
+ 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 Island(I): %d";
char msg[256];
ScrArea *sa= CTX_wm_area(C);
char mode = (stitch_state->mode == VERT_STITCH);
@@ -1413,22 +1413,6 @@
}
}
-/* Set preview buffer position of UV face in editface->tmp.l */
-static void stitch_set_face_preview_buffer_position(EditFace *efa, StitchPreviewer *preview)
-{
- if(efa->tmp.l == -1)
- {
- if(efa->v4)
- {
- efa->tmp.l = preview->numOfQuads*8;
- preview->numOfQuads++;
- } else {
- efa->tmp.l = preview->numOfTris*6;
- preview->numOfTris++;
- }
- }
-}
-
static int getNumOfIslandUvs(UvElementMap *elementMap, int island){
if(island == elementMap->totalIslands-1){
return elementMap->totalUVs - elementMap->islandIndices[island];
@@ -2125,46 +2109,8 @@
return OPERATOR_FINISHED;
}
+#endif
-static int stitch_init(bContext *C, wmOperator *op)
-{
- StitchState *stitch_state = MEM_mallocN(sizeof(StitchState), "stitch_state");
- StitchPreviewer *preview = stitch_preview_init();
- Scene *scene = CTX_data_scene(C);
-
- Object *obedit = CTX_data_edit_object(C);
-
- preview->enabled = 1;
- op->customdata = stitch_state;
-
- if(!stitch_state)
- return 0;
-
- stitch_state->use_limit = RNA_boolean_get(op->ptr, "use_limit");
- stitch_state->limitDist = RNA_float_get(op->ptr, "limit");
- stitch_state->em = BKE_mesh_get_editmesh((Mesh*)obedit->data);
- stitch_state->mode = RNA_enum_get(op->ptr, "mode");
- stitch_state->snapIslands = RNA_boolean_get(op->ptr, "snap_islands");
- if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION){
- stitch_state->elementMap = EM_make_uv_element_map(stitch_state->em, 0, 1);
- }else {
- stitch_state->elementMap = EM_make_uv_element_map(stitch_state->em, 1, 1);
- }
-
-
- if(!stitch_state->elementMap){
- stitch_preview_delete();
- return 0;
- }
- stitch_process_data(stitch_state, 0, scene, 1);
-
- stitch_update_header(stitch_state, C);
- return 1;
-}
-
-#else
-/* New stitch stuff */
-
static void stitch_state_delete(StitchState *stitch_state)
{
if(stitch_state){
@@ -2224,61 +2170,71 @@
return 0;
}
+/* Set preview buffer position of UV face in editface->tmp.l */
+static void stitch_set_face_preview_buffer_position(EditFace *efa, StitchPreviewer *preview)
+{
+ if(efa->tmp.l == -1)
+ {
+ if(efa->v4)
+ {
+ efa->tmp.l = preview->numOfQuads*8;
+ preview->numOfQuads++;
+ } else {
+ efa->tmp.l = preview->numOfTris*6;
+ preview->numOfTris++;
+ }
+ }
+}
+
+
+/* Setup face preview for all coincident uvs and their faces */
static void stitch_setup_face_preview_for_uv_group(UvElement *element, StitchState *state, IslandStitchData *island_stitch_data){
StitchPreviewer *preview = uv_get_stitch_previewer();
+ if(state->snapIslands){
+ island_stitch_data[element->island].addedForPreview = 1;
+ }
+
do{
stitch_set_face_preview_buffer_position(element->face, preview);
- if(state->snapIslands){
- island_stitch_data[element->island].addedForPreview = 1;
- }
element = element->next;
- if(!element)
- break;
- }while(!element->separate);
-
+ }while(element && !element->separate);
}
/* registers uvs so that they can be shown in preview */
-static void stitch_setup_preview_for_uv_group(UvElement *element, StitchState *state, IslandStitchData *island_stitch_data){
+static void stitch_setup_preview_for_stitchable_uv(UvElement *element, StitchState *state, IslandStitchData *island_stitch_data){
StitchPreviewer *preview = uv_get_stitch_previewer();
UvElement *element_iter = state->elementMap->vert[(*(&element->face->v1 + element->tfindex))->tmp.l];
for(; element_iter; element_iter = element_iter->next){
- if(state->use_limit){
- MTFace *mtface_orig = CustomData_em_get(&state->em->fdata, element->face->data, CD_MTFACE);
- MTFace *mtface_iter = CustomData_em_get(&state->em->fdata, element_iter->face->data, CD_MTFACE);
+ if(element->separate){
+ if(state->use_limit){
+ MTFace *mtface_orig = CustomData_em_get(&state->em->fdata, element->face->data, CD_MTFACE);
+ MTFace *mtface_iter = CustomData_em_get(&state->em->fdata, element_iter->face->data, CD_MTFACE);
- if(fabs(mtface_orig->uv[element->tfindex][0] - mtface_iter->uv[element_iter->tfindex][0]) < state->limitDist
- && fabs(mtface_orig->uv[element->tfindex][1] - mtface_iter->uv[element_iter->tfindex][1]) < state->limitDist){
+ if(fabs(mtface_orig->uv[element->tfindex][0] - mtface_iter->uv[element_iter->tfindex][0]) < state->limitDist
+ && fabs(mtface_orig->uv[element->tfindex][1] - mtface_iter->uv[element_iter->tfindex][1]) < state->limitDist){
+
+ if(!(element_iter->flag & STITCH_STITCHABLE)){
+ element_iter->flag |= STITCH_STITCHABLE;
+ preview->numOfStitchable++;
+ stitch_setup_face_preview_for_uv_group(element_iter, state, island_stitch_data);
+ }
+ }
+ }else{
int uniqueIndex;
+ /* if no limit exists all uvs are stitchable */
stitch_set_face_preview_buffer_position(element_iter->face, preview);
uniqueIndex = state->map[element_iter - state->elementMap->buf];
- if(state->mode == VERT_STITCH && !(state->uvs[uniqueIndex]->flag & STITCH_STITCHABLE)){
- state->uvs[uniqueIndex]->flag |= STITCH_STITCHABLE;
- if(state->snapIslands){
- island_stitch_data[element_iter->island].addedForPreview = 1;
- }
+ if(!(element_iter->flag & STITCH_STITCHABLE)){
+ element_iter->flag |= STITCH_STITCHABLE;
preview->numOfStitchable++;
+ stitch_setup_face_preview_for_uv_group(element_iter, state, island_stitch_data);
}
}
- }else{
- int uniqueIndex;
- /* if no limit exists all uvs are stitchable */
- stitch_set_face_preview_buffer_position(element_iter->face, preview);
-
- uniqueIndex = state->map[element_iter - state->elementMap->buf];
-
- if(state->mode == VERT_STITCH && !(state->uvs[uniqueIndex]->flag & STITCH_STITCHABLE)){
- state->uvs[uniqueIndex]->flag |= STITCH_STITCHABLE;
- if(state->snapIslands){
- island_stitch_data[element_iter->island].addedForPreview = 1;
- }
- preview->numOfStitchable++;
- }
}
}
}
@@ -2324,36 +2280,29 @@
* First determine stitchability of uvs *
*****************************************/
if(state->mode == VERT_STITCH){
+ /* Uv Vert case */
for(i = 0; i < state->selection_size; i++){
UvElement *element = (UvElement *)state->selection_stack[i];
if(determine_uv_stitchability(element, state)){
- stitch_setup_preview_for_uv_group(element, state, island_stitch_data);
+ stitch_setup_preview_for_stitchable_uv(element, state, island_stitch_data);
}else{
/* Add to preview */
preview->numOfUnstitchable++;
}
}
}else{
+ /* Uv Edge case */
for(i = 0; i < state->selection_size; i++){
char stitchable1, stitchable2;
UvEdge *edge = (UvEdge *)state->selection_stack[i];
- UvElement *element1 = state->uvs[edge->uv1];
- UvElement *element2 = state->uvs[edge->uv2];
- stitchable1 = determine_uv_stitchability(element1, state);
- stitchable2 = determine_uv_stitchability(element2, state);
+ if(edge->flag & STITCH_BOUNDARY){
+ UvElement *element1 = state->uvs[edge->uv1];
+ UvElement *element2 = state->uvs[edge->uv2];
- if(stitchable1 || stitchable2){
- /* Update only uv face preview that need to be updated */
- if(stitchable1){
- stitch_setup_preview_for_uv_group(element1, state, island_stitch_data);
- }
- if(stitchable2){
- stitch_setup_preview_for_uv_group(element2, state, island_stitch_data);
- }
- if(state->snapIslands){
- island_stitch_data[element1->island].addedForPreview = 1;
- }
+ stitch_setup_face_preview_for_uv_group(element1, state, island_stitch_data);
+ stitch_setup_face_preview_for_uv_group(element2, state, island_stitch_data);
+
edge->flag |= STITCH_STITCHABLE;
preview->numOfStitchable++;
}else{
@@ -2362,6 +2311,8 @@
}
}
}
+
+ printf("st %d, ust %d\n",preview->numOfStitchable, preview->numOfUnstitchable);
/*****************************************
* Setup preview for stitchable islands *
*****************************************/
@@ -2413,8 +2364,8 @@
}
}
}
+ /* Fill the appropriate preview buffers */
if(state->mode == VERT_STITCH){
- /* Fill the preview buffers with stitchable only uvs */
for(i = 0; i < state->total_separate_uvs; i++){
UvElement *element = (UvElement *)state->uvs[i];
if(element->flag & STITCH_STITCHABLE){
@@ -2436,29 +2387,69 @@
unstitchBufferIndex++;
}
}
+ }else{
+ /* Fill the preview buffers with stitchable only uvs */
+ for(i = 0; i < state->total_edges; i++){
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list