Revision: 37963
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37963
Author:   psy-fi
Date:     2011-06-29 20:22:14 +0000 (Wed, 29 Jun 2011)
Log Message:
-----------
smart stitch (edge mode) - edge selection + disable stuff to move elsewhere

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-06-29 19:49:11 UTC (rev 37962)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c  
2011-06-29 20:22:14 UTC (rev 37963)
@@ -1138,8 +1138,6 @@
        EditMesh *em;
        /* vertmap, contains vertices sharing uv's in linked lists. */
        UvVertMap2 *vmap;
-       /* gHash with operand edges */
-       GHash *edges;
 } StitchState;
 
 /*
@@ -1422,24 +1420,23 @@
                MEM_freeN(commonVertMaps);
 
        /* Edge stitching case */
-       } else {
+       }
+       if(0){
 
-               /* Here we store the indices corresponding to UvMapVerts that 
contain the first vertex of the edge.*/
+               // Here we store the indices corresponding to UvMapVerts that 
contain the first vertex of the edge.*/
                int *faceStack = 
MEM_mallocN(state->em->totface*sizeof(float)*8, "quad_uv_stitch_prev");
-               GHashIterator* edgeIterator = 
BLI_ghashIterator_new(state->edges);
 
-               for(; !BLI_ghashIterator_isDone(edgeIterator); 
BLI_ghashIterator_step(edgeIterator)){
-                       /* simple check to see which of the two face vertices 
corresponds to the original */
+               for(; 0;){
+                       // simple check to see which of the two face vertices 
corresponds to the original */
                        char vertCheck = 0;
                        EditVert *v1, *v2;
                        UvElement *element;
                        int stackSize = 0;
-                       editEdge = BLI_ghashIterator_getKey(edgeIterator);
 
                        v1 = editEdge->v1;
                        v2 = editEdge->v2;
 
-                       /* search for faces with the corresponding UV's and 
check if they comply with stitchability restrictions */
+                       // search for faces with the corresponding UV's and 
check if they comply with stitchability restrictions */
                        for(element = vmap->vert[v1->tmp.l]; element; element = 
element->next){
                                int nverts;
                                efa = element->face;
@@ -1450,7 +1447,7 @@
                                }
                        }
 
-                       /* Check if faces found comply with stitchability 
restrictions */
+                       // Check if faces found comply with stitchability 
restrictions */
                        for(i = 0; i < stackSize; i++)
                        {
                                int faceIter;
@@ -1461,15 +1458,15 @@
                                nverts = (editFace->v4)? 4 : 3;
                                mt = CustomData_em_get(&state->em->fdata, 
editFace->data, CD_MTFACE);
 
-                               /* Take uv's of first face */
+                               // Take uv's of first face */
                                uv1[0][0] = mt->uv[element->tfindex][0];
                                uv1[0][1] = mt->uv[element->tfindex][1];
                                uv1[1][0] = (element->flag & STITCH_EDGE_PLUS)? 
mt->uv[(element->tfindex + 1)%nverts][0] : mt->uv[(element->tfindex + nverts - 
1)%nverts][0];
                                uv1[1][1] = (element->flag & STITCH_EDGE_PLUS)? 
mt->uv[(element->tfindex + 1)%nverts][1] : mt->uv[(element->tfindex + nverts - 
1)%nverts][1];
 
-                               /* iterate through all of the rest faces and 
check if they are */
+                               // iterate through all of the rest faces and 
check if they are */
                                for(faceIter = i+1; faceIter < stackSize; 
faceIter++){
-                                       /* flags to check if vertices have 
passed the test */
+                                       // flags to check if vertices have 
passed the test */
                                        char v1pass = 0, v2pass = 0;
                                        float uv2[2][2];
                                        MTFace *tmptface;
@@ -1479,19 +1476,19 @@
 
                                        tmptface = 
CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
 
-                                       /* Take uv's of second face */
+                                       // Take uv's of second face */
                                        uv2[0][0] = 
tmptface->uv[mapVertIter->tfindex][0];
                                        uv2[0][1] = 
tmptface->uv[mapVertIter->tfindex][1];
                                        uv2[1][0] = (mapVertIter->flag & 
STITCH_EDGE_PLUS)? tmptface->uv[(mapVertIter->tfindex + 1)%nverts][0] : 
tmptface->uv[(mapVertIter->tfindex + nverts - 1)%nverts][0];
                                        uv2[1][1] = (mapVertIter->flag & 
STITCH_EDGE_PLUS)? tmptface->uv[(mapVertIter->tfindex + 1)%nverts][1] : 
tmptface->uv[(mapVertIter->tfindex + nverts - 1)%nverts][1];
 
-                                       /* Actual checks */
+                                       // Actual checks */
                                        if(fabs((uv1[0][0] - uv2[0][0]) < 
STD_UV_CONNECT_LIMIT) &&
                                                (fabs(uv1[0][1] - uv2[0][1]) < 
STD_UV_CONNECT_LIMIT) &&
                                                fabs((uv1[1][0] - uv2[1][0]) < 
STD_UV_CONNECT_LIMIT) &&
                                                (fabs(uv1[1][1] - uv2[1][1]) < 
STD_UV_CONNECT_LIMIT))
                                        {
-                                               /* Coincident UV's so 
non-stitchable edge. */
+                                               // Coincident UV's so 
non-stitchable edge. */
                                                continue;
                                        }
                                        else if(state->use_limit && ( 
fabs(uv1[0][0] - uv2[0][0]) > state->limitDist ||
@@ -1499,17 +1496,15 @@
                                                fabs(uv1[1][0] - uv2[1][0]) > 
state->limitDist ||
                                                fabs(uv1[1][1] - uv2[1][1]) > 
state->limitDist))
                                        {
-                                               /* Both UVs out of stitch range 
*/
+                                               // Both UVs out of stitch range 
*/
                                                continue;
                                        }
                                        else {
-                                               /* Stitchable case, do the 
necessary stuff */
+                                               // Stitchable case, do the 
necessary stuff */
                                        }
                                }
                        }
                }
-
-               BLI_ghashIterator_free(edgeIterator);
        }
 
        if(!final)
