Depsgraph: Add additional relations/id update tags

This calls are not strictly speaking needed for the old dependency graph, but
due to more granular nature of upcoming depsgraph more actions requires update
of relations of IDs.

On the one hand this extra tags could be wrapped with if() statements, but on
the other hand it makes sense to keep tag in sync so it's clear if some issue
is caused by missing/extra tag or by depsgraph itself.
This commit is contained in:
Sergey Sharybin 2015-05-12 13:29:00 +05:00
parent 87fd166654
commit 31f0c27ae7
12 changed files with 55 additions and 13 deletions

View File

@ -34,6 +34,7 @@
#include "MEM_guardedalloc.h"
#include "BKE_depsgraph.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
@ -1707,7 +1708,8 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
/* send notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
DAG_relations_tag_update(CTX_data_main(C));
return OPERATOR_FINISHED;
}

View File

@ -73,8 +73,10 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale)
/* tag AnimData for refresh so that other views will update in realtime with these changes */
adt = BKE_animdata_from_id(id);
if (adt)
if (adt) {
adt->recalc |= ADT_RECALC_ANIM;
DAG_id_tag_update(id, OB_RECALC_TIME);
}
/* update data */
fcu = (ale->datatype == ALE_FCURVE) ? ale->key_data : NULL;

View File

@ -42,6 +42,7 @@
#include "DNA_texture_types.h"
#include "BKE_animsys.h"
#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
#include "BKE_context.h"
#include "BKE_report.h"
@ -450,7 +451,7 @@ static int add_driver_button_exec(bContext *C, wmOperator *op)
if (success) {
/* send updates */
UI_context_update_anim_flag(C);
DAG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX
}
@ -504,7 +505,7 @@ static int remove_driver_button_exec(bContext *C, wmOperator *op)
if (success) {
/* send updates */
UI_context_update_anim_flag(C);
DAG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX
}

View File

@ -152,6 +152,10 @@ bAction *verify_adt_action(ID *id, short add)
* to the wrong places
*/
adt->action->idroot = GS(id->name);
/* tag depsgraph to be rebuilt to include time dependency */
/* XXX: we probably should have bmain passed down, but that involves altering too many API's */
DAG_relations_tag_update(G.main);
}
/* return the action */

View File

@ -1260,7 +1260,10 @@ static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op))
/* there's no active constraint now, so make sure this is the case */
BKE_constraints_active_set(&ob->constraints, NULL);
ED_object_constraint_update(ob); /* needed to set the flags on posebones correctly */
/* relatiols */
DAG_relations_tag_update(CTX_data_main(C));
/* notifiers */
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob);

View File

