Commit: bf6338c48184e528880e48043964ae7b4189ae57
Author: Darshan Kadu
Date:   Fri Jun 30 16:25:08 2017 +0530
Branches: soc-2017-vertex_paint
https://developer.blender.org/rBbf6338c48184e528880e48043964ae7b4189ae57

added the weight to paint converter as option in paint in verte xpainting and 
weight in weight painting

===================================================================

M       release/scripts/startup/bl_ui/space_view3d.py
M       source/blender/editors/sculpt_paint/paint_vertex.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 643a4b8cc00..42a6d3138a7 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1779,6 +1779,7 @@ class VIEW3D_MT_paint_vertex(Menu):
         layout.operator("paint.vertex_color_set")
         layout.operator("paint.vertex_color_smooth")
         layout.operator("paint.vertex_color_dirt")
+        layout.operator("paint.weight_to_vertex_convert")
 
         layout.separator()
 
@@ -1869,6 +1870,7 @@ class VIEW3D_MT_paint_weight(Menu):
         layout.separator()
 
         layout.operator("paint.weight_set")
+        layout.operator("paint.weight_to_vertex_convert")
 
 
 # ********** Sculpt menu **********
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c 
b/source/blender/editors/sculpt_paint/paint_vertex.c
index 25ffd312ced..24ef4fd6315 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -124,6 +124,13 @@ int vertex_paint_mode_poll(bContext *C)
        return ob && ob->mode == OB_MODE_VERTEX_PAINT && ((Mesh 
*)ob->data)->totpoly;
 }
 
+int vertex_weight_paint_mode_poll(bContext *C)
+{
+       Object *ob = CTX_data_active_object(C);
+
+       return ob && (ob->mode == OB_MODE_VERTEX_PAINT || ob->mode == 
OB_MODE_WEIGHT_PAINT) && ((Mesh *)ob->data)->totpoly;
+}
+
 int vertex_paint_poll(bContext *C)
 {
        if (vertex_paint_mode_poll(C) && 
@@ -4584,8 +4591,9 @@ void PAINT_OT_weight_gradient(wmOperatorType *ot)
        WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT);
 }
 
-static bool weight_to_vert_convert(Object *ob)
+static bool weight_to_vert_convert(bContext *C)
 {
+       Object *ob = CTX_data_active_object(C);
        Mesh *me;
        const MPoly *mp;
        int vgroup_active;
@@ -4611,13 +4619,15 @@ static bool weight_to_vert_convert(Object *ob)
                        j++;
                } while (j <= mp->totloop - 1);
        }
+
+       DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
        return true;
 }
 
 static int weight_to_vert_convert_exec(bContext *C, wmOperator *op)
 {
-       Object *obact = CTX_data_active_object(C);
-       if (weight_to_vert_convert(obact)) {
+       if (weight_to_vert_convert(C)) {
                return OPERATOR_FINISHED;
        }
        return OPERATOR_CANCELLED;
@@ -4626,13 +4636,13 @@ static int weight_to_vert_convert_exec(bContext *C, 
wmOperator *op)
 void PAINT_OT_weight_to_vertex_convert(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name = "Weight to Vertex Converter";
+       ot->name = "Weight to Vertex Convert";
        ot->idname = "PAINT_OT_weight_to_vertex_convert";
        ot->description = "Converts the weight color into the black and white 
vertex color";
 
        /* api callback */
        ot->exec = weight_to_vert_convert_exec;
-       ot->poll = weight_paint_poll;
+       ot->poll = vertex_weight_paint_mode_poll;
 
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to