Cleanup: Make object_handle_update easier to follow
This commit is contained in:
parent
1f9387ef91
commit
dbde3c78f8
|
@ -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) == 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);
|
||||
}
|
||||
}
|
||||
/* 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) {
|
||||
/* 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 (G.debug & G_DEBUG_DEPSGRAPH) {
|
||||
printf("recalcob %s\n", ob->id.name + 2);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
/* 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);
|
||||
}
|
||||
|
||||
if (ob->recalc & OB_RECALC_DATA) {
|
||||
BKE_object_handle_data_update(eval_ctx, scene, ob);
|
||||
}
|
||||
|
||||
ob->recalc &= ~OB_RECALC_ALL;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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);
|
||||
else {
|
||||
copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
BKE_object_where_is_calc_ex(scene, rbw, ob, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (ob->recalc & OB_RECALC_DATA) {
|
||||
BKE_object_handle_data_update(eval_ctx, scene, ob);
|
||||
}
|
||||
|
||||
ob->recalc &= ~OB_RECALC_ALL;
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue