[Bf-blender-cvs] [b7e9161] workspaces: Make 3D View scene data syncing work with window level scenes.

Julian Eisel noreply at git.blender.org
Thu Dec 22 01:57:57 CET 2016


Commit: b7e91618330ce5ba963a72580b7d649b00d5e347
Author: Julian Eisel
Date:   Thu Dec 22 01:50:20 2016 +0100
Branches: workspaces
https://developer.blender.org/rBb7e91618330ce5ba963a72580b7d649b00d5e347

Make 3D View scene data syncing work with window level scenes.

We previously updated all screens - visible or not - when changing scene layers or scene camera. Now we only update visible ones and ensure a screen is updated when activating it. This simplifies things a bit and makes it possible to update 3D Views directly through notifiers.

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

M	source/blender/blenkernel/BKE_screen.h
M	source/blender/blenkernel/intern/screen.c
M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/screen/screen_edit.c
M	source/blender/editors/screen/workspace_edit.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/space_view3d/view3d_header.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_window.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c

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

diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 13d59e8..9b9d757 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -307,7 +307,6 @@ unsigned int BKE_screen_view3d_layer_all(const struct bScreen *sc) ATTR_WARN_UNU
 
 void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene);
 void BKE_screen_view3d_scene_sync(struct bScreen *sc, struct Scene *scene);
-void BKE_screen_view3d_main_sync(ListBase *screen_lb, struct Scene *scene);
 void BKE_screen_view3d_twmode_remove(struct View3D *v3d, const int i);
 void BKE_screen_view3d_main_twmode_remove(ListBase *screen_lb, struct Scene *scene, const int i);
 void BKE_screen_gpu_fx_validate(struct GPUFXSettings *fx_settings);
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 1be1a85..77e12fb 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -611,24 +611,6 @@ void BKE_screen_view3d_scene_sync(bScreen *sc, Scene *scene)
 	}
 }
 
-void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene)
-{
-	bScreen *sc;
-	ScrArea *sa;
-	SpaceLink *sl;
-
-	/* from scene copy to the other views */
-	for (sc = screen_lb->first; sc; sc = sc->id.next) {
-		if (sc->scene != scene)
-			continue;
-
-		for (sa = sc->areabase.first; sa; sa = sa->next)
-			for (sl = sa->spacedata.first; sl; sl = sl->next)
-				if (sl->spacetype == SPACE_VIEW3D)
-					BKE_screen_view3d_sync((View3D *)sl, scene);
-	}
-}
-
 void BKE_screen_view3d_twmode_remove(View3D *v3d, const int i)
 {
 	const int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index eb80340..108409c 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -130,6 +130,7 @@ struct WorkSpaceLayout *ED_workspace_layout_duplicate(struct WorkSpace *workspac
                                                       const struct WorkSpaceLayout *layout_old,
                                                       struct wmWindow *win) ATTR_NONNULL();
 bool ED_workspace_delete(struct Main *bmain, struct bContext *C, struct wmWindow *win, struct WorkSpace *ws);
+void ED_workspace_scene_data_sync(struct WorkSpace *workspace, Scene *scene);
 bool ED_workspace_layout_delete(struct bContext *C, struct WorkSpace *workspace, struct WorkSpaceLayout *layout_old) ATTR_NONNULL();
 bool ED_workspace_layout_cycle(struct bContext *C, struct WorkSpace *workspace, const short direction) ATTR_NONNULL();
 
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index dadd808..8bc923e 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1208,6 +1208,7 @@ bScreen *screen_set_find_associated_fullscreen(const Main *bmain, bScreen *scree
  */
 void screen_set_refresh(Main *bmain, bContext *C, wmWindow *win)
 {
+	Scene *scene = WM_window_get_active_scene(win);
 	bScreen *sc = WM_window_get_active_screen(win);
 
 	CTX_wm_window_set(C, win);  // stores C->wm.screen... hrmf
@@ -1215,6 +1216,7 @@ void screen_set_refresh(Main *bmain, bContext *C, wmWindow *win)
 	/* prevent multiwin errors */
 	sc->winid = win->winid;
 
+	BKE_screen_view3d_scene_sync(sc, scene); /* sync new screen with scene data */
 	ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C));
 	WM_event_add_notifier(C, NC_WINDOW, NULL);
 	WM_event_add_notifier(C, NC_WORKSPACE | ND_SCREENSET, sc);
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 4bb647f..31527cd 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -119,6 +119,16 @@ bool ED_workspace_delete(Main *bmain, bContext *C, wmWindow *win, WorkSpace *ws)
 	return true;
 }
 
