[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59002] trunk/blender/source/blender/ editors/object/object_group.c: Fix #36383: add object to group check for dependency cycles did not work correctly

Brecht Van Lommel brechtvanlommel at pandora.be
Wed Aug 7 22:16:36 CEST 2013


Revision: 59002
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59002
Author:   blendix
Date:     2013-08-07 20:16:36 +0000 (Wed, 07 Aug 2013)
Log Message:
-----------
Fix #36383: add object to group check for dependency cycles did not work correctly
when the group contained two objects duplicating the same group. Also added the
dependency check to the "add to active group" operator now for consistency.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/object/object_group.c

Modified: trunk/blender/source/blender/editors/object/object_group.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_group.c	2013-08-07 19:29:15 UTC (rev 59001)
+++ trunk/blender/source/blender/editors/object/object_group.c	2013-08-07 20:16:36 UTC (rev 59002)
@@ -61,6 +61,49 @@
 
 /********************* 3d view operators ***********************/
 
+static bool group_link_early_exit_check(Group *group, Object *object)
+{
+	GroupObject *group_object;
+
+	for (group_object = group->gobject.first; group_object; group_object = group_object->next) {
+		if (group_object->ob == object) {
+			return true;
+		}
+	}
+
+	return false;
+}
+
+static bool check_group_contains_object_recursive(Group *group, Object *object)
+{
+	GroupObject *group_object;
+
+	if ((group->id.flag & LIB_DOIT) == 0) {
+		/* Cycle already exists in groups, let's prevent further crappyness */
+		return true;
+	}
+
+	group->id.flag &= ~LIB_DOIT;
+
+	for (group_object = group->gobject.first; group_object; group_object = group_object->next) {
+		Object *current_object = group_object->ob;
+
+		if (current_object == object) {
+			return true;
+		}
+
+		if (current_object->dup_group) {
+			if (check_group_contains_object_recursive(current_object->dup_group, object)) {
+				return true;
+			}
+		}
+	}
+
+	group->id.flag |= LIB_DOIT;
+
+	return false;
+}
+
 /* can be called with C == NULL */
 static EnumPropertyItem *group_object_active_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
 {
@@ -123,9 +166,15 @@
 		/* now add all selected objects from the group */
 		if (group) {
 
+			/* for recursive check */
+			tag_main_lb(&bmain->group, TRUE);
+
 			CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
 			{
-				if (base->object->dup_group != group) {
+				if (group_link_early_exit_check(group, base->object))
+					continue;
+
+				if (base->object->dup_group != group && !check_group_contains_object_recursive(group, base->object)) {
 					BKE_group_object_add(group, base->object, scene, base);
 				}
 				else {
@@ -378,47 +427,6 @@
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
-static bool group_link_early_exit_check(Group *group, Object *object)
-{
-	GroupObject *group_object;
-
-	for (group_object = group->gobject.first; group_object; group_object = group_object->next) {
-		if (group_object->ob == object) {
-			return true;
-		}
-	}
-
-	return false;
-}
-
-static bool check_group_contains_object_recursive(Group *group, Object *object)
-{
-	GroupObject *group_object;
-
-	if ((group->id.flag & LIB_DOIT) == 0) {
-		/* Cycle already exists in groups, let's prevent further crappyness */
-		return true;
-	}
-
-	group->id.flag &= ~LIB_DOIT;
-
-	for (group_object = group->gobject.first; group_object; group_object = group_object->next) {
-		Object *current_object = group_object->ob;
-
-		if (current_object == object) {
-			return true;
-		}
-
-		if (current_object->dup_group) {
-			if (check_group_contains_object_recursive(current_object->dup_group, object)) {
-				return true;
-			}
-		}
-	}
-
-	return false;
-}
-
 static int group_link_exec(bContext *C, wmOperator *op)
 {
 	Main *bmain = CTX_data_main(C);




More information about the Bf-blender-cvs mailing list