[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38537] branches/soc-2011-onion/source/ blender/editors/uvedit/uvedit_ops.c: smart stitch commit #+infinity+-1
Antony Riakiotakis
kalast at gmail.com
Wed Jul 20 15:05:18 CEST 2011
Revision: 38537
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38537
Author: psy-fi
Date: 2011-07-20 13:05:18 +0000 (Wed, 20 Jul 2011)
Log Message:
-----------
smart stitch commit #+infinity+-1
============================
-Some reorganization of the code, looks like it solves processing order bug
-Added preview code for snapping,still crashing though, fixes to follow
Modified Paths:
--------------
branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c 2011-07-20 12:46:22 UTC (rev 38536)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c 2011-07-20 13:05:18 UTC (rev 38537)
@@ -1246,13 +1246,15 @@
struct IslandStitchData;
-/* This is a straightforward implementation, couunt the uv's in the island that will move and take the mean displacement and apply it to all
+/* This is a straightforward implementation, count the uv's in the island that will move and take the mean displacement/rotation and apply it to all
* elements of the island except from the stitchable */
typedef struct IslandStitchData{
/* rotation can be used only for edges, for vertices there is no such notion */
float rotation;
float translation;
int numOfElements;
+ /* Flag to remember if island has been aded for preview */
+ char addedForPreview;
}IslandStitchData;
@@ -1381,7 +1383,13 @@
if(element->flag & STITCH_STITCHABLE)
{
/* add original face to preview */
- stitch_update_face_preview_index(editFace, preview);
+ if(state->snapIslands){
+ //island_stitch_data[el_iter->island].numOfElements++;
+ island_stitch_data[element->island].addedForPreview = 1;
+ }
+ else {
+ stitch_update_face_preview_index(editFace, preview);
+ }
for(iter2 = 0; iter2 < iter; iter2++)
{
int averageIndex2;
@@ -1396,8 +1404,12 @@
uv_average[averageIndex2].count += uv_average[averageIndex].count;
uv_average[averageIndex2].uv[0] += uv_average[averageIndex].uv[0];
uv_average[averageIndex2].uv[1] += uv_average[averageIndex].uv[1];
-
- stitch_update_face_preview_index(efa, preview);
+ if(state->snapIslands){
+ island_stitch_data[el_iter->island].addedForPreview = 1;
+ }
+ else {
+ stitch_update_face_preview_index(efa, preview);
+ }
}
}
}
@@ -1532,6 +1544,16 @@
break;
commonVertMaps2[stackSize2++] = tmp_iter;
}
+ for(tmp_iter = el_sep1; tmp_iter; tmp_iter = tmp_iter->next){
+ if(tmp_iter->separate && tmp_iter != el_sep1)
+ break;
+ commonVertMaps[stackSize1++] = tmp_iter;
+ }
+ for(tmp_iter = el_sep2; tmp_iter; tmp_iter = tmp_iter->next){
+ if(tmp_iter->separate && tmp_iter != el_sep2)
+ break;
+ commonVertMaps2[stackSize2++] = tmp_iter;
+ }
if(vertCheck)
{
@@ -1555,32 +1577,7 @@
UvElement *tmp_iter;
int index_tmp;
- /* update coincident uv's with initial */
- for(tmp_iter = el_sep1; tmp_iter; tmp_iter = tmp_iter->next){
- if(tmp_iter->separate && tmp_iter != el_sep1)
- break;
- tmp_iter->flag |= STITCH_STITCHABLE;
- efa = tmp_iter->face;
- index_tmp = tmp_iter - vmap->buf;
- uv_average[index_tmp].count += uv_average_tmp[0].count;
- uv_average[index_tmp].uv[0] += uv_average_tmp[0].uv[0];
- uv_average[index_tmp].uv[1] += uv_average_tmp[0].uv[1];
-
- stitch_update_face_preview_index(efa, preview);
- }
- for(tmp_iter = el_sep2; tmp_iter; tmp_iter = tmp_iter->next){
- if(tmp_iter->separate && tmp_iter != el_sep2)
- break;
- efa = tmp_iter->face;
- tmp_iter->flag |= STITCH_STITCHABLE;
- index_tmp = tmp_iter - vmap->buf;
- uv_average[index_tmp].count += uv_average_tmp[1].count;
- uv_average[index_tmp].uv[0] += uv_average_tmp[1].uv[0];
- uv_average[index_tmp].uv[1] += uv_average_tmp[1].uv[1];
-
- stitch_update_face_preview_index(efa, preview);
- }
-
+ /* update uv's on the update stack */
for(stack_iter = 0; stack_iter < stackSize1; stack_iter++){
index1 = commonVertMaps[stack_iter] - vmap->buf,
efa = commonVertMaps[stack_iter]->face;
@@ -1591,7 +1588,12 @@
uv_average[index1].uv[0] += uv_average_tmp[0].uv[0];
uv_average[index1].uv[1] += uv_average_tmp[0].uv[1];
- stitch_update_face_preview_index(efa, preview);
+ if(state->snapIslands){
+ island_stitch_data[commonVertMaps[stack_iter]->island].addedForPreview = 1;
+ }
+ else {
+ stitch_update_face_preview_index(efa, preview);
+ }
}
for(stack_iter = 0; stack_iter < stackSize2; stack_iter++){
index2 = commonVertMaps2[stack_iter] - vmap->buf;
@@ -1602,8 +1604,12 @@
uv_average[index2].count += uv_average_tmp[1].count;
uv_average[index2].uv[0] += uv_average_tmp[1].uv[0];
uv_average[index2].uv[1] += uv_average_tmp[1].uv[1];
-
- stitch_update_face_preview_index(efa, preview);
+ if(state->snapIslands){
+ island_stitch_data[commonVertMaps[stack_iter]->island].addedForPreview = 1;
+ }
+ else {
+ stitch_update_face_preview_index(efa, preview);
+ }
}
}
MEM_freeN(commonVertMaps2);
@@ -1613,6 +1619,24 @@
}
}
+ if(state->snapIslands){
+ for(i = 0; i < state->vmap->numOfIslands; i++){
+ if(island_stitch_data[i].addedForPreview){
+ int previewIslandUVs = 0, j;
+ if(i == state->vmap->numOfIslands-1){
+ previewIslandUVs = state->vmap->numOfUVs - state->vmap->islandIndices[i];
+ }else{
+ previewIslandUVs = state->vmap->islandIndices[i+1] - state->vmap->islandIndices[i];
+ }
+
+ element = &state->vmap->buf[state->vmap->islandIndices[i]];
+ for(j = 0; j < previewIslandUVs; j++, element++){
+ stitch_update_face_preview_index(element->face, preview);
+ }
+ }
+ }
+ }
+
MEM_freeN(commonVertMaps);
More information about the Bf-blender-cvs
mailing list