mirror modifier vgroup option was doing string name conversion to find the flipped...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 16 Jan 2010 01:15:47 +0000 (01:15 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 16 Jan 2010 01:15:47 +0000 (01:15 +0000)
the vertex flip mapping only needs to be made once.

warning fixes too.

source/blender/blenkernel/intern/modifier.c
source/blender/editors/space_console/console_ops.c
source/blender/makesrna/intern/rna_wm_api.c

index 3c925e5ff25f3eafa3f481a3829f66dc9d7c8e35..830c484b8413e6d4e5631414ae4cc23dae4380c4 100644 (file)
@@ -1813,9 +1813,8 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
        int maxVerts = dm->getNumVerts(dm);
        int maxEdges = dm->getNumEdges(dm);
        int maxFaces = dm->getNumFaces(dm);
-       int vector_size=0, j, a, b;
-       bDeformGroup *def, *defb;
-       bDeformGroup **vector_def = NULL;
+       int *flip_map;
+       int do_vgroup_mirr= (mmd->flag & MOD_MIR_VGROUP);
        int (*indexMap)[2];
        float mtx[4][4], imtx[4][4];
 
@@ -1826,18 +1825,10 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
        result = CDDM_from_template(dm, maxVerts * 2, maxEdges * 2, maxFaces * 2);
 
 
-       if (mmd->flag & MOD_MIR_VGROUP) {
-               /* calculate the number of deformedGroups */
-               for(vector_size = 0, def = ob->defbase.first; def;
-                   def = def->next, vector_size++);
-
-               /* load the deformedGroups for fast access */
-               vector_def =
-                   (bDeformGroup **)MEM_mallocN(sizeof(bDeformGroup*) * vector_size,
-                                                "group_index");
-               for(a = 0, def = ob->defbase.first; def; def = def->next, a++) {
-                       vector_def[a] = def;
-               }
+       if (do_vgroup_mirr) {
+               flip_map= get_defgroup_flip_map(ob);
+               if(flip_map == NULL)
+                       do_vgroup_mirr= 0;
        }
 
        if (mmd->mirror_ob) {
@@ -1884,7 +1875,6 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
                        mv->flag |= ME_VERT_MERGED;
                } else {
                        MVert *mv2 = CDDM_get_vert(result, numVerts);
-                       MDeformVert *dvert = NULL;
                        
                        DM_copy_vert_data(dm, result, i, numVerts, 1);
                        *mv2 = *mv;
@@ -1895,35 +1885,13 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
                        }
                        copy_v3_v3(mv2->co, co);
                        
-                       if (mmd->flag & MOD_MIR_VGROUP){
-                               dvert = DM_get_vert_data(result, numVerts, CD_MDEFORMVERT);
-                               
-                               if (dvert)
-                               {
-                                       for(j = 0; j < dvert[0].totweight; ++j)
-                                       {
-                                               char tmpname[32];
-                                               
-                                               if(dvert->dw[j].def_nr < 0 ||
-                                                  dvert->dw[j].def_nr >= vector_size)
-                                                       continue;
-                                               
-                                               def = vector_def[dvert->dw[j].def_nr];
-                                               flip_vertexgroup_name(tmpname, def->name, 0);
-                                               
-                                               for(b = 0, defb = ob->defbase.first; defb;
-                                                   defb = defb->next, b++)
-                                               {
-                                                       if(!strcmp(defb->name, tmpname))
-                                                       {
-                                                               dvert->dw[j].def_nr = b;
-                                                               break;
-                                                       }
-                                               }
-                                       }
+                       if (do_vgroup_mirr) {
+                               MDeformVert *dvert= DM_get_vert_data(result, numVerts, CD_MDEFORMVERT);
+                               if(dvert) {
+                                       flip_defvert(dvert, flip_map);
                                }
                        }
-                       
+
                        numVerts++;
                }
        }
@@ -2008,7 +1976,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
                }
        }
 
-       if (vector_def) MEM_freeN(vector_def);
+       if (flip_map) MEM_freeN(flip_map);
 
        MEM_freeN(indexMap);
 
index 76e1231b0d495ac70f3ff8b119a2b8db45aa3409..969918392c973d7a999d17bedf034ede3fbbacc1 100644 (file)
@@ -279,12 +279,12 @@ static int console_edit_poll(bContext *C)
 
        return 1;
 }
-
+#if 0
 static int console_poll(bContext *C)
 {
        return (CTX_wm_space_console(C) != NULL);
 }
-
+#endif
 
 /* static funcs for text editing */
 
index c69e706e28ddffe119d0139eecc1e7bca0fdcd56..3fa646598d60e406b7af04dc11deeb1c224f325e 100644 (file)
@@ -145,9 +145,10 @@ static void rna_Operator_report(wmOperator *op, int type, char *msg)
 }
 
 /* since event isnt needed... */
-static int rna_Operator_enum_search_invoke(bContext *C, wmOperator *op)
+static void rna_Operator_enum_search_invoke(bContext *C, wmOperator *op)
 {
        WM_enum_search_invoke(C, op, NULL);
+       
 }
 
 #else
@@ -194,7 +195,7 @@ void RNA_api_wm(StructRNA *srna)
 
        /* invoke enum */
        func= RNA_def_function(srna, "invoke_search_popup", "rna_Operator_enum_search_invoke");
-       rna_generic_op_invoke(func, 0, 1);
+       rna_generic_op_invoke(func, 0, 0);
 
        /* invoke functions, for use with python */
        func= RNA_def_function(srna, "invoke_popup", "WM_operator_ui_popup");