[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40272] branches/soc-2011-onion-uv-tools/ source/blender/editors/uvedit/uvedit_ops.c: Vertex stitching simple + limited now functional.
Antony Riakiotakis
kalast at gmail.com
Fri Sep 16 21:21:26 CEST 2011
Revision: 40272
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40272
Author: psy-fi
Date: 2011-09-16 19:21:25 +0000 (Fri, 16 Sep 2011)
Log Message:
-----------
Vertex stitching simple + limited now functional. Island stitching not yet implemented.
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-09-16 18:23:57 UTC (rev 40271)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c 2011-09-16 19:21:25 UTC (rev 40272)
@@ -1496,8 +1496,8 @@
}
}
-#ifndef STITCHNEW
+
static void stitch_island_calculate_rotation(UvElement *element, int i, StitchState *state, UVVertAverage *uv_average, IslandStitchData *island_stitch_data)
{
EditFace *efa;
@@ -1541,7 +1541,7 @@
island_stitch_data[element->island].medianPoint[1] += (mt->uv[(element->tfindex + 1)%nverts][1] + mt->uv[element->tfindex][1]) / 2.0;
}
-
+#ifndef STITCHNEW
/* This function prepares the data of the previewer for display */
static int stitch_process_data(StitchState *state, int final, Scene *scene, int doIndexInit)
{
@@ -2234,7 +2234,7 @@
}
}else{
int uniqueIndex;
- /* if no limit exists, then the mere existence of a separate uv means that the uv is stitchable */
+ /* 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->uvs[uniqueIndex]->flag & STITCH_STITCHABLE)){
@@ -2282,7 +2282,9 @@
}
}
- /* First determine stitchability of uvs */
+ /*****************************************
+ * First determine stitchability of uvs *
+ *****************************************/
if(state->mode == VERT_STITCH){
for(i = 0; i < state->selection_size; i++){
UvElement *element = (UvElement *)state->selection_stack[i];
@@ -2295,7 +2297,10 @@
}
}
-
+ /*********************************************************
+ * And final display, here we either update the preview *
+ * or flush the result to the MTFace structures *
+ *********************************************************/
if(!final){
int stitchBufferIndex = 0, unstitchBufferIndex = 0;
/* Initialize the preview buffers */
@@ -2339,8 +2344,6 @@
} else {
memcpy(preview->previewTris+efa->tmp.l, &mt->uv[0][0], 6*sizeof(float));
}
- /* avoids re-copying */
- efa->tmp.l = -1;
}
}
}
@@ -2353,12 +2356,68 @@
preview->previewUnstitchable[unstitchBufferIndex*2 + 1] = mt->uv[element->tfindex][1];
unstitchBufferIndex++;
}
- /* keep only the selection flag */
- element->flag &= STITCH_SELECTED;
}
}
}
+ /******************************************************
+ * Here we calculate the final coordinates of the uvs *
+ ******************************************************/
+ if(state->mode == VERT_STITCH){
+ for(i = 0; i < state->selection_size; i++){
+ float uv_sum[2] = {0.0, 0.0};
+ short count = 0;
+ char stitchable = 0;
+ UvElement *element = (UvElement *)state->selection_stack[i];
+ if(element->flag & STITCH_STITCHABLE){
+ /* First pass, calculate final position for each uv */
+ 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){
+ MTFace *mt;
+ efa = element_iter->face;
+ mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+
+ uv_sum[0] += mt->uv[element_iter->tfindex][0];
+ uv_sum[1] += mt->uv[element_iter->tfindex][1];
+ count++;
+ }
+ }
+ /* median result */
+ uv_sum[0] /= count;
+ uv_sum[1] /= count;
+
+ /* Second pass, delegate changes to stitchable uvs */
+ element_iter = state->elementMap->vert[(*(&element->face->v1 + element->tfindex))->tmp.l];
+ for(;element_iter; element_iter = element_iter->next){
+ if(element_iter->separate){
+ if(element_iter->flag & STITCH_STITCHABLE){
+ stitchable = 1;
+ } else {
+ stitchable = 0;
+ }
+ }
+
+ if(stitchable){
+ efa = element_iter->face;
+ if(final){
+ MTFace *mt;
+ mt = CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
+
+ mt->uv[element_iter->tfindex][0] = uv_sum[0];
+ mt->uv[element_iter->tfindex][1] = uv_sum[1];
+ }else {
+ *(preview->previewQuads+efa->tmp.l + element_iter->tfindex*2) = uv_sum[0];
+ *(preview->previewQuads+efa->tmp.l + element_iter->tfindex*2 + 1) = uv_sum[1];
+ }
+ }
+ /* end of calculations, keep only the selection flag */
+ element_iter->flag &= STITCH_SELECTED;
+ }
+ }
+ }
+ }
+
if(island_stitch_data)
MEM_freeN(island_stitch_data);
@@ -2547,7 +2606,8 @@
return OPERATOR_CANCELLED;
case LEFTMOUSE:
- case PADENTER:{
+ case PADENTER:
+ case RETKEY:{
int returnValue;
returnValue = stitch_process_data(stitch_state, 1, scene, 1);
stitch_exit(C, op);
More information about the Bf-blender-cvs
mailing list