diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-29 18:12:39 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-29 18:12:39 +0300 |
commit | dbde3c78f8c65800233d6b51681deeaf3e4fa562 (patch) | |
tree | 72fdcca1af33b4238edb4a36544a19b44a5f4047 | |
parent | 1f9387ef917b4e8977a0eef56af272223e50fb63 (diff) |
Cleanup: Make object_handle_update easier to follow
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 127 |
1 files changed, 69 insertions, 58 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f231f8f61c9..6276f12acfb 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2586,6 +2586,28 @@ bool BKE_object_parent_loop_check(const Object *par, const Object *ob) return BKE_object_parent_loop_check(par->parent, ob); } +static void object_handle_update_proxy(EvaluationContext *eval_ctx, + Scene *scene, + Object *object, + const bool do_proxy_update) +{ + /* The case when this is a group proxy, object_update is called in group.c */ + if (object->proxy == NULL) { + return; + } + /* set pointer in library proxy target, for copying, but restore it */ + object->proxy->proxy_from = object; + // printf("set proxy pointer for later group stuff %s\n", ob->id.name); + + /* the no-group proxy case, we call update */ + if (object->proxy_group == NULL) { + if (do_proxy_update) { + // printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name); + BKE_object_handle_update(eval_ctx, scene, object->proxy); + } + } +} + /* proxy rule: lib_object->proxy_from == the one we borrow from, only set temporal and cleared here */ /* local_object->proxy == pointer to library object, saved in files and read */ @@ -2599,75 +2621,64 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx, RigidBodyWorld *rbw, const bool do_proxy_update) { - if (ob->recalc & OB_RECALC_ALL) { - /* speed optimization for animation lookups */ - if (ob->pose) { - BKE_pose_channels_hash_make(ob->pose); - if (ob->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) { - BKE_pose_update_constraint_flags(ob->pose); - } + if ((ob->recalc & OB_RECALC_ALL) == 0) { + object_handle_update_proxy(eval_ctx, scene, ob, do_proxy_update); + return; + } + /* Speed optimization for animation lookups. */ + if (ob->pose != NULL) { + BKE_pose_channels_hash_make(ob->pose); + if (ob->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) { + BKE_pose_update_constraint_flags(ob->pose); } - - if (ob->recalc & OB_RECALC_DATA) { - if (ob->type == OB_ARMATURE) { - /* this happens for reading old files and to match library armatures - * with poses we do it ahead of BKE_object_where_is_calc to ensure animation - * is evaluated on the rebuilt pose, otherwise we get incorrect poses - * on file load */ - if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC)) - BKE_pose_rebuild(ob, ob->data); - } + } + if (ob->recalc & OB_RECALC_DATA) { + if (ob->type == OB_ARMATURE) { + /* this happens for reading old files and to match library armatures + * with poses we do it ahead of BKE_object_where_is_calc to ensure animation + * is evaluated on the rebuilt pose, otherwise we get incorrect poses + * on file load */ + if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC)) + BKE_pose_rebuild(ob, ob->data); } - - /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers, - * which is only in BKE_object_where_is_calc now */ - /* XXX: should this case be OB_RECALC_OB instead? */ - if (ob->recalc & OB_RECALC_ALL) { - - if (G.debug & G_DEBUG_DEPSGRAPH) - printf("recalcob %s\n", ob->id.name + 2); - - /* handle proxy copy for target */ - if (ID_IS_LINKED(ob) && ob->proxy_from) { - // printf("ob proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name); - if (ob->proxy_from->proxy_group) { /* transform proxy into group space */ - Object *obg = ob->proxy_from->proxy_group; - float imat[4][4]; - invert_m4_m4(imat, obg->obmat); - mul_m4_m4m4(ob->obmat, imat, ob->proxy_from->obmat); - if (obg->dup_group) { /* should always be true */ - add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs); - } + } + /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers, + * which is only in BKE_object_where_is_calc now */ + /* XXX: should this case be OB_RECALC_OB instead? */ + if (ob->recalc & OB_RECALC_ALL) { + if (G.debug & G_DEBUG_DEPSGRAPH) { + printf("recalcob %s\n", ob->id.name + 2); + } + /* Handle proxy copy for target. */ + if (ID_IS_LINKED(ob) && ob->proxy_from) { + // printf("ob proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name); + if (ob->proxy_from->proxy_group) { /* transform proxy into group space */ + Object *obg = ob->proxy_from->proxy_group; + float imat[4][4]; + invert_m4_m4(imat, obg->obmat); + mul_m4_m4m4(ob->obmat, imat, ob->proxy_from->obmat); + if (obg->dup_group) { /* should always be true */ + add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs); } - else - copy_m4_m4(ob->obmat, ob->proxy_from->obmat); } - else - BKE_object_where_is_calc_ex(scene, rbw, ob, NULL); + else { + copy_m4_m4(ob->obmat, ob->proxy_from->obmat); + } } - - if (ob->recalc & OB_RECALC_DATA) { - BKE_object_handle_data_update(eval_ctx, scene, ob); + else { + BKE_object_where_is_calc_ex(scene, rbw, ob, NULL); } + } - ob->recalc &= ~OB_RECALC_ALL; + if (ob->recalc & OB_RECALC_DATA) { + BKE_object_handle_data_update(eval_ctx, scene, ob); } - /* the case when this is a group proxy, object_update is called in group.c */ - if (ob->proxy) { - /* set pointer in library proxy target, for copying, but restore it */ - ob->proxy->proxy_from = ob; - // printf("set proxy pointer for later group stuff %s\n", ob->id.name); + ob->recalc &= ~OB_RECALC_ALL; - /* the no-group proxy case, we call update */ - if (ob->proxy_group == NULL) { - if (do_proxy_update) { - // printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name); - BKE_object_handle_update(eval_ctx, scene, ob->proxy); - } - } - } + object_handle_update_proxy(eval_ctx, scene, ob, do_proxy_update); } + /* WARNING: "scene" here may not be the scene object actually resides in. * When dealing with background-sets, "scene" is actually the active scene. * e.g. "scene" <-- set 1 <-- set 2 ("ob" lives here) <-- set 3 <-- ... <-- set n |