@ -65,6 +65,7 @@
#include "BKE_curve.h"
#include "BKE_effect.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@ -318,7 +319,7 @@ void OBJECT_OT_hide_render_set(wmOperatorType *ot)
* Load EditMode data back into the object,
* optionally freeing the editmode data.
*/
static bool ED_object_editmode_load_ex(Object *obedit, const bool freedata)
static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool freedata)
{
if (obedit == NULL) {
return false;
@ -348,6 +349,11 @@ static bool ED_object_editmode_load_ex(Object *obedit, const bool freedata)
ED_armature_from_edit(obedit->data);
if (freedata)
ED_armature_edit_free(obedit->data);
/* TODO(sergey): Pose channels might have been changed, so need
* to inform dependency graph about this. But is it really the
* best place to do this?
*/
DAG_relations_tag_update(bmain);
}
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
load_editNurb(obedit);
@ -376,7 +382,8 @@ static bool ED_object_editmode_load_ex(Object *obedit, const bool freedata)
bool ED_object_editmode_load(Object *obedit)
{
return ED_object_editmode_load_ex(obedit, false);
/* TODO(sergey): use proper main here? */
return ED_object_editmode_load_ex(G.main, obedit, false);
}
void ED_object_editmode_exit(bContext *C, int flag)
@ -389,7 +396,7 @@ void ED_object_editmode_exit(bContext *C, int flag)
if (flag & EM_WAITCURSOR) waitcursor(1);
if (ED_object_editmode_load_ex(obedit, freedata) == false) {
if (ED_object_editmode_load_ex(CTX_data_main(C), obedit, freedata) == false) {
/* in rare cases (background mode) its possible active object
* is flagged for editmode, without 'obedit' being set [#35489] */
if (UNLIKELY(scene->basact && (scene->basact->object->mode & OB_MODE_EDIT))) {

View File

@ -152,10 +152,10 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
ob->pd = object_add_collision_fields(0);
ob->pd->deflect = 1;
DAG_relations_tag_update(bmain);
}
else if (type == eModifierType_Surface)
DAG_relations_tag_update(bmain);
else if (type == eModifierType_Surface) {
/* pass */
}
else if (type == eModifierType_Multires) {
/* set totlvl from existing MDISPS layer if object already had it */
multiresModifier_set_levels_from_disps((MultiresModifierData *)new_md, ob);
@ -172,6 +172,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
}
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
DAG_relations_tag_update(bmain);
return new_md;
}
@ -319,6 +320,8 @@ static bool object_modifier_remove(Main *bmain, Object *ob, ModifierData *md,
ob->mode &= ~OB_MODE_PARTICLE_EDIT;
}
DAG_relations_tag_update(bmain);
BLI_remlink(&ob->modifiers, md);
modifier_free(md);

View File

@ -123,7 +123,14 @@ void ED_node_tag_update_id(ID *id)
bNodeTree *ntree = node_tree_from_ID(id);
if (id == NULL || ntree == NULL)
return;
/* TODO(sergey): With the new dependency graph it
* should be just enough to ony tag ntree itself,
* all the users of this tree will have update
* flushed from the tree,
*/
DAG_id_tag_update(&ntree->id, 0);
if (ntree->type == NTREE_SHADER) {
DAG_id_tag_update(id, 0);

View File

@ -127,6 +127,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
// Camera
Object *object_camera = BKE_object_add(freestyle_bmain, freestyle_scene, OB_CAMERA, NULL);
DAG_relations_tag_update(freestyle_bmain);
Camera *camera = (Camera *)object_camera->data;
camera->type = CAM_ORTHO;
@ -506,6 +507,7 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
// If still no material, create one
if (!has_mat) {
Material *ma = BKE_material_add(freestyle_bmain, "stroke_material");
DAG_relations_tag_update(freestyle_bmain);
ma->mode |= MA_VERTEXCOLP;
ma->mode |= MA_TRANSP;
ma->mode |= MA_SHLESS;
@ -668,6 +670,7 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
{
#if 0
Object *object_mesh = BKE_object_add(freestyle_bmain, freestyle_scene, OB_MESH);
DAG_relations_tag_update(freestyle_bmain);
#else
Object *object_mesh = NewMesh();
#endif
@ -938,6 +941,7 @@ Object *BlenderStrokeRenderer::NewMesh() const
ob->lay = 1;
base = BKE_scene_base_add(freestyle_scene, ob);
DAG_relations_tag_update(freestyle_bmain);
#if 0
BKE_scene_base_deselect_all(scene);
BKE_scene_base_select(scene, base);

View File

@ -112,6 +112,7 @@ static void rna_AnimData_action_set(PointerRNA *ptr, PointerRNA value)
adt = BKE_animdata_from_id(ownerId);
if (adt) {
adt->recalc |= ADT_RECALC_ANIM;
DAG_id_tag_update(ownerId, OB_RECALC_TIME);
}
}

View File

@ -87,6 +87,13 @@ static void rna_Camera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointer
DAG_id_tag_update(&camera->id, 0);
}
static void rna_Camera_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
Camera *camera = (Camera *)ptr->id.data;
DAG_relations_tag_update(bmain);
DAG_id_tag_update(&camera->id, 0);
}
#else
static void rna_def_camera_stereo_data(BlenderRNA *brna)
@ -356,7 +363,7 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "dof_ob");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "DOF Object", "Use this object to define the depth of field focal point");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dependency_update");
prop = RNA_def_property(srna, "gpu_dof", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "GPUDOFSettings");

View File

@ -949,6 +949,7 @@ static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr)
WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, ptr->id.data);
WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL);
DAG_relations_tag_update(bmain);
}
static char *rna_MaterialSlot_path(PointerRNA *ptr)