Revision: 39536
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39536
Author:   shuvro
Date:     2011-08-18 20:35:37 +0000 (Thu, 18 Aug 2011)
Log Message:
-----------
Execute seam generation functions only when the parameters related to them are 
changed in the UI. Otherwise avoid this calculation and only execute the 
function related to unwrapping.

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

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-08-18 20:01:30 UTC (rev 39535)
+++ 
branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c  
    2011-08-18 20:35:37 UTC (rev 39536)
@@ -63,8 +63,10 @@
 #include "autoseam_C_API.h"
 #include "ED_mesh.h"
 
+#include "ED_util.h"
 
 
+
 #define INF 999999
 
 static float min_value = INF;
@@ -625,54 +627,67 @@
 
 static int generate_seam_exec(bContext *C, wmOperator *op)
 {
-       AUTOSEAM_Adjacency adj;
+       
        int maxdepth= RNA_int_get(op->ptr, "depth");
        int is_combinatorial = RNA_boolean_get(op->ptr, "is_combinatorial");
+       int stretch_algo   = RNA_enum_get(op->ptr, "stretch_type"); 
+       
        int method = RNA_enum_get(op->ptr, "method");
        int fill_holes = RNA_boolean_get(op->ptr, "fill_holes");
        int correct_aspect = RNA_boolean_get(op->ptr, "correct_aspect");
        int num_faces;
        int is_live_unwrap = RNA_boolean_get(op->ptr, "live_unwrap");
-       int stretch_algo   = RNA_enum_get(op->ptr, "stretch_type"); 
        
+       
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        Mesh *me= ((Mesh *)obedit->data);
        BMEditMesh *em= ((Mesh *)obedit->data)->edit_btmesh;
        BMesh *bm = em->bm;
        
-       //Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
-       //Mesh *me= ob->data;
+
        
-       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);
        
-       adj = autoseam_create_adjacency(num_faces);
+       if((scene->toolsettings->autoseam_data.recursion_depth != maxdepth) || 
(scene->toolsettings->autoseam_data.is_combinatorial != is_combinatorial) || 
(scene->toolsettings->autoseam_data.stretch_type != stretch_algo))
+       {
+               AUTOSEAM_Adjacency adj;
+               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);
+               
+               adj = autoseam_create_adjacency(num_faces);
+               
+               /* set initial indices, found out this is necessary, they get 
reset on operator redo */
+               autoseam_prepare_graph(bm);
+               
+               /* this creates the adjacency matrix */
+               autoseam_create_graph(adj, bm, is_combinatorial, -1, NULL);
+               
+               /* set the min value for adjcacency calculation. */
+               autoseam_set_min_value(adj, min_value);
+               
+               /* clear if any seam already exists. */
+               autoseam_clear_seam(bm);
+               autoseam_set_map_default(adj);
+               
+               ED_mesh_uv_texture_add(C, me, "stretch_layer", TRUE);
+               /* This function will call the recusive function for each of 
the components of bmesh*/
+               handle_separate_components(adj, num_faces, bm, maxdepth, C, 
stretch_algo);
+               // do_all_components(bm, maxdepth, C);
+               
+               ED_mesh_uv_texture_remove(C, obedit, me);
        
-       /* set initial indices, found out this is necessary, they get reset on 
operator redo */
-       autoseam_prepare_graph(bm);
+       }
        
-       /* this creates the adjacency matrix */
-       autoseam_create_graph(adj, bm, is_combinatorial, -1, NULL);
+       scene->toolsettings->autoseam_data.recursion_depth  = maxdepth;
+       scene->toolsettings->autoseam_data.is_combinatorial = is_combinatorial;
+       scene->toolsettings->autoseam_data.stretch_type     = stretch_algo;
 
-       /* set the min value for adjcacency calculation. */
-       autoseam_set_min_value(adj, min_value);
+
        
-       /* clear if any seam already exists. */
-       autoseam_clear_seam(bm);
-       autoseam_set_map_default(adj);
-       
-       ED_mesh_uv_texture_add(C, me, "stretch_layer", TRUE);
-       /* This function will call the recusive function for each of the 
components of bmesh*/
-       handle_separate_components(adj, num_faces, bm, maxdepth, C, 
stretch_algo);
-       // do_all_components(bm, maxdepth, C);
-       
-       ED_mesh_uv_texture_remove(C, obedit, me);
-       
        /* If live unwrapping enable, unwrap the seams after marking */
        if(is_live_unwrap){
                
@@ -704,6 +719,8 @@
        /*reset the min_value*/
        min_value = INF;
        
+       ED_undo_push_op(C, op);
+       
        /* operator management */
        DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
@@ -739,7 +756,7 @@
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        RNA_def_enum(ot->srna, "stretch_type", prop_stretch_algo_types, 1, 
"Stretch Type", "");
-       RNA_def_int(ot->srna, "depth", 3, 1, 6, "Recursion Depth", "Max. 
recursion depth", 0, 6);
+       RNA_def_int(ot->srna, "depth", 1, 1, 6, "Recursion Depth", "Max. 
recursion depth", 0, 6);
        RNA_def_boolean(ot->srna, "is_combinatorial", 0, "Combinatorial", 
"Consider actual face centers for calculation.");
        
        RNA_def_enum(ot->srna, "method", method_items, 0, "Unwrap Method", 
"Unwrapping method. Angle Based usually gives better results than Conformal, 
while being somewhat slower.");

Modified: 
branches/soc-2011-avocado/blender/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/soc-2011-avocado/blender/source/blender/makesdna/DNA_scene_types.h 
2011-08-18 20:01:30 UTC (rev 39535)
+++ branches/soc-2011-avocado/blender/source/blender/makesdna/DNA_scene_types.h 
2011-08-18 20:35:37 UTC (rev 39536)
@@ -601,7 +601,24 @@
        
        void *paintcursor;                                      /* wm handle */
 } VPaint;
+       
+typedef struct AutoseamData
+{
+               
+       int stretch_type;
+       int recursion_depth;
+       int is_combinatorial;
+       
+       int method;
+       int fill_holes;
+       int correct_aspect;
+       
+       int live_unwrap;
+       float margin;
 
+
+} AutoseamData;
+
 /* VPaint flag */
 #define VP_COLINDEX    1
 #define VP_AREA                2
@@ -617,6 +634,10 @@
        VPaint *wpaint;         /* weight paint */
        Sculpt *sculpt;
        
+       //Autoseam data storage
+       
+       AutoseamData autoseam_data;
+       
        /* Vertex groups */
        float vgroup_weight;
 
@@ -737,6 +758,7 @@
        float sculpt_paint_unified_alpha; /* unified strength of brush */
 } ToolSettings;
 
+
 typedef struct bStats {
        /* scene totals for visible layers */
        int totobj, totlamp, totobjsel, totcurve, totmesh, totarmature;

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

Reply via email to