[Bf-blender-cvs] [ee3dde2] master: UI: ObData support for copy-to-selected

Campbell Barton noreply at git.blender.org
Tue May 12 23:25:47 CEST 2015


Commit: ee3dde2d49983906ce7c5fb7d5802aea20ffb3ba
Author: Campbell Barton
Date:   Wed May 13 07:23:03 2015 +1000
Branches: master
https://developer.blender.org/rBee3dde2d49983906ce7c5fb7d5802aea20ffb3ba

UI: ObData support for copy-to-selected

Now multi-object editing works for obdata too.

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

M	source/blender/editors/interface/interface_ops.c

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

diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 892bbd8..e0adc39 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -33,6 +33,7 @@
 
 #include "DNA_screen_types.h"
 #include "DNA_text_types.h" /* for UI_OT_reports_to_text */
+#include "DNA_object_types.h" /* for OB_DATA_SUPPORT_ID */
 
 #include "BLI_blenlib.h"
 #include "BLI_math_color.h"
@@ -57,6 +58,7 @@
 #include "WM_types.h"
 
 #include "ED_paint.h"
+#include "ED_object.h"
 
 /* only for UI_OT_editsource */
 #include "ED_screen.h"
@@ -285,6 +287,51 @@ bool UI_context_copy_to_selected_list(
 			*r_use_path_from_id = true;
 			*r_path = RNA_path_from_ID_to_property(ptr, prop);
 		}
+		else if (OB_DATA_SUPPORT_ID(GS(id->name))) {
+			/* check we're using the active object */
+
+			Object *ob = ED_object_context(C);
+			if (ob && ob->data == id) {
+				const short id_code = GS(id->name);
+				ListBase lb = CTX_data_collection_get(C, "selected_editable_objects");
+				char *path = RNA_path_from_ID_to_property(ptr, prop);
+
+				if (path) {
+					char *path_tmp;
+					path_tmp = path;
+					path = BLI_sprintfN("data%s%s", path[0] == '[' ? "" : ".", path);
+					MEM_freeN(path_tmp);
+				}
+
+				/* de-duplicate obdata */
+				if (!BLI_listbase_is_empty(&lb)) {
+					CollectionPointerLink *link, *link_next;
+
+					for (link = lb.first; link; link = link->next) {
+						Object *ob = link->ptr.id.data;
+						if (ob->data) {
+							ID *id = ob->data;
+							id->flag |= LIB_DOIT;
+						}
+					}
+
+					for (link = lb.first; link; link = link_next) {
+						Object *ob = link->ptr.id.data;
+						ID *id = ob->data;
+						link_next = link->next;
+						if ((id == NULL) || (id->flag & LIB_DOIT) == 0 || (GS(id->name) != id_code)) {
+							BLI_remlink(&lb, link);
+							MEM_freeN(link);
+						}
+						id->flag &= ~LIB_DOIT;
+					}
+				}
+
+				*r_lb = lb;
+				*r_path = path;
+			}
+
+		}
 		else if (GS(id->name) == ID_SCE) {
 			/* Sequencer's ID is scene :/ */
 			/* Try to recursively find an RNA_Sequence ancestor, to handle situations like T41062... */




More information about the Bf-blender-cvs mailing list