[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58627] branches/ soc-2013-meshdata_transfer/source/blender/editors/object/object_shapekey.c: Shapekey transfer through vertices: supporting multi direction copying -either to/from active object-

Walid Shouman eng.walidshouman at gmail.com
Fri Jul 26 18:13:09 CEST 2013


Revision: 58627
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58627
Author:   walid
Date:     2013-07-26 16:13:09 +0000 (Fri, 26 Jul 2013)
Log Message:
-----------
Shapekey transfer through vertices: supporting multi direction copying -either to/from active object-

Modified Paths:
--------------
    branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_shapekey.c

Modified: branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_shapekey.c
===================================================================
--- branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_shapekey.c	2013-07-26 15:35:16 UTC (rev 58626)
+++ branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_shapekey.c	2013-07-26 16:13:09 UTC (rev 58627)
@@ -312,6 +312,19 @@
     {0, NULL, 0, NULL, NULL}
 };
 
+typedef enum ST_FromToActive {
+	ST_FROM_ACTIVE = 1,
+	ST_TO_ACTIVE = 2
+} ST_FromToActive;
+
+static EnumPropertyItem ST_from_to_active[] = {
+    {ST_FROM_ACTIVE,
+	 "ST_FROM_ACTIVE", 0, "From active", "Transfer to different objects"},
+    {ST_TO_ACTIVE,
+	 "ST_TO_ACTIVE", 0, "To active", "Better to faster tweek the output"},
+    {0, NULL, 0, NULL, NULL}
+};
+
 static bool ED_object_shape_key_transfer(Object *ob_dst, Object *ob_src, bContext *C, Scene *scene, wmOperator *op)
 {
 	Mesh *me_dst, *me_src;
@@ -769,15 +782,34 @@
 	Object *ob_act = CTX_data_active_object(C);
 	int fail = 0;
 
+	bool transfer_first_to_act = true;
+
+	ST_FromToActive from_active = RNA_enum_get(op->ptr, "from_to_active");
+
 	/* Macro to loop through selected objects.*/
 	CTX_DATA_BEGIN (C, Object *, ob_slc, selected_editable_objects)
 	{
 		//if the selected isn't the active object
 		if (ob_act != ob_slc) {
 
-			if (!ED_object_shape_key_transfer(ob_act, ob_slc, C, scene, op)) {
-				fail++;
+			if (from_active == ST_TO_ACTIVE) {
+
+				//if many objects were selected within this mode ... we should copy only from the first
+				//notice that ob_slc priority isn't set by order of selection!
+				if (transfer_first_to_act == true) {
+					transfer_first_to_act = false;
+
+					if (!ED_object_shape_key_transfer(ob_act, ob_slc, C, scene, op)) {
+						fail++;
+						}
+				}
+
 			}
+			else {		//copy from the active to all the other selected
+				if (!ED_object_shape_key_transfer(ob_slc, ob_act, C, scene, op)) {
+					fail++;
+				}
+			}
 		}
 	}
 
@@ -831,5 +863,7 @@
 	             "Replace/Append", "define which groups to move");
 	RNA_def_enum(ot->srna, "transfer_mode", ST_transfer_mode_item, 2,
 	             "Transfer Mode", "Choose between different algorithms");
+	RNA_def_enum(ot->srna, "from_to_active", ST_from_to_active, 2, "From/To active object",
+	             "Choose the transfer direction");
 }
 




More information about the Bf-blender-cvs mailing list