diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-29 18:32:50 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-29 18:32:50 +0300 |
commit | 0439733cf8963dec13654c5b55556d8b11639d9c (patch) | |
tree | 097b6a45db1e1a8ff5a3ce2b0a295b78d8207e19 | |
parent | aa2ecbf35b26edd22deb1595487ef59035d1a16c (diff) | |
parent | 1136dee23273830ce16a624526b45d145a7e4020 (diff) |
Merge branch 'master' into blender2.8
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 116 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object_update.c | 42 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_nodes.cc | 2 |
4 files changed, 81 insertions, 85 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index e446451d999..2b183906f57 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -184,7 +184,6 @@ void BKE_object_tfm_protected_restore(struct Object *ob, /* Dependency graph evaluation callbacks. */ void BKE_object_eval_local_transform(const struct EvaluationContext *eval_ctx, - struct Scene *scene, struct Object *ob); void BKE_object_eval_parent(const struct EvaluationContext *eval_ctx, struct Scene *scene, @@ -194,8 +193,9 @@ void BKE_object_eval_constraints(const struct EvaluationContext *eval_ctx, struct Object *ob); void BKE_object_eval_done(const struct EvaluationContext *eval_ctx, struct Object *ob); +bool BKE_object_eval_proxy_copy(const struct EvaluationContext *eval_ct, + struct Object *object); void BKE_object_eval_uber_transform(const struct EvaluationContext *eval_ctx, - struct Scene *scene, struct Object *ob); void BKE_object_eval_uber_data(const struct EvaluationContext *eval_ctx, struct Scene *scene, @@ -205,7 +205,7 @@ void BKE_object_eval_cloth(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *object); -void BKE_object_eval_transform_all(struct EvaluationContext *eval_ctx, +void BKE_object_eval_transform_all(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *object); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 3795e1bbf0e..f58a0d76b6a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2664,6 +2664,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(const 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 */ @@ -2677,75 +2699,49 @@ void BKE_object_handle_update_ex(const 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); - } - } - else - copy_m4_m4(ob->obmat, ob->proxy_from->obmat); - } - else - BKE_object_where_is_calc_ex(eval_ctx, scene, rbw, ob, NULL); + } + /* 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); } - - if (ob->recalc & OB_RECALC_DATA) { - BKE_object_handle_data_update(eval_ctx, scene, ob); + /* Handle proxy copy for target. */ + if (!BKE_object_eval_proxy_copy(eval_ctx, ob)) { + BKE_object_where_is_calc_ex(eval_ctx, 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 diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 4d2cf0c5dc6..f5f521e119d 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -68,7 +68,6 @@ #define DEBUG_PRINT if (G.debug & G_DEBUG_DEPSGRAPH) printf void BKE_object_eval_local_transform(const EvaluationContext *UNUSED(eval_ctx), - Scene *UNUSED(scene), Object *ob) { DEBUG_PRINT("%s on %s (%p)\n", __func__, ob->id.name, ob); @@ -273,33 +272,36 @@ void BKE_object_handle_data_update( /* quick cache removed */ } -void BKE_object_eval_uber_transform(const EvaluationContext *UNUSED(eval_ctx), - Scene *UNUSED(scene), - Object *ob) +bool BKE_object_eval_proxy_copy(const EvaluationContext *UNUSED(eval_ctx), + Object *object) { - /* TODO(sergey): Currently it's a duplicate of logic in BKE_object_handle_update_ex(). */ - // XXX: it's almost redundant now... - /* Handle proxy copy for target, */ - if (ID_IS_LINKED(ob) && ob->proxy_from) { - if (ob->proxy_from->proxy_group) { + if (ID_IS_LINKED(object) && object->proxy_from) { + if (object->proxy_from->proxy_group) { /* Transform proxy into group space. */ - Object *obg = ob->proxy_from->proxy_group; + Object *obg = object->proxy_from->proxy_group; float imat[4][4]; invert_m4_m4(imat, obg->obmat); - mul_m4_m4m4(ob->obmat, imat, ob->proxy_from->obmat); + mul_m4_m4m4(object->obmat, imat, object->proxy_from->obmat); /* Should always be true. */ if (obg->dup_group) { - add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs); + add_v3_v3(object->obmat[3], obg->dup_group->dupli_ofs); } } - else - copy_m4_m4(ob->obmat, ob->proxy_from->obmat); + else { + copy_m4_m4(object->obmat, object->proxy_from->obmat); + } + return true; } + return false; +} - ob->recalc &= ~(OB_RECALC_OB | OB_RECALC_TIME); - if (ob->data == NULL) { - ob->recalc &= ~OB_RECALC_DATA; +void BKE_object_eval_uber_transform(const EvaluationContext *eval_ctx, Object *object) +{ + BKE_object_eval_proxy_copy(eval_ctx, object); + object->recalc &= ~(OB_RECALC_OB | OB_RECALC_TIME); + if (object->data == NULL) { + object->recalc &= ~OB_RECALC_DATA; } } @@ -391,19 +393,19 @@ void BKE_object_eval_cloth(const EvaluationContext *UNUSED(eval_ctx), BKE_ptcache_object_reset(scene, object, PTCACHE_RESET_DEPSGRAPH); } -void BKE_object_eval_transform_all(EvaluationContext *eval_ctx, +void BKE_object_eval_transform_all(const EvaluationContext *eval_ctx, Scene *scene, Object *object) { /* This mimics full transform update chain from new depsgraph. */ - BKE_object_eval_local_transform(eval_ctx, scene, object); + BKE_object_eval_local_transform(eval_ctx, object); if (object->parent != NULL) { BKE_object_eval_parent(eval_ctx, scene, object); } if (!BLI_listbase_is_empty(&object->constraints)) { BKE_object_eval_constraints(eval_ctx, scene, object); } - BKE_object_eval_uber_transform(eval_ctx, scene, object); + BKE_object_eval_uber_transform(eval_ctx, object); BKE_object_eval_done(eval_ctx, object); } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index a2a0f633fd9..121db9a4c5f 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -583,7 +583,6 @@ void DepsgraphNodeBuilder::build_object_transform(Object *object) op_node = add_operation_node(&object->id, DEG_NODE_TYPE_TRANSFORM, function_bind(BKE_object_eval_local_transform, _1, - scene_cow, ob_cow), DEG_OPCODE_TRANSFORM_LOCAL); op_node->set_as_entry(); @@ -607,7 +606,6 @@ void DepsgraphNodeBuilder::build_object_transform(Object *object) add_operation_node(&object->id, DEG_NODE_TYPE_TRANSFORM, function_bind(BKE_object_eval_uber_transform, _1, - scene_cow, ob_cow), DEG_OPCODE_TRANSFORM_OBJECT_UBEREVAL); |