Revision: 38469
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38469
Author:   shuvro
Date:     2011-07-18 06:43:50 +0000 (Mon, 18 Jul 2011)
Log Message:
-----------
Seams will be generated only on the selected faces. If no face of the mesh is 
selected, a warning will be displayed to the user.

Modified Paths:
--------------
    
branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c

Modified: 
branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c
===================================================================
--- 
branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c  
    2011-07-18 05:41:46 UTC (rev 38468)
+++ 
branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c  
    2011-07-18 06:43:50 UTC (rev 38469)
@@ -55,7 +55,7 @@
 #include "BKE_report.h"
 #include "BKE_tessmesh.h"
 #include "BKE_main.h"
-
+#include "BKE_report.h"
 #include "ED_screen.h"
 #include "ED_uvedit.h"
 #include "MEM_guardedalloc.h"
@@ -130,10 +130,11 @@
        BMFace *face;
        BMIter face_iter;
        
+    
        int i=0;
        for(face = BMIter_New(&face_iter, bm, BM_FACES_OF_MESH, NULL); face; 
face= BMIter_Step(&face_iter))
        {
-               BM_SetIndex(face,i++);
+        BM_SetIndex(face,i++);
        }
 }
 
@@ -163,40 +164,44 @@
                        
                        BM_ITER(loop, &face_iter, bm, BM_LOOPS_OF_EDGE, edge) {
                                
-                               if(!combinatorial){
-                                       autoseam_set_adjacent(adj, 
loop->f->head.index, loop->radial_next->f->head.index, 1.0);
-                                       min_value = 1.0;
-                               }
-                               else{
-                                       float dx, dy, dz;
-                                       BM_Compute_Face_Center(bm, loop->f, 
poly_centres[0]);
-                                       BM_Compute_Face_Center(bm, 
loop->radial_next->f, poly_centres[1]);
+                /* Only create adjacency matrix for the selected faces */
+                if (BM_TestHFlag(loop->f, BM_SELECT) && 
BM_TestHFlag(loop->radial_next->f, BM_SELECT)){ 
+                    if(!combinatorial){
+                        autoseam_set_adjacent(adj, loop->f->head.index, 
loop->radial_next->f->head.index, 1.0);
+                        min_value = 1.0;
+                    }
+                    else{
+                        float dx, dy, dz;
+                        BM_Compute_Face_Center(bm, loop->f, poly_centres[0]);
+                        BM_Compute_Face_Center(bm, loop->radial_next->f, 
poly_centres[1]);
                                        
-                                       dx = poly_centres[0][0] - 
poly_centres[1][0];
-                                       dy = poly_centres[0][1] - 
poly_centres[1][1];
-                                       dz = poly_centres[0][2] - 
poly_centres[1][2];
-                                       edge_length = sqrt(dx*dx + dy*dy + 
dz*dz);
+                        dx = poly_centres[0][0] - poly_centres[1][0];
+                        dy = poly_centres[0][1] - poly_centres[1][1];
+                        dz = poly_centres[0][2] - poly_centres[1][2];
+                        edge_length = sqrt(dx*dx + dy*dy + dz*dz);
                                        
-                                       if(num_faces != -1){
-                                               int is_first_index = 
find_element_in_array(loop->f->head.index, faces, num_faces);
+                        if(num_faces != -1){
+                            int is_first_index = 
find_element_in_array(loop->f->head.index, faces, num_faces);
                                                
-                                               if(is_first_index >= 0){
-                                                       int is_second_index = 
find_element_in_array(loop->radial_next->f->head.index, faces, num_faces);
+                            if(is_first_index >= 0){
+                                int is_second_index = 
find_element_in_array(loop->radial_next->f->head.index, faces, num_faces);
                                                        
-                                                       if(is_second_index >= 
0){
+                                if(is_second_index >= 0){
                                                                
-                                                               
autoseam_set_adjacent(adj, loop->f->head.index, 
loop->radial_next->f->head.index, edge_length);
-                                                               if(edge_length 
< min_value) min_value = edge_length;
+                                    autoseam_set_adjacent(adj, 
loop->f->head.index, loop->radial_next->f->head.index, edge_length);
+                                    if(edge_length < min_value) min_value = 
edge_length;
 
-                                                       }
-                                               }
+                                }
+                            }
                                                
-                                       }
-                                       else{
-                                               autoseam_set_adjacent(adj, 
loop->f->head.index, loop->radial_next->f->head.index, edge_length);
-                                               if(edge_length < min_value) 
min_value = edge_length;
-                                       }
-                               }
+                        }
+                        else{
+                            autoseam_set_adjacent(adj, loop->f->head.index, 
loop->radial_next->f->head.index, edge_length);
+                            if(edge_length < min_value) min_value = 
edge_length;
+                        }
+                    }
+                    
+                }
 
                        }
                }
@@ -547,6 +552,10 @@
        BMEditMesh *em= ((Mesh *)obedit->data)->edit_btmesh;
        BMesh *bm = em->bm;
        
+    if(!(bm->totfacesel)) {
+               BKE_report(op->reports, RPT_WARNING, "No selected face found.");
+               return OPERATOR_CANCELLED;
+       }
        me->drawflag |= ME_DRAWSEAMS;
        num_faces = BM_Count_Element(bm, BM_FACE);
        

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

Reply via email to