+/**
+ * Some editor data may need to be synced with scene data (3D View camera and layers).
+ * This function ensures data is synced for editors in active layout of \a workspace.
+ */
+void ED_workspace_scene_data_sync(WorkSpace *workspace, Scene *scene)
+{
+	bScreen *screen = BKE_workspace_active_screen_get(workspace);
+	BKE_screen_view3d_scene_sync(screen, scene);
+}
+
 /** \} Workspace API */
 
 
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index abb3fe0..092ef51 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -841,12 +841,17 @@ static void view3d_main_region_listener(bScreen *UNUSED(sc), ScrArea *sa, ARegio
 						view3d_recalc_used_layers(ar, wmn, wmn->reference);
 					ED_region_tag_redraw(ar);
 					break;
+				case ND_LAYER:
+					if (wmn->reference) {
+						BKE_screen_view3d_sync(v3d, wmn->reference);
+					}
+					ED_region_tag_redraw(ar);
+					break;
 				case ND_FRAME:
 				case ND_TRANSFORM:
 				case ND_OB_ACTIVE:
 				case ND_OB_SELECT:
 				case ND_OB_VISIBLE:
-				case ND_LAYER:
 				case ND_RENDER_OPTIONS:
 				case ND_MARKERS:
 				case ND_MODE:
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 32e265c..ab95355 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -71,11 +71,10 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event);
 /* XXX quickly ported across */
 static void handle_view3d_lock(bContext *C)
 {
-	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
 	ScrArea *sa = CTX_wm_area(C);
 	View3D *v3d = CTX_wm_view3d(C);
-	
+
 	if (v3d != NULL && sa != NULL) {
 		if (v3d->localvd == NULL && v3d->scenelock && sa->spacetype == SPACE_VIEW3D) {
 			/* copy to scene */
@@ -83,10 +82,6 @@ static void handle_view3d_lock(bContext *C)
 			scene->layact = v3d->layact;
 			scene->camera = v3d->camera;
 
-			/* not through notifier, listener don't have context
-			 * and non-open screens or spaces need to be updated too */
-			BKE_screen_view3d_main_sync(&bmain->screen, scene);
-			
 			/* notifiers for scene update */
 			WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
 		}
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index dfaf0d5..1665256 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -690,19 +690,21 @@ static int rna_Scene_active_layer_get(PointerRNA *ptr)
 
 static void rna_Scene_view3d_update(Main *bmain, Scene *UNUSED(scene_unused), PointerRNA *ptr)
 {
+	wmWindowManager *wm = bmain->wm.first;
 	Scene *scene = (Scene *)ptr->data;
 
-	BKE_screen_view3d_main_sync(&bmain->screen, scene);
+	WM_windows_scene_data_sync(&wm->windows, scene);
 }
 
-static void rna_Scene_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_Scene_layer_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
 {
-	rna_Scene_view3d_update(bmain, scene, ptr);
 	/* XXX We would need do_time=true here, else we can have update issues like [#36289]...
 	 *     However, this has too much drawbacks (like slower layer switch, undesired updates...).
 	 *     That's TODO for future DAG updates.
 	 */
 	DAG_on_visible_update(bmain, false);
+
+	/* No need to sync scene data here (WM_windows_scene_data_sync), handled through notifier. */
 }
 
 static void rna_Scene_fps_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 30d1fe5..ce91446 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -457,8 +457,10 @@ static void rna_SpaceView3D_camera_update(Main *bmain, Scene *scene, PointerRNA
 {
 	View3D *v3d = (View3D *)(ptr->data);
 	if (v3d->scenelock) {
+		wmWindowManager *wm = bmain->wm.first;
+
 		scene->camera = v3d->camera;
-		BKE_screen_view3d_main_sync(&bmain->screen, scene);
+		WM_windows_scene_data_sync(&wm->windows, scene);
 	}
 }
 
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 5f8902e..2fa4ebb 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -101,6 +101,8 @@ int			WM_window_pixels_x		(struct wmWindow *win);
 int			WM_window_pixels_y		(struct wmWindow *win);
 bool		WM_window_is_fullscreen	(struct wmWindow *win);
 
+void WM_windows_scene_data_sync(const ListBase *win_lb, struct Scene *scene) ATTR_NONNULL();
+
 struct Scene *WM_window_get_active_scene(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 void          WM_window_set_active_scene(struct Main *bmain, struct bContext *C, struct wmWindow *win,
                                          struct Scene *scene_new) ATTR_NONNULL();
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 40741ad..bb74466 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -55,6 +55,7 @@
 #include "BKE_library.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
+#include "BKE_screen.h"
 #include "BKE_workspace.h"
 
 
@@ -1729,6 +1730,20 @@ bool WM_window_is_fullscreen(wmWindow *win)
 	return win->windowstate == GHOST_kWindowStateFullScreen;
 }
 
+/**
+ * Some editor data may need to be synced with scene data (3D View camera and layers).
+ * This function ensures data is synced for editors in visible workspaces and their visible layouts.
+ */
+void WM_windows_scene_data_sync(const ListBase *win_lb, Scene *scene)
+{
+	for (wmWindow *win = win_lb->first; win; win = win->next) {
+		if (WM_window_get_active_scene(win) == scene) {
+			WorkSpace *workspace = win->workspace;
+			ED_workspace_scene_data_sync(workspace, scene);
+		}
+	}
+}
+
 Scene *WM_window_get_active_scene(const wmWindow *win)
 {
 	return win->scene;
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list