[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53082] trunk/blender/source/blender: Bugfix 33560

Ton Roosendaal ton at blender.org
Mon Dec 17 13:03:34 CET 2012


Revision: 53082
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53082
Author:   ton
Date:     2012-12-17 12:03:31 +0000 (Mon, 17 Dec 2012)
Log Message:
-----------
Bugfix 33560

Setup: 2 windows, 2 scenes, shared objects and groups.

Errors:
- editing in 1 window, didn't correctly update shared stuff in the other
  (like child - parent relations)
- deleting group members in 1 scene, could crash the other.

Fixes:
- On load, only a depsgraph was created for the "active" scene. Now it makes
  depsgraphs for all visible scenes.
- "DAG ID flushes" were only working on active scenes too, they now take
  the other visible into account as well.
- Delete object - notifier was only sent to the active scene.

All in all it's a real depsgraph fix (for once!) :) Using multi-window and
multi-scene setups now is more useful.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/blender.c
    trunk/blender/source/blender/blenkernel/intern/depsgraph.c
    trunk/blender/source/blender/editors/object/object_add.c
    trunk/blender/source/blender/editors/space_view3d/space_view3d.c

Modified: trunk/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/blender.c	2012-12-17 11:26:41 UTC (rev 53081)
+++ trunk/blender/source/blender/blenkernel/intern/blender.c	2012-12-17 12:03:31 UTC (rev 53082)
@@ -54,6 +54,7 @@
 #include "DNA_screen_types.h"
 #include "DNA_sequence_types.h"
 #include "DNA_sound_types.h"
+#include "DNA_windowmanager_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_dynstr.h"
@@ -334,6 +335,20 @@
 	}
 	
 	/* baseflags, groups, make depsgraph, etc */
+	/* first handle case if other windows have different scenes visible */
+	if (mode == 0) {
+		wmWindowManager *wm = G.main->wm.first;
+		
+		if (wm) {
+			wmWindow *win;
+			
+			for (win = wm->windows.first; win; win = win->next) {
+				if (win->screen && win->screen->scene) /* zealous check... */
+					if (win->screen->scene != CTX_data_scene(C))
+						BKE_scene_set_background(G.main, win->screen->scene);
+			}
+		}
+	}
 	BKE_scene_set_background(G.main, CTX_data_scene(C));
 
 	if (mode != 'u') {
@@ -341,8 +356,7 @@
 	}
 
 	MEM_freeN(bfd);
-	
-	(void)curscene; /* quiet warning */
+
 }
 
 static int handle_subversion_warning(Main *main, ReportList *reports)

Modified: trunk/blender/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/depsgraph.c	2012-12-17 11:26:41 UTC (rev 53081)
+++ trunk/blender/source/blender/blenkernel/intern/depsgraph.c	2012-12-17 12:03:31 UTC (rev 53082)
@@ -2482,30 +2482,51 @@
 	
 }
 
