transfer weight's now operates on selected vertices (when vertex select is enabled).
authorCampbell Barton <ideasman42@gmail.com>
Tue, 9 Oct 2012 22:55:05 +0000 (22:55 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 9 Oct 2012 22:55:05 +0000 (22:55 +0000)
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/editors/object/object_vgroup.c
source/blender/editors/uvedit/uvedit_smart_stitch.c

index d5648a6d3a23f8f98b50b69f3092b87fa6ca8984..606b14d4221272c7485bb11631b7a2f116648339 100644 (file)
@@ -1247,6 +1247,7 @@ class VIEW3D_MT_paint_weight(Menu):
         layout.operator("object.vertex_group_clean", text="Clean")
         layout.operator("object.vertex_group_levels", text="Levels")
         layout.operator("object.vertex_group_blend", text="Blend")
+        layout.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
         layout.operator("object.vertex_group_limit_total", text="Limit Total")
         layout.operator("object.vertex_group_fix", text="Fix Deforms")
 
index b0b8401fe026513c8f93be2f7facbd0d324e3a09..d162a97d32c30dca664a877f7a8a34337c9973c2 100644 (file)
@@ -967,7 +967,7 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
         col.operator("object.vertex_group_clean", text="Clean")
         col.operator("object.vertex_group_levels", text="Levels")
         col.operator("object.vertex_group_blend", text="Blend")
-        col.operator("object.vertex_group_transfer_weight", text="Transfer weight")
+        col.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
         col.operator("object.vertex_group_limit_total", text="Limit Total")
         col.operator("object.vertex_group_fix", text="Fix Deforms")
 
index dea7eb984ad40bb825e3bc2cdc00fe745340b461..ab9a4cb07ecf02b116dd90274efa0f730eb04b2d 100644 (file)
@@ -406,7 +406,6 @@ typedef enum WT_Method {
 typedef enum WT_ReplaceMode {
        WT_REPLACE_ALL_WEIGHTS = 1,
        WT_REPLACE_EMPTY_WEIGHTS = 2,
-       WT_REPLACE_SELECTED_WEIGHTS = 3
 } WT_ReplaceMode;
 
 static EnumPropertyItem WT_vertex_group_mode_item[] = {
@@ -426,25 +425,21 @@ static EnumPropertyItem WT_method_item[] = {
 static EnumPropertyItem WT_replace_mode_item[] = {
     {WT_REPLACE_ALL_WEIGHTS, "WT_REPLACE_ALL_WEIGHTS", 1, "All", "Overwrites all weights."},
     {WT_REPLACE_EMPTY_WEIGHTS, "WT_REPLACE_EMPTY_WEIGHTS", 1, "Empty", "Adds weights to vertices with no weight."},
-    {WT_REPLACE_SELECTED_WEIGHTS, "WT_REPLACE_SELECTED_WEIGHTS", 1, "Selected", "Replace selected weights."},
     {0, NULL, 0, NULL, NULL}
 };
 
 /*copy weight*/
-static void vgroup_transfer_weight(MVert *mv_dst, float *weight_dst, float weight_src, WT_ReplaceMode replace_mode)
+static void vgroup_transfer_weight(float *r_weight_dst, const float weight_src, const WT_ReplaceMode replace_mode)
 {
        switch (replace_mode) {
-
                case WT_REPLACE_ALL_WEIGHTS:
-                       *weight_dst = weight_src;
+                       *r_weight_dst = weight_src;
                        break;
 
                case WT_REPLACE_EMPTY_WEIGHTS:
-                       if (*weight_dst == 0) *weight_dst = weight_src;
-                       break;
-
-               case WT_REPLACE_SELECTED_WEIGHTS:
-                       if (mv_dst->flag & SELECT) *weight_dst = weight_src;
+                       if (*r_weight_dst == 0.0f) {
+                               *r_weight_dst = weight_src;
+                       }
                        break;
 
                default:
@@ -469,9 +464,10 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou
        int dv_tot_src, dv_tot_dst, i, v_index, index_dst, index_src, index_nearest, index_nearest_vertex;
        unsigned int f_index;
        float weight, tmp_weight[4], tmp_co[3], normal[3], tmp_mat[4][4], dist_v1, dist_v2, dist_v3, dist_v4;
+       const int use_vert_sel = vertex_group_use_vert_sel(ob_dst);
 
        /* create new and overwrite vertex group on destination without data */
-       if (!defgroup_find_name(ob_dst, dg_src->name) || replace_mode == WT_REPLACE_ALL_WEIGHTS) {
+       if (!defgroup_find_name(ob_dst, dg_src->name)) {
                ED_vgroup_delete(ob_dst, defgroup_find_name(ob_dst, dg_src->name));
                ED_vgroup_add_name(ob_dst, dg_src->name);
        }
@@ -495,7 +491,7 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou
 
        /* get vertex group arrays */
        ED_vgroup_give_parray(ob_src->data, &dv_array_src, &dv_tot_src, FALSE);
-       ED_vgroup_give_parray(ob_dst->data, &dv_array_dst, &dv_tot_dst, FALSE);
+       ED_vgroup_give_parray(ob_dst->data, &dv_array_dst, &dv_tot_dst, use_vert_sel);
 
        /* get indexes of vertex groups */
        index_src = BLI_findindex(&ob_src->defbase, dg_src);
@@ -512,6 +508,11 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou
        /* clear weights */
        if (replace_mode == WT_REPLACE_ALL_WEIGHTS) {
                for(i = 0, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++) {
+
+                       if (*dv_dst == NULL) {
+                               continue;
+                       }
+
                        dw_dst = defvert_verify_index(*dv_dst, index_dst);
                        if (dw_dst) (*dw_dst).weight = 0;
                }
@@ -533,13 +534,17 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou
                        }
 
                        /* loop through the vertices*/
-                       for(i = 0, dv_src = dv_array_src, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++, dv_src++, mv_src++) {
+                       for(i = 0, dv_src = dv_array_src, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++, dv_src++, mv_src++, mv_dst++) {
+
+                               if (*dv_dst == NULL) {
+                                       continue;
+                               }
 
                                /* copy weight */
                                dw_src = defvert_find_index(*dv_src, index_src);
                                if (dw_src && dw_src->weight) {
                                        dw_dst = defvert_verify_index(*dv_dst, index_dst);
-                                       vgroup_transfer_weight(mv_dst, &dw_dst->weight, dw_src->weight, replace_mode);
+                                       vgroup_transfer_weight(&dw_dst->weight, dw_src->weight, replace_mode);
                                }
                        }
                        break;
@@ -551,6 +556,10 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou
                        /* loop trough vertices */
                        for(i = 0, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++, mv_dst++){
 
+                               if (*dv_dst == NULL) {
+                                       continue;
+                               }
+
                                /* reset nearest */
                                nearest.dist = FLT_MAX;
                                /* With current binary tree its marginally faster to start searching at the top, as opposed to previous search. */
@@ -567,7 +576,7 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou
                                dw_src = defvert_find_index(dv_array_src[nearest.index], index_src);
                                if (dw_src && dw_src->weight) {
                                        dw_dst = defvert_verify_index(*dv_dst, index_dst);
-                                       vgroup_transfer_weight(mv_dst, &dw_dst->weight, dw_src->weight, replace_mode);
+                                       vgroup_transfer_weight(&dw_dst->weight, dw_src->weight, replace_mode);
                                }
                        }
 
@@ -586,6 +595,10 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou
                        /* loop through the vertices */
                        for(i = 0, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++, mv_dst++) {
 
+                               if (*dv_dst == NULL) {
+                                       continue;
+                               }
+
                                /* reset nearest */
                                nearest.dist = FLT_MAX;
                                /* With current binary tree its marginally faster to start searching at the top, as opposed to previous search. */
@@ -623,7 +636,7 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou
                                /* copy weight that are not NULL including weight value 0. Existing target weights are overwritten prior to this in relevant cases. */
                                if (weight > 0) {
                                        dw_dst = defvert_verify_index(*dv_dst, index_dst);
-                                       vgroup_transfer_weight(mv_dst, &dw_dst->weight, weight, replace_mode);
+                                       vgroup_transfer_weight(&dw_dst->weight, weight, replace_mode);
                                }
                        }
 
@@ -642,6 +655,10 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou
                        /* loop through the vertices */
                        for(i = 0, dv_dst = dv_array_dst; i < me_dst->totvert; i++, dv_dst++, mv_dst++){
 
+                               if (*dv_dst == NULL) {
+                                       continue;
+                               }
+
                                /* reset nearest */
                                nearest.dist = FLT_MAX;
                                /* With current binary tree its marginally faster to start searching at the top, as opposed to previous search. */
@@ -677,7 +694,7 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou
                                dw_src = defvert_find_index(dv_array_src[index_nearest_vertex], index_src);
                                if (dw_src && dw_src->weight) {
                                        dw_dst = defvert_verify_index(*dv_dst, index_dst);
-                                       vgroup_transfer_weight(mv_dst, &dw_dst->weight, dw_src->weight, replace_mode);
+                                       vgroup_transfer_weight(&dw_dst->weight, dw_src->weight, replace_mode);
                                }
                        }
 
@@ -3316,7 +3333,7 @@ static int vertex_group_transfer_weight_exec(bContext *C, wmOperator *op)
 void OBJECT_OT_vertex_group_transfer_weight(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name = "Transfer weight";
+       ot->name = "Transfer Weights";
        ot->idname = "OBJECT_OT_vertex_group_transfer_weight";
        ot->description = "Transfer weight paint to active from selected mesh";
 
index 49439b8daa5e2bcff3d742190d3926a6e4075620..2b225118472d41b0906b66543f77f386160b970a 100644 (file)
@@ -1007,7 +1007,7 @@ static void stitch_calculate_edge_normal(BMEditMesh *em, UvEdge *edge, float *no
        normalize_v2(normal);
 }
 
-static void stitch_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
+static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *UNUSED(arg))
 {
        int i, index = 0;
        float pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE);