From 20220d47e38c4ad22ad89481fd40b804cc2fd1ef Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 21 Feb 2013 19:33:04 +0000 Subject: Dependency Graph: some refactoring which should have no user visible impact besides performance in some cases. * DAG_scene_sort is now removed and replaced by DAG_relations_tag_update in most cases. This will clear the dependency graph, and only rebuild it right before it's needed again when the scene is re-evaluated. This is done because DAG_scene_sort is slow when called many times from python operators. Further the scene argument is not needed because most operations can potentially affect more than the current scene. * DAG_scene_relations_update will now rebuild the dependency graph if it's not there yet, and DAG_scene_relations_rebuild will force a rebuild for the rare cases that need it. * Remove various places where ob->recalc was set manually. This should go through DAG_id_tag_update() in nearly all cases instead since this is now a fast operation. Also removed DAG_ids_flush_update that goes along with such manual tagging of ob->recalc. --- source/blender/blenkernel/intern/object.c | 35 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'source/blender/blenkernel/intern/object.c') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 58b47398a7d..95b1809bbae 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -74,6 +74,7 @@ #include "BKE_bullet.h" #include "BKE_colortools.h" #include "BKE_deform.h" +#include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" #include "BKE_animsys.h" #include "BKE_anim.h" @@ -406,7 +407,8 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec if (*obpoin == unlinkOb) { *obpoin = NULL; - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; // XXX: should this just be OB_RECALC_DATA? + // XXX: should this just be OB_RECALC_DATA? + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } } @@ -440,14 +442,14 @@ void BKE_object_unlink(Object *ob) obt->proxy = NULL; if (obt->proxy_from == ob) { obt->proxy_from = NULL; - obt->recalc |= OB_RECALC_OB; + DAG_id_tag_update(&obt->id, OB_RECALC_OB); } if (obt->proxy_group == ob) obt->proxy_group = NULL; if (obt->parent == ob) { obt->parent = NULL; - obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&obt->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } modifiers_foreachObjectLink(obt, unlink_object__unlinkModifierLinks, ob); @@ -457,15 +459,15 @@ void BKE_object_unlink(Object *ob) if (cu->bevobj == ob) { cu->bevobj = NULL; - obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&obt->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } if (cu->taperobj == ob) { cu->taperobj = NULL; - obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&obt->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } if (cu->textoncurve == ob) { cu->textoncurve = NULL; - obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&obt->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } } else if (obt->type == OB_ARMATURE && obt->pose) { @@ -483,7 +485,7 @@ void BKE_object_unlink(Object *ob) if (ct->tar == ob) { ct->tar = NULL; ct->subtarget[0] = '\0'; - obt->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&obt->id, OB_RECALC_DATA); } } @@ -497,7 +499,7 @@ void BKE_object_unlink(Object *ob) } else if (ELEM(OB_MBALL, ob->type, obt->type)) { if (BKE_mball_is_basis_for(obt, ob)) - obt->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&obt->id, OB_RECALC_DATA); } sca_remove_ob_poin(obt, ob); @@ -514,7 +516,7 @@ void BKE_object_unlink(Object *ob) if (ct->tar == ob) { ct->tar = NULL; ct->subtarget[0] = '\0'; - obt->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&obt->id, OB_RECALC_DATA); } } @@ -526,12 +528,12 @@ void BKE_object_unlink(Object *ob) /* object is deflector or field */ if (ob->pd) { if (obt->soft) - obt->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&obt->id, OB_RECALC_DATA); /* cloth */ for (md = obt->modifiers.first; md; md = md->next) if (md->type == eModifierType_Cloth) - obt->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&obt->id, OB_RECALC_DATA); } /* strips */ @@ -560,14 +562,14 @@ void BKE_object_unlink(Object *ob) for (; pt; pt = pt->next) { if (pt->ob == ob) { pt->ob = NULL; - obt->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&obt->id, OB_RECALC_DATA); break; } } if (tpsys->target_ob == ob) { tpsys->target_ob = NULL; - obt->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&obt->id, OB_RECALC_DATA); } if (tpsys->part->dup_ob == ob) @@ -602,7 +604,7 @@ void BKE_object_unlink(Object *ob) } } if (ob->pd) - obt->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&obt->id, OB_RECALC_DATA); } obt = obt->id.next; @@ -970,7 +972,7 @@ Object *BKE_object_add(struct Scene *scene, int type) base = BKE_scene_base_add(scene, ob); BKE_scene_base_deselect_all(scene); BKE_scene_base_select(scene, base); - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); return ob; } @@ -1480,7 +1482,8 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob) ob->proxy_group = gob; id_lib_extern(&target->id); - ob->recalc = target->recalc = OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + DAG_id_tag_update(&target->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* copy transform * - gob means this proxy comes from a group, just apply the matrix -- cgit v1.2.3