[Bf-blender-cvs] [00f5c621a65] blender2.8: Outliner: Re-build depsgraph when reordering collections

Dalai Felinto noreply at git.blender.org
Tue Apr 25 18:44:41 CEST 2017


Commit: 00f5c621a65b6bc9847776b2542588835fb4054c
Author: Dalai Felinto
Date:   Tue Apr 25 18:43:53 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB00f5c621a65b6bc9847776b2542588835fb4054c

Outliner: Re-build depsgraph when reordering collections

Otherwise if we create a new collection, and drag a collection into it we either
get a crash, or at the very least we dont get the visibility flags correct.

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

M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_ops.c
M	source/blender/editors/space_outliner/outliner_tree.c

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

diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 2256e55a315..06b37377535 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -39,6 +39,7 @@
 struct wmOperatorType;
 struct TreeElement;
 struct TreeStoreElem;
+struct Main;
 struct bContext;
 struct Scene;
 struct SceneLayer;
@@ -68,7 +69,8 @@ typedef enum TreeTraversalAction {
  * Callback type for reinserting elements at a different position, used to allow user customizable element order.
  * Passing scene right now, may be better to allow some custom data.
  */
-typedef void (*TreeElementReinsertFunc)(const struct Scene *scene, struct TreeElement *insert_element,
+typedef void (*TreeElementReinsertFunc)(struct Main *bmain, const struct Scene *scene,
+                                        struct TreeElement *insert_element,
                                         struct TreeElement *insert_handle, TreeElementInsertType action);
 /**
  * Executed on (almost) each mouse move while dragging. It's supposed to give info
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index 90d27b09292..5466ef1a9ed 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -29,6 +29,7 @@
  */
 
 #include "BKE_context.h"
+#include "BKE_main.h"
 
 #include "BLI_listbase.h"
 #include "BLI_math.h"
@@ -164,7 +165,7 @@ static void outliner_item_drag_handle(
 	te_dragged->drag_data->insert_handle = te_insert_handle;
 }
 
-static bool outliner_item_drag_drop_apply(const Scene *scene, TreeElement *dragged_te)
+static bool outliner_item_drag_drop_apply(Main *bmain, const Scene *scene, TreeElement *dragged_te)
 {
 	TreeElement *insert_handle = dragged_te->drag_data->insert_handle;
 	TreeElementInsertType insert_type = dragged_te->drag_data->insert_type;
@@ -178,7 +179,7 @@ static bool outliner_item_drag_drop_apply(const Scene *scene, TreeElement *dragg
 		/* call of assert above should not have changed insert_handle and insert_type at this point */
 		BLI_assert(dragged_te->drag_data->insert_handle == insert_handle &&
 		           dragged_te->drag_data->insert_type == insert_type);
-		dragged_te->reinsert(scene, dragged_te, insert_handle, insert_type);
+		dragged_te->reinsert(bmain, scene, dragged_te, insert_handle, insert_type);
 		return true;
 	}
 
@@ -187,6 +188,7 @@ static bool outliner_item_drag_drop_apply(const Scene *scene, TreeElement *dragg
 
 static int outliner_item_drag_drop_modal(bContext *C, wmOperator *op, const wmEvent *event)
 {
+	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
 	ARegion *ar = CTX_wm_region(C);
 	SpaceOops *soops = CTX_wm_space_outliner(C);
@@ -198,7 +200,7 @@ static int outliner_item_drag_drop_modal(bContext *C, wmOperator *op, const wmEv
 	switch (event->type) {
 		case EVT_MODAL_MAP:
 			if (event->val == OUTLINER_ITEM_DRAG_CONFIRM) {
-				if (outliner_item_drag_drop_apply(scene, te_dragged)) {
+				if (outliner_item_drag_drop_apply(bmain, scene, te_dragged)) {
 					skip_rebuild = false;
 				}
 				retval = OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 9cca2416acc..e7a866524fd 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -61,6 +61,7 @@
 
 #include "BLT_translation.h"
 
+#include "BKE_depsgraph.h"
 #include "BKE_fcurve.h"
 #include "BKE_main.h"
 #include "BKE_layer.h"
@@ -389,7 +390,8 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s
 }
 
 static void outliner_object_reorder(
-        const Scene *scene, TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action)
+        Main *UNUSED(bmain), const Scene *scene,
+        TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action)
 {
 	TreeStoreElem *tselem_insert = TREESTORE(insert_element);
 	Object *ob = (Object *)tselem_insert->id;
@@ -413,6 +415,7 @@ static void outliner_object_reorder(
 	}
 	BKE_collection_object_move(scene, sc, sc_ob_parent, ob);
 }
+
 static bool outliner_object_reorder_poll(
         const Scene *UNUSED(scene), const TreeElement *insert_element,
         TreeElement **io_insert_handle, TreeElementInsertType *io_action)
@@ -1331,7 +1334,8 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops)
 }
 
 static void outliner_layer_collections_reorder(
-        const Scene *scene, TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action)
+        Main *bmain, const Scene *scene,
+        TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action)
 {
 	LayerCollection *lc_insert = insert_element->directdata;
 	LayerCollection *lc_handle = insert_handle->directdata;
@@ -1348,6 +1352,8 @@ static void outliner_layer_collections_reorder(
 	else {
 		BLI_assert(0);
 	}
+
+	DAG_relations_tag_update(bmain);
 }
 static bool outliner_layer_collections_reorder_poll(
         const Scene *UNUSED(scene), const TreeElement *UNUSED(insert_element),
@@ -1383,7 +1389,8 @@ static void outliner_add_collections_act_layer(SpaceOops *soops, SceneLayer *lay
 }
 
 static void outliner_scene_collections_reorder(
-        const Scene *scene, TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action)
+        Main *bmain, const Scene *scene,
+        TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action)
 {
 	SceneCollection *sc_insert = insert_element->directdata;
 	SceneCollection *sc_handle = insert_handle->directdata;
@@ -1401,6 +1408,8 @@ static void outliner_scene_collections_reorder(
 	else {
 		BLI_assert(0);
 	}
+
+	DAG_relations_tag_update(bmain);
 }
 static bool outliner_scene_collections_reorder_poll(
         const Scene *scene, const TreeElement *UNUSED(insert_element),




More information about the Bf-blender-cvs mailing list