[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57246] trunk/blender: add option to remove all shape keys at once ( access from shape key menu on panel).

Campbell Barton ideasman42 at gmail.com
Wed Jun 5 08:34:19 CEST 2013


Revision: 57246
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57246
Author:   campbellbarton
Date:     2013-06-05 06:34:18 +0000 (Wed, 05 Jun 2013)
Log Message:
-----------
add option to remove all shape keys at once (access from shape key menu on panel).

Without this there was no easy way to get a WYSIWYG copy of a mesh that had shape keys,
since removing them would adjust the mesh.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py
    trunk/blender/source/blender/editors/object/object_shapekey.c
    trunk/blender/source/blender/editors/object/object_vgroup.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py	2013-06-05 05:58:51 UTC (rev 57245)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py	2013-06-05 06:34:18 UTC (rev 57246)
@@ -54,6 +54,7 @@
         layout.operator("object.join_shapes", icon='COPY_ID')  # icon is not ideal
         layout.operator("object.shape_key_mirror", icon='ARROW_LEFTRIGHT')
         layout.operator("object.shape_key_add", icon='ZOOMIN', text="New Shape From Mix").from_mix = True
+        layout.operator("object.shape_key_remove", icon='X', text="Delete All Shapes").all = True
 
 
 class MESH_UL_vgroups(UIList):
@@ -257,7 +258,7 @@
 
         sub = col.column(align=True)
         sub.operator("object.shape_key_add", icon='ZOOMIN', text="").from_mix = False
-        sub.operator("object.shape_key_remove", icon='ZOOMOUT', text="")
+        sub.operator("object.shape_key_remove", icon='ZOOMOUT', text="").all = False
         sub.menu("MESH_MT_shape_key_specials", icon='DOWNARROW_HLT', text="")
 
         if kb:

Modified: trunk/blender/source/blender/editors/object/object_shapekey.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_shapekey.c	2013-06-05 05:58:51 UTC (rev 57245)
+++ trunk/blender/source/blender/editors/object/object_shapekey.c	2013-06-05 06:34:18 UTC (rev 57246)
@@ -88,17 +88,34 @@
 
 /*********************** remove shape key ***********************/
 
-static int ED_object_shape_key_remove(bContext *C, Object *ob)
+static bool ED_object_shape_key_remove_all(Main *bmain, Object *ob)
 {
-	Main *bmain = CTX_data_main(C);
+	Key *key;
+
+	key = BKE_key_from_object(ob);
+	if (key == NULL)
+		return false;
+
+	switch (GS(key->from->name)) {
+		case ID_ME: ((Mesh *)key->from)->key    = NULL; break;
+		case ID_CU: ((Curve *)key->from)->key   = NULL; break;
+		case ID_LT: ((Lattice *)key->from)->key = NULL; break;
+	}
+
+	BKE_libblock_free_us(&(bmain->key), key);
+
+	return true;
+}
+
+static bool ED_object_shape_key_remove(Main *bmain, Object *ob)
+{
 	KeyBlock *kb, *rkb;
 	Key *key;
-	//IpoCurve *icu;
 
 	key = BKE_key_from_object(ob);
 	if (key == NULL)
-		return 0;
-	
+		return false;
+
 	kb = BLI_findlink(&key->block, ob->shapenr - 1);
 
 	if (kb) {
@@ -145,11 +162,8 @@
 
 		BKE_libblock_free_us(&(bmain->key), key);
 	}
-	
-	DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
 
-	return 1;
+	return true;
 }
 
 static bool object_shape_key_mirror(bContext *C, Object *ob,
@@ -311,14 +325,28 @@
 	RNA_def_boolean(ot->srna, "from_mix", 1, "From Mix", "Create the new shape key from the existing mix of keys");
 }
 
-static int shape_key_remove_exec(bContext *C, wmOperator *UNUSED(op))
+static int shape_key_remove_exec(bContext *C, wmOperator *op)
 {
+	Main *bmain = CTX_data_main(C);
 	Object *ob = ED_object_context(C);
+	bool change = false;
 
-	if (!ED_object_shape_key_remove(C, ob))
+	if (RNA_boolean_get(op->ptr, "all")) {
+		change = ED_object_shape_key_remove_all(bmain, ob);
+	}
+	else {
+		change = ED_object_shape_key_remove(bmain, ob);
+	}
+
+	if (change) {
+		DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+		WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+
+		return OPERATOR_FINISHED;
+	}
+	else {
 		return OPERATOR_CANCELLED;
-	
-	return OPERATOR_FINISHED;
+	}
 }
 
 void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
@@ -334,6 +362,9 @@
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+	/* properties */
+	RNA_def_boolean(ot->srna, "all", 0, "All", "Remove all shape keys");
 }
 
 static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))

Modified: trunk/blender/source/blender/editors/object/object_vgroup.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_vgroup.c	2013-06-05 05:58:51 UTC (rev 57245)
+++ trunk/blender/source/blender/editors/object/object_vgroup.c	2013-06-05 06:34:18 UTC (rev 57246)
@@ -2830,7 +2830,7 @@
 	ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO;
 
 	/* properties */
-	RNA_def_boolean(ot->srna, "all", 0, "All", "Remove from all vertex groups");
+	RNA_def_boolean(ot->srna, "all", 0, "All", "Remove all vertex groups");
 }
 
 static int vertex_group_assign_exec(bContext *C, wmOperator *op)




More information about the Bf-blender-cvs mailing list