@@ -1617,7 +1612,6 @@
        stitch_state->limitDist = RNA_float_get(op->ptr, "limit");
        stitch_state->em = em = BKE_mesh_get_editmesh((Mesh*)obedit->data);
        stitch_state->mode = VERT_STITCH;
-       stitch_state->edges = BLI_ghash_new(BLI_ghashutil_ptrhash, 
BLI_ghashutil_ptrcmp, "stitch edge selection hash");
 
        stitch_state->vmap = EM_make_uv_vert_map2(stitch_state->em, 1, limit);
 
@@ -1662,7 +1656,6 @@
        /* remember to set vertices used for redo operator in an RNA array or 
something */
 
        EM_free_uv_vert_map2(stitch_state->vmap);
-       BLI_ghash_free(stitch_state->edges, NULL, NULL);
 
        BKE_mesh_end_editmesh(obedit->data, stitch_state->em);
 
@@ -1803,10 +1796,48 @@
                                        }
                                        else
                                        {
-                                               //UvElement *element = 
EM_get_uv_map_vert_for_edge(stitch_state->vmap, stitch_state->em, edge, 0);
-                                               //if(element && 
!BLI_ghash_haskey(stitch_state->edges,element)){
-                                               //      
BLI_ghash_insert(stitch_state->edges, element, NULL);
-                                               //}
+                                               /* same as above but for two 
verts. Maybe make a function for this after implementation is concrete */
+                                               UvElement *element = 
stitch_state->vmap->vert[hit.vert];
+                                               UvElement *element2 = 
stitch_state->vmap->vert[hit.vert2];
+
+                                               UvElement *firstCoincident;
+                                               for(; element; element = 
element->next)
+                                               {
+                                                       if(element->separate)
+                                                               firstCoincident 
= element;
+                                                       if(element->face == 
hit.efa){
+                                                               for(element = 
firstCoincident; element; element = element->next){
+                                                                       MTFace 
*tface;
+                                                                       
if(element->separate && element != firstCoincident)
+                                                                               
break;
+                                                                       tface = 
 CustomData_em_get(&stitch_state->em->fdata, element->face->data, CD_MTFACE);
+                                                                       
if(event->ctrl)
+                                                                               
uvedit_uv_deselect(scene, element->face, tface, element->tfindex);
+                                                                       else
+                                                                               
uvedit_uv_select(scene, element->face, tface, element->tfindex);
+                                                               }
+                                                               break;
+                                                       }
+                                               }
+
+                                               for(; element2; element2 = 
element2->next)
+                                               {
+                                                       if(element2->separate)
+                                                               firstCoincident 
= element2;
+                                                       if(element2->face == 
hit.efa){
+                                                               for(element2 = 
firstCoincident; element2; element2 = element2->next){
+                                                                       MTFace 
*tface;
+                                                                       
if(element2->separate && element2 != firstCoincident)
+                                                                               
break;
+                                                                       tface = 
 CustomData_em_get(&stitch_state->em->fdata, element2->face->data, CD_MTFACE);
+                                                                       
if(event->ctrl)
+                                                                               
uvedit_uv_deselect(scene, element2->face, tface, element2->tfindex);
+                                                                       else
+                                                                               
uvedit_uv_select(scene, element2->face, tface, element2->tfindex);
+                                                               }
+                                                               break;
+                                                       }
+                                               }
                                        }
                                }
                                stitch_process_data(stitch_state, 0, scene, 0);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to