[Bf-blender-cvs] [599d643] temp_custom_loop_normals: Split add/clear clnors data operator (vcol does that too, so...).

Bastien Montagne noreply at git.blender.org
Tue Feb 3 12:22:08 CET 2015


Commit: 599d643e7d2def96c1ae6f110893337d195d8d16
Author: Bastien Montagne
Date:   Tue Feb 3 12:21:43 2015 +0100
Branches: temp_custom_loop_normals
https://developer.blender.org/rB599d643e7d2def96c1ae6f110893337d195d8d16

Split add/clear clnors data operator (vcol does that too, so...).

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

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 c6f7014..8efd14a 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -373,11 +373,9 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel):
         col.operator("mesh.customdata_clear_skin", icon='X')
 
         if me.has_custom_normals:
-            col.operator("mesh.customdata_add_clear_custom_splitnormals",
-                         icon='X', text="Clear Custom Split Normals Data")
+            col.operator("mesh.customdata_custom_splitnormals_clear", icon='X')
         else:
-            col.operator("mesh.customdata_add_clear_custom_splitnormals",
-                         icon='ZOOMIN', text="Add Custom Split Normals Data")
+            col.operator("mesh.customdata_custom_splitnormals_add", icon='ZOOMIN')
 
         col = layout.column()
 
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 798f9fa..c56e7c8 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -839,7 +839,7 @@ void MESH_OT_customdata_clear_skin(wmOperatorType *ot)
 }
 
 /* Clear custom loop normals */
-static int mesh_customdata_add_clear_custom_splitnormals_poll(bContext *C)
+static int mesh_customdata_custom_splitnormals_add_clear_poll(bContext *C)
 {
 	Object *ob = ED_object_context(C);
 
@@ -852,15 +852,12 @@ static int mesh_customdata_add_clear_custom_splitnormals_poll(bContext *C)
 	return false;
 }
 
-static int mesh_customdata_add_clear_custom_splitnormals_exec(bContext *C, wmOperator *UNUSED(op))
+static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Object *ob = ED_object_context(C);
 	Mesh *me = ob->data;
 
-	if (BKE_mesh_has_custom_loop_normals(me)) {
-		return mesh_customdata_clear_exec__internal(C, BM_LOOP, CD_CUSTOMLOOPNORMAL);
-	}
-	else {
+	if (!BKE_mesh_has_custom_loop_normals(me)) {
 		CustomData *data = GET_CD_DATA(me, ldata);
 
 		if (me->edit_btmesh) {
@@ -875,18 +872,45 @@ static int mesh_customdata_add_clear_custom_splitnormals_exec(bContext *C, wmOpe
 
 		return OPERATOR_FINISHED;
 	}
+	return OPERATOR_CANCELLED;
+}
+
+void MESH_OT_customdata_custom_splitnormals_add(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Add Custom Split Normals Data";
+	ot->idname = "MESH_OT_customdata_custom_splitnormals_add";
+	ot->description = "Add a custom split normals layer, if none exists yet";
+
+	/* api callbacks */
+	ot->exec = mesh_customdata_custom_splitnormals_add_exec;
+	ot->poll = mesh_customdata_custom_splitnormals_add_clear_poll;
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int mesh_customdata_custom_splitnormals_clear_exec(bContext *C, wmOperator *UNUSED(op))
+{
+	Object *ob = ED_object_context(C);
+	Mesh *me = ob->data;
+
+	if (BKE_mesh_has_custom_loop_normals(me)) {
+		return mesh_customdata_clear_exec__internal(C, BM_LOOP, CD_CUSTOMLOOPNORMAL);
+	}
+	return OPERATOR_CANCELLED;
 }
 
-void MESH_OT_customdata_add_clear_custom_splitnormals(wmOperatorType *ot)
+void MESH_OT_customdata_custom_splitnormals_clear(wmOperatorType *ot)
 {
 	/* identifiers */
-	ot->name = "Add/Clear Custom Split Normals Data";
-	ot->idname = "MESH_OT_customdata_add_clear_custom_splitnormals";
-	ot->description = "Add a custom split normals layer, or remove it if it already exists";
+	ot->name = "Clear Custom Split Normals Data";
+	ot->idname = "MESH_OT_customdata_custom_splitnormals_clear";
+	ot->description = "Remove the custom split normals layer, if it exists";
 
 	/* api callbacks */
-	ot->exec = mesh_customdata_add_clear_custom_splitnormals_exec;
-	ot->poll = mesh_customdata_add_clear_custom_splitnormals_poll;
+	ot->exec = mesh_customdata_custom_splitnormals_clear_exec;
+	ot->poll = mesh_customdata_custom_splitnormals_add_clear_poll;
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index e027f52..8f5ecae 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -238,7 +238,8 @@ 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_add_clear_custom_splitnormals(struct wmOperatorType *ot);
+void MESH_OT_customdata_custom_splitnormals_add(struct wmOperatorType *ot);
+void MESH_OT_customdata_custom_splitnormals_clear(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 d462185..59d0de8 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -153,7 +153,8 @@ 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_add_clear_custom_splitnormals);
+	WM_operatortype_append(MESH_OT_customdata_custom_splitnormals_add);
+	WM_operatortype_append(MESH_OT_customdata_custom_splitnormals_clear);
 	WM_operatortype_append(MESH_OT_drop_named_image);
 
 	WM_operatortype_append(MESH_OT_edgering_select);




More information about the Bf-blender-cvs mailing list