[Bf-blender-cvs] [3a80827] master: Fix T44589: No way to add a skin data layer manualy.

Bastien Montagne noreply at git.blender.org
Sun May 3 15:19:49 CEST 2015


Commit: 3a808270df31ea438e7ca912b8035920ad24cd4a
Author: Bastien Montagne
Date:   Sun May 3 15:09:48 2015 +0200
Branches: master
https://developer.blender.org/rB3a808270df31ea438e7ca912b8035920ad24cd4a

Fix T44589: No way to add a skin data layer manualy.

There are several ways to end up with an object with skin modifier, but no
skin data on the geometry. So we need an operator to add it by hands.

Also tweaked a bit UI of this modifier.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/editors/mesh/mesh_data.c
M	source/blender/editors/mesh/mesh_intern.h
M	source/blender/editors/mesh/mesh_ops.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 1186992..d6d4e03 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1131,13 +1131,15 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         self.vertex_weight_mask(layout, ob, md)
 
     def SKIN(self, layout, ob, md):
-        layout.operator("object.skin_armature_create", text="Create Armature")
+        row = layout.row()
+        row.operator("object.skin_armature_create", text="Create Armature")
+        row.operator("mesh.customdata_skin_add")
 
         layout.separator()
 
-        col = layout.column(align=True)
-        col.prop(md, "branch_smoothing")
-        col.prop(md, "use_smooth_shade")
+        row = layout.row(align=True)
+        row.prop(md, "branch_smoothing")
+        row.prop(md, "use_smooth_shade")
 
         split = layout.split()
 
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 86991d7..1d0cd6a 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -804,7 +804,7 @@ void MESH_OT_customdata_clear_mask(wmOperatorType *ot)
 }
 
 /* Clear Skin */
-static int mesh_customdata_clear_skin_poll(bContext *C)
+static bool mesh_customdata_skin_has(bContext *C)
 {
 	Object *ob = ED_object_context(C);
 
@@ -819,6 +819,45 @@ static int mesh_customdata_clear_skin_poll(bContext *C)
 	}
 	return false;
 }
+
+static int mesh_customdata_skin_add_poll(bContext *C)
+{
+	return !mesh_customdata_skin_has(C);
+}
+
+static int mesh_customdata_skin_add_exec(bContext *C, wmOperator *UNUSED(op))
+{
+	Object *ob = ED_object_context(C);
+	Mesh *me = ob->data;
+
+	BKE_mesh_ensure_skin_customdata(me);
+
+	DAG_id_tag_update(&me->id, 0);
+	WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
+
+	return OPERATOR_FINISHED;
+}
+
+void MESH_OT_customdata_skin_add(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Add Skin Data";
+	ot->idname = "MESH_OT_customdata_skin_add";
+	ot->description = "Add a vertex skin layer";
+
+	/* api callbacks */
+	ot->exec = mesh_customdata_skin_add_exec;
+	ot->poll = mesh_customdata_skin_add_poll;
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int mesh_customdata_clear_skin_poll(bContext *C)
+{
+	return mesh_customdata_skin_has(C);
+}
+
 static int mesh_customdata_clear_skin_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	return mesh_customdata_clear_exec__internal(C, BM_VERT, CD_MVERT_SKIN);
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index c735512..de7d0f3 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -233,6 +233,7 @@ void MESH_OT_vertex_color_add(struct wmOperatorType *ot);
 void MESH_OT_vertex_color_remove(struct wmOperatorType *ot);
 /* no create_mask yet */
 void MESH_OT_customdata_clear_mask(struct wmOperatorType *ot);
+void MESH_OT_customdata_skin_add(struct wmOperatorType *ot);
 void MESH_OT_customdata_clear_skin(struct wmOperatorType *ot);
 void MESH_OT_customdata_custom_splitnormals_add(struct wmOperatorType *ot);
 void MESH_OT_customdata_custom_splitnormals_clear(struct wmOperatorType *ot);
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 2855af0..31d3f01 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -152,6 +152,7 @@ void ED_operatortypes_mesh(void)
 	WM_operatortype_append(MESH_OT_vertex_color_add);
 	WM_operatortype_append(MESH_OT_vertex_color_remove);
 	WM_operatortype_append(MESH_OT_customdata_clear_mask);
+	WM_operatortype_append(MESH_OT_customdata_skin_add);
 	WM_operatortype_append(MESH_OT_customdata_clear_skin);
 	WM_operatortype_append(MESH_OT_customdata_custom_splitnormals_add);
 	WM_operatortype_append(MESH_OT_customdata_custom_splitnormals_clear);




More information about the Bf-blender-cvs mailing list