Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-26 14:11:53 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-26 14:11:53 +0300
commit26d8b598649d25cf352adab03111e623adacea48 (patch)
tree34543e721140b5ec733e12eba80d2bf9ed69111e /source/blender/editors/sculpt_paint/paint_vertex.c
parent5a1603374c768d7a9c7d9cb4b05ca4098ca32537 (diff)
Assign automatic/envelope weights in weight paint mode is back,
accessible from W key and in new Weights menu in the header.
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_vertex.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 64dbe4e4c5c..debdf4a3118 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -88,6 +88,7 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "ED_armature.h"
#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_screen.h"
@@ -135,6 +136,13 @@ int vertex_paint_poll(bContext *C)
return 0;
}
+int weight_paint_mode_poll(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+
+ return ob && ob->mode == OB_MODE_WEIGHT_PAINT;
+}
+
int weight_paint_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
@@ -1980,3 +1988,51 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot)
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
}
+/* ********************** weight from bones operator ******************* */
+
+static int weight_from_bones_poll(bContext *C)
+{
+ Object *ob= CTX_data_active_object(C);
+
+ return (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob));
+}
+
+static int weight_from_bones_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+ Object *armob= modifiers_isDeformedByArmature(ob);
+ Mesh *me= ob->data;
+ int type= RNA_enum_get(op->ptr, "type");
+
+ create_vgroups_from_armature(scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
+
+ DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
+
+ return OPERATOR_FINISHED;
+}
+
+void PAINT_OT_weight_from_bones(wmOperatorType *ot)
+{
+ static EnumPropertyItem type_items[]= {
+ {ARM_GROUPS_AUTO, "AUTOMATIC", 0, "Automatic", "Automatic weights froms bones."},
+ {ARM_GROUPS_ENVELOPE, "ENVELOPES", 0, "From Envelopes", "Weights from envelopes with user defined radius."},
+ {0, NULL, 0, NULL, NULL}};
+
+ /* identifiers */
+ ot->name= "Weight from Bones";
+ ot->idname= "PAINT_OT_weight_from_bones";
+
+ /* api callbacks */
+ ot->exec= weight_from_bones_exec;
+ ot->invoke= WM_menu_invoke;
+ ot->poll= weight_from_bones_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ ot->prop= RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Method to use for assigning weights.");
+}
+