[Bf-blender-cvs] [f1598e4] temp_custom_loop_normals: Add a 'clear custom split normals' op (similar to those for skin or mask CD layers).

Bastien Montagne noreply at git.blender.org
Wed Aug 6 21:36:37 CEST 2014


Commit: f1598e4d1a932a677496487fd5eb6281cd1bdc27
Author: Bastien Montagne
Date:   Tue Jul 15 12:57:20 2014 +0200
Branches: temp_custom_loop_normals
https://developer.blender.org/rBf1598e4d1a932a677496487fd5eb6281cd1bdc27

Add a 'clear custom split normals' op (similar to those for skin or mask CD layers).

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

M	release/scripts/startup/bl_ui/properties_data_mesh.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_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index 909c6ab..ff3c03a 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -370,6 +370,7 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel):
 
         col.operator("mesh.customdata_clear_mask", icon='X')
         col.operator("mesh.customdata_clear_skin", icon='X')
+        col.operator("mesh.customdata_clear_custom_splitnormals", icon='X')
 
         col = layout.column()
 
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 8394753..60221f2 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -817,6 +817,42 @@ void MESH_OT_customdata_clear_skin(wmOperatorType *ot)
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+/* Clear custom loop normals */
+static int mesh_customdata_clear_custom_splitnormals_poll(bContext *C)
+{
+	Object *ob = ED_object_context(C);
+
+	if (ob && ob->type == OB_MESH) {
+		Mesh *me = ob->data;
+		if (me->id.lib == NULL) {
+			CustomData *data = GET_CD_DATA(me, ldata);
+			if (CustomData_has_layer(data, CD_CUSTOMLOOPNORMAL)) {
+				return true;
+			}
+		}
+	}
+	return false;
+}
+static int mesh_customdata_clear_custom_splitnormals_exec(bContext *C, wmOperator *UNUSED(op))
+{
+	return mesh_customdata_clear_exec__internal(C, BM_LOOP, CD_CUSTOMLOOPNORMAL);
+}
+
+void MESH_OT_customdata_clear_custom_splitnormals(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Clear Custom Split Normals Data";
+	ot->idname = "MESH_OT_customdata_clear_custom_splitnormals";
+	ot->description = "Clear custom split normals layer";
+
+	/* api callbacks */
+	ot->exec = mesh_customdata_clear_custom_splitnormals_exec;
+	ot->poll = mesh_customdata_clear_custom_splitnormals_poll;
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
 /************************** Add Geometry Layers *************************/
 
 void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface)
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index 2ce19fe..4c38fbb 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -235,6 +235,7 @@ 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_clear_skin(struct wmOperatorType *ot);
+void MESH_OT_customdata_clear_custom_splitnormals(struct wmOperatorType *ot);
 void MESH_OT_drop_named_image(struct wmOperatorType *ot);
 
 
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 55dd97d..09fc509 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_remove);
 	WM_operatortype_append(MESH_OT_customdata_clear_mask);
 	WM_operatortype_append(MESH_OT_customdata_clear_skin);
+	WM_operatortype_append(MESH_OT_customdata_clear_custom_splitnormals);
 	WM_operatortype_append(MESH_OT_drop_named_image);
 
 	WM_operatortype_append(MESH_OT_edgering_select);




More information about the Bf-blender-cvs mailing list