From 2e0017efd4d6858a1d4d78dc5e72fdd2f1aafaa9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Feb 2013 03:57:20 +0000 Subject: code cleanup: change order of args in void BKE_object_where_is_calc_time_ex() so extra arg is at the end (loose convention for *_ex() funcs). also some style cleanup. --- source/blender/blenkernel/intern/object.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 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 117e9fe280c..ef3c98ee3f4 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2118,7 +2118,8 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[ } /* note, scene is the active scene while actual_scene is the scene the object resides in */ -void BKE_object_where_is_calc_time_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob, float ctime) +void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime, + RigidBodyWorld *rbw) { if (ob == NULL) return; @@ -2163,7 +2164,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, RigidBodyWorld *rbw, Object void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) { - BKE_object_where_is_calc_time_ex(scene, NULL, ob, ctime); + BKE_object_where_is_calc_time_ex(scene, ob, ctime, NULL); } /* get object transformation matrix without recalculating dependencies and @@ -2189,17 +2190,17 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4]) void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob) { - BKE_object_where_is_calc_time_ex(scene, rbw, ob, BKE_scene_frame_get(scene)); + BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), rbw); } void BKE_object_where_is_calc(Scene *scene, Object *ob) { - BKE_object_where_is_calc_time_ex(scene, NULL, ob, BKE_scene_frame_get(scene)); + BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), NULL); } -void BKE_object_where_is_calc_simul(Scene *scene, Object *ob) /* was written for the old game engine (until 2.04) */ /* It seems that this function is only called * for a lamp that is the child of another object */ +void BKE_object_where_is_calc_simul(Scene *scene, Object *ob) { Object *par; float *fp1, *fp2; -- cgit v1.2.3 From 00f48914f32f9df4266ff73550a0f80a085baa32 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Feb 2013 04:35:50 +0000 Subject: code cleanup: missed r54603, arg reordering. --- source/blender/blenkernel/intern/object.c | 5 +++-- 1 file changed, 3 insertions(+), 2 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 ef3c98ee3f4..b810aa89257 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2631,7 +2631,8 @@ int BKE_object_parent_loop_check(const Object *par, const Object *ob) /* the main object update call, for object matrix, constraints, keys and displist (modifiers) */ /* requires flags to be set! */ /* Ideally we shouldn't have to pass the rigid body world, but need bigger restructuring to avoid id */ -void BKE_object_handle_update_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob) +void BKE_object_handle_update_ex(Scene *scene, Object *ob, + RigidBodyWorld *rbw) { if (ob->recalc & OB_RECALC_ALL) { /* speed optimization for animation lookups */ @@ -2833,7 +2834,7 @@ void BKE_object_handle_update_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob) */ void BKE_object_handle_update(Scene *scene, Object *ob) { - BKE_object_handle_update_ex(scene, NULL, ob); + BKE_object_handle_update_ex(scene, ob, NULL); } void BKE_object_sculpt_modifiers_changed(Object *ob) -- cgit v1.2.3 From 3e0725854c091c48695bf89da66e927aad611574 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Sun, 17 Feb 2013 19:38:08 +0000 Subject: rigidbody: Fix regression in background scene fix Since BKE_object_where_is_calc() might be called outside of scene_update_tagged_recursive(), we need to fall back to the scene's rigid body world. --- source/blender/blenkernel/intern/object.c | 2 ++ 1 file changed, 2 insertions(+) (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 b810aa89257..58b47398a7d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2145,6 +2145,8 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime, BKE_object_to_mat4(ob, ob->obmat); } + /* try to fall back to the scene rigid body world if none given */ + rbw = rbw ? rbw : scene->rigidbody_world; /* read values pushed into RBO from sim/cache... */ BKE_rigidbody_sync_transforms(rbw, ob, ctime); -- cgit v1.2.3 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