Fix #26573, #26574 and #26551: objects on layers not visible on load or undo

restore, would not get their dependencies updated when they became visible.
It happend with a shrinkwrap modifier in these reports, but could happen with
other modifiers too.

Now we keep track of which layers have ever been updated since load, and tag
objects on them to be recalculated when they become visible.
This commit is contained in:
Brecht Van Lommel 2011-03-23 14:06:44 +00:00
parent 72fe34efb2
commit edc5cf1f96
9 changed files with 24 additions and 11 deletions

@ -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);

@ -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;

@ -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;
}
}

@ -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);

@ -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 */

@ -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);

@ -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);

@ -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)) {

@ -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 */