diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index f78a957cbab..14251fb1762 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -112,7 +112,7 @@ void DAG_scene_update_flags(struct Main *bmain, struct Scene *sce, unsigned int /* flushes all recalc flags in objects down the dependency tree */ void DAG_scene_flush_update(struct Main *bmain, struct Scene *sce, unsigned int lay, const short do_time); /* tag objects for update on file load */ -void DAG_on_load_update(struct Main *bmain, const short do_time); +void DAG_on_visible_update(struct Main *bmain, const short do_time); /* when setting manual RECALC flags, call this afterwards */ void DAG_ids_flush_update(struct Main *bmain, int time); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 9fb36d8f6b7..d1a181046a6 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -466,7 +466,7 @@ static int read_undosave(bContext *C, UndoElem *uel) if(success) { /* important not to update time here, else non keyed tranforms are lost */ - DAG_on_load_update(G.main, FALSE); + DAG_on_visible_update(G.main, FALSE); } return success; diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index ec75bfb1818..ff49c64ebf4 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2270,7 +2270,7 @@ void DAG_ids_flush_update(Main *bmain, int time) DAG_scene_flush_update(bmain, sce, lay, time); } -void DAG_on_load_update(Main *bmain, const short do_time) +void DAG_on_visible_update(Main *bmain, const short do_time) { Scene *scene; Base *base; @@ -2295,7 +2295,7 @@ void DAG_on_load_update(Main *bmain, const short do_time) node= (sce_iter->theDag)? dag_get_node(sce_iter->theDag, ob): NULL; oblay= (node)? node->lay: ob->lay; - if(oblay & lay) { + if((oblay & lay) & ~scene->lay_updated) { if(ELEM6(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) ob->recalc |= OB_RECALC_DATA; if(ob->dup_group) @@ -2318,6 +2318,7 @@ void DAG_on_load_update(Main *bmain, const short do_time) /* now tag update flags, to ensure deformers get calculated on redraw */ DAG_scene_update_flags(bmain, scene, lay, do_time); + scene->lay_updated |= lay; } } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 98a83e22ee5..22ce3bd590a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4470,6 +4470,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->stats= NULL; sce->fps_info= NULL; sce->customdata_mask_modal= 0; + sce->lay_updated = 0; sound_create_scene(sce); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index cc35658b63f..bd2cce041dd 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -783,9 +783,9 @@ typedef struct Scene { unsigned int lay; /* bitflags for layer visibility */ int layact; /* active layer */ + unsigned int lay_updated; /* runtime flag, has layer ever been updated since load? */ unsigned int customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by object_handle_update() */ unsigned int customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */ - unsigned int pad4; short flag; /* various settings */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index bfaa81f631e..812e991831b 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -319,6 +319,12 @@ static void rna_Scene_view3d_update(Main *bmain, Scene *unused, PointerRNA *ptr) BKE_screen_view3d_main_sync(&bmain->screen, scene); } +static void rna_Scene_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + rna_Scene_view3d_update(bmain, scene, ptr); + DAG_on_visible_update(bmain, FALSE); +} + static void rna_Scene_framelen_update(Main *bmain, Scene *scene, PointerRNA *ptr) { scene->r.framelen= (float)scene->r.framapto/(float)scene->r.images; @@ -3177,7 +3183,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_array(prop, 20); RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_layer_set"); RNA_def_property_ui_text(prop, "Layers", "Layers visible when rendering the scene"); - RNA_def_property_update(prop, NC_SCENE|ND_LAYER, "rna_Scene_view3d_update"); + RNA_def_property_update(prop, NC_SCENE|ND_LAYER, "rna_Scene_layer_update"); /* Frame Range Stuff */ prop= RNA_def_property(srna, "frame_current", PROP_INT, PROP_TIME); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 6b0ae7eec80..54b2dc1dd0f 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -314,6 +314,11 @@ static void rna_SpaceView3D_layer_set(PointerRNA *ptr, const int *values) v3d->lay= ED_view3d_scene_layer_set(v3d->lay, values, &v3d->layact); } +static void rna_SpaceView3D_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + DAG_on_visible_update(bmain, FALSE); +} + static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr) { View3D *v3d= (View3D*)(ptr->data); @@ -1275,7 +1280,7 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_array(prop, 20); RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceView3D_layer_set"); RNA_def_property_ui_text(prop, "Visible Layers", "Layers visible in this 3D View"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_SpaceView3D_layer_update"); prop= RNA_def_property(srna, "layers_used", PROP_BOOLEAN, PROP_LAYER_MEMBER); RNA_def_property_boolean_sdna(prop, NULL, "lay_used", 1); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ebf3e856241..35bb874ff71 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -329,7 +329,7 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports) CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); ED_editors_init(C); - DAG_on_load_update(CTX_data_main(C), TRUE); + DAG_on_visible_update(CTX_data_main(C), TRUE); #ifdef WITH_PYTHON /* run any texts that were loaded in and flagged as modules */ @@ -433,7 +433,7 @@ int WM_read_homefile(bContext *C, ReportList *reports, short from_memory) BKE_write_undo(C, "original"); /* save current state */ ED_editors_init(C); - DAG_on_load_update(CTX_data_main(C), TRUE); + DAG_on_visible_update(CTX_data_main(C), TRUE); #ifdef WITH_PYTHON if(CTX_py_init_get(C)) { diff --git a/source/creator/creator.c b/source/creator/creator.c index 6c2ba5bc674..2480f8b544b 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -72,7 +72,7 @@ #include "BKE_utildefines.h" #include "BKE_blender.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" // for DAG_on_load_update +#include "BKE_depsgraph.h" // for DAG_on_visible_update #include "BKE_font.h" #include "BKE_global.h" #include "BKE_main.h" @@ -993,7 +993,7 @@ static int load_file(int UNUSED(argc), const char **argv, void *data) G.relbase_valid = 1; if (CTX_wm_manager(C) == NULL) CTX_wm_manager_set(C, wm); /* reset wm */ - DAG_on_load_update(CTX_data_main(C), TRUE); + DAG_on_visible_update(CTX_data_main(C), TRUE); } /* WM_read_file() runs normally but since we're in background mode do here */