-static void dag_current_scene_layers(Main *bmain, Scene **sce, unsigned int *lay)
+/* struct returned by DagSceneLayer */
+typedef struct DagSceneLayer {
+	struct DagSceneLayer *next, *prev;
+	Scene *scene;
+	unsigned int layer;
+} DagSceneLayer;
+
+/* returns visible scenes with valid DAG */
+static void dag_current_scene_layers(Main *bmain, ListBase *lb)
 {
 	wmWindowManager *wm;
 	wmWindow *win;
+	
+	lb->first = lb->last = NULL;
 
-	/* only one scene supported currently, making more scenes work
-	 * correctly requires changes beyond just the dependency graph */
+	/* if we have a windowmanager, look into windows */
+	if ((wm = bmain->wm.first)) {
+		
+		flag_listbase_ids(&bmain->scene, LIB_DOIT, 1);
 
-	*sce = NULL;
-	*lay = 0;
-
-	if ((wm = bmain->wm.first)) {
-		/* if we have a windowmanager, look into windows */
 		for (win = wm->windows.first; win; win = win->next) {
-			if (win->screen) {
-				if (*sce == NULL) *sce = win->screen->scene;
-				*lay |= BKE_screen_visible_layers(win->screen, win->screen->scene);
+			if (win->screen && win->screen->scene->theDag) {
+				Scene *scene = win->screen->scene;
+				
+				if (scene->id.flag & LIB_DOIT) {
+					DagSceneLayer *dsl = MEM_mallocN(sizeof(DagSceneLayer), "dag scene layer");
+					
+					BLI_addtail(lb, dsl);
+					
+					dsl->scene = scene;
+					dsl->layer = BKE_screen_visible_layers(win->screen, scene);
+					
+					scene->id.flag &= ~LIB_DOIT;
+				}
 			}
 		}
 	}
 	else {
 		/* if not, use the first sce */
-		*sce = bmain->scene.first;
-		if (*sce) *lay = (*sce)->lay;
+		DagSceneLayer *dsl = MEM_mallocN(sizeof(DagSceneLayer), "dag scene layer");
+		
+		BLI_addtail(lb, dsl);
+		
+		dsl->scene = bmain->scene.first;
+		dsl->layer = dsl->scene->lay;
 
 		/* XXX for background mode, we should get the scene
 		 * from somewhere, for the -S option, but it's in
@@ -2515,29 +2536,36 @@
 
 void DAG_ids_flush_update(Main *bmain, int time)
 {
-	Scene *sce;
-	unsigned int lay;
+	ListBase listbase;
+	DagSceneLayer *dsl;
+	
+	/* get list of visible scenes and layers */
+	dag_current_scene_layers(bmain, &listbase);
 
-	dag_current_scene_layers(bmain, &sce, &lay);
-
-	if (sce)
-		DAG_scene_flush_update(bmain, sce, lay, time);
+	for (dsl = listbase.first; dsl; dsl = dsl->next)
+		DAG_scene_flush_update(bmain, dsl->scene, dsl->layer, time);
+	
+	BLI_freelistN(&listbase);
 }
 
 void DAG_on_visible_update(Main *bmain, const short do_time)
 {
-	Scene *scene;
-	Base *base;
-	Object *ob;
-	Group *group;
-	GroupObject *go;
-	DagNode *node;
-	unsigned int lay, oblay;
-
-	dag_current_scene_layers(bmain, &scene, &lay);
-
-	if (scene && scene->theDag) {
+	ListBase listbase;
+	DagSceneLayer *dsl;
+	
+	/* get list of visible scenes and layers */
+	dag_current_scene_layers(bmain, &listbase);
+	
+	for (dsl = listbase.first; dsl; dsl = dsl->next) {
+		Scene *scene = dsl->scene;
 		Scene *sce_iter;
+		Base *base;
+		Object *ob;
+		Group *group;
+		GroupObject *go;
+		DagNode *node;
+		unsigned int lay = dsl->layer, oblay;
+	
 		/* derivedmeshes and displists are not saved to file so need to be
 		 * remade, tag them so they get remade in the scene update loop,
 		 * note armature poses or object matrices are preserved and do not
@@ -2574,6 +2602,8 @@
 		DAG_scene_update_flags(bmain, scene, lay, do_time);
 		scene->lay_updated |= lay;
 	}
+	
+	BLI_freelistN(&listbase);
 
 	/* hack to get objects updating on layer changes */
 	DAG_id_type_tag(bmain, ID_OB);
@@ -2758,14 +2788,15 @@
 
 void DAG_ids_flush_tagged(Main *bmain)
 {
+	ListBase listbase;
+	DagSceneLayer *dsl;
 	ListBase *lbarray[MAX_LIBARRAY];
-	Scene *sce;
-	unsigned int lay;
 	int a, do_flush = FALSE;
+	
+	/* get list of visible scenes and layers */
+	dag_current_scene_layers(bmain, &listbase);
 
-	dag_current_scene_layers(bmain, &sce, &lay);
-
-	if (!sce || !sce->theDag)
+	if (listbase.first == NULL)
 		return;
 
 	/* loop over all ID types */
@@ -2780,7 +2811,10 @@
 		if (id && bmain->id_tag_update[id->name[0]]) {
 			for (; id; id = id->next) {
 				if (id->flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA)) {
-					dag_id_flush_update(sce, id);
+					
+					for (dsl = listbase.first; dsl; dsl = dsl->next)
+						dag_id_flush_update(dsl->scene, id);
+					
 					do_flush = TRUE;
 				}
 			}
@@ -2788,8 +2822,12 @@
 	}
 
 	/* flush changes to other objects */
-	if (do_flush)
-		DAG_scene_flush_update(bmain, sce, lay, 0);
+	if (do_flush) {
+		for (dsl = listbase.first; dsl; dsl = dsl->next)
+			DAG_scene_flush_update(bmain, dsl->scene, dsl->layer, 0);
+	}
+	
+	BLI_freelistN(&listbase);
 }
 
 void DAG_ids_check_recalc(Main *bmain, Scene *scene, int time)

Modified: trunk/blender/source/blender/editors/object/object_add.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_add.c	2012-12-17 11:26:41 UTC (rev 53081)
+++ trunk/blender/source/blender/editors/object/object_add.c	2012-12-17 12:03:31 UTC (rev 53082)
@@ -936,6 +936,8 @@
 {
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
+	wmWindowManager *wm = CTX_wm_manager(C);
+	wmWindow *win;
 	const short use_global = RNA_boolean_get(op->ptr, "use_global");
 
 	if (CTX_data_edit_object(C)) 
@@ -967,12 +969,22 @@
 	}
 	CTX_DATA_END;
 
-	DAG_scene_sort(bmain, scene);
+	/* delete has to handle all open scenes */
+	flag_listbase_ids(&bmain->scene, LIB_DOIT, 1);
+	for (win = wm->windows.first; win; win = win->next) {
+		scene = win->screen->scene;
+		
+		if (scene->id.flag & LIB_DOIT) {
+			scene->id.flag &= ~LIB_DOIT;
+			
+			DAG_scene_sort(bmain, scene);
+
+			WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
+			WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
+		}
+	}
 	DAG_ids_flush_update(bmain, 0);
 
-	WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
-	WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
-
 	return OPERATOR_FINISHED;
 }
 

Modified: trunk/blender/source/blender/editors/space_view3d/space_view3d.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/space_view3d.c	2012-12-17 11:26:41 UTC (rev 53081)
+++ trunk/blender/source/blender/editors/space_view3d/space_view3d.c	2012-12-17 12:03:31 UTC (rev 53082)
@@ -632,8 +632,7 @@
 
 static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
 {
-	bScreen *sc;
-
+	
 	/* context changes */
 	switch (wmn->category) {
 		case NC_ANIMATION:
@@ -656,7 +655,8 @@
 		case NC_SCENE:
 			switch (wmn->data) {
 				case ND_LAYER_CONTENT:
-					view3d_recalc_used_layers(ar, wmn, wmn->reference);
+					if (wmn->reference)
+						view3d_recalc_used_layers(ar, wmn, wmn->reference);
 					ED_region_tag_redraw(ar);
 					break;
 				case ND_FRAME:
@@ -784,8 +784,10 @@
 				case ND_SCREENSET:
 					/* screen was changed, need to update used layers due to NC_SCENE|ND_LAYER_CONTENT */
 					/* updates used layers only for View3D in active screen */
-					sc = wmn->reference;
-					view3d_recalc_used_layers(ar, wmn, sc->scene);
+					if (wmn->reference) {
+						bScreen *sc = wmn->reference;
+						view3d_recalc_used_layers(ar, wmn, sc->scene);
+					}
 					ED_region_tag_redraw(ar);
 					break;
 			}




More information about the Bf-blender-cvs mailing list