[Bf-blender-cvs] [e63b87fb4db] soc-2019-outliner: Outliner: Set active camera on camera data activate

Nathan Craddock noreply at git.blender.org
Tue Jul 16 03:42:31 CEST 2019


Commit: e63b87fb4db75017436aa231aa2ddd40a5f793b5
Author: Nathan Craddock
Date:   Mon Jul 15 19:25:06 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rBe63b87fb4db75017436aa231aa2ddd40a5f793b5

Outliner: Set active camera on camera data activate

Allow setting the active scene camera on camera data activate.

Not sure if all the depsgraph and event notifier calls are needed.
Tested removing some and it still worked.

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

M	source/blender/editors/space_outliner/outliner_select.c

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

diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 09752bdb08e..fe35c8d9661 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -51,6 +51,7 @@
 #include "BKE_workspace.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
 
 #include "ED_armature.h"
 #include "ED_object.h"
@@ -475,9 +476,9 @@ static eOLDrawState tree_element_active_material(bContext *C,
   return OL_DRAWSEL_NONE;
 }
 
-static eOLDrawState tree_element_active_camera(bContext *UNUSED(C),
+static eOLDrawState tree_element_active_camera(bContext *C,
                                                Scene *scene,
-                                               ViewLayer *UNUSED(sl),
+                                               ViewLayer *UNUSED(view_layer),
                                                SpaceOutliner *soops,
                                                TreeElement *te,
                                                const eOLSetState set)
@@ -485,10 +486,21 @@ static eOLDrawState tree_element_active_camera(bContext *UNUSED(C),
   Object *ob = (Object *)outliner_search_back(soops, te, ID_OB);
 
   if (set != OL_SETSEL_NONE) {
+    scene->camera = ob;
+
+    Main *bmain = CTX_data_main(C);
+    wmWindowManager *wm = bmain->wm.first;
+
+    WM_windows_scene_data_sync(&wm->windows, scene);
+    DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
+    DEG_relations_tag_update(bmain);
+    WM_event_add_notifier(C, NC_SCENE | NA_EDITED, NULL);
+
     return OL_DRAWSEL_NONE;
   }
-
-  return scene->camera == ob;
+  else {
+    return scene->camera == ob;
+  }
 }
 
 static eOLDrawState tree_element_active_world(bContext *C,



More information about the Bf-blender-cvs mailing list