From 565316909ec71c8f98b2fee150737ed2defe2902 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 15 Oct 2007 10:36:30 +0000 Subject: [PATCH] Bugfix: Object constraints with a driven influence ipo were not being evaluated properly. The code for adding the depsgraph relation and updating without time changes was simply missing. --- source/blender/blenkernel/BKE_constraint.h | 2 +- source/blender/blenkernel/intern/action.c | 3 ++- source/blender/blenkernel/intern/constraint.c | 16 +++++++++------- source/blender/blenkernel/intern/depsgraph.c | 6 +++++- source/blender/blenkernel/intern/object.c | 6 ++++-- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index c2fdd551d79..39a3cf13087 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -76,7 +76,7 @@ void free_constraint_data(struct bConstraint *con); /* Constraint Channel function prototypes */ struct bConstraintChannel *get_constraint_channel(ListBase *list, const char *name); struct bConstraintChannel *verify_constraint_channel(ListBase *list, const char *name); -void do_constraint_channels(struct ListBase *conbase, struct ListBase *chanbase, float ctime); +void do_constraint_channels(struct ListBase *conbase, struct ListBase *chanbase, float ctime, int onlydrivers); void copy_constraint_channels(ListBase *dst, ListBase *src); void clone_constraint_channels(struct ListBase *dst, struct ListBase *src); void free_constraint_channels(ListBase *chanbase); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index c43be2925bc..22e621a27e2 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -718,7 +718,8 @@ void extract_pose_from_action(bPose *pose, bAction *act, float ctime) /* This call also sets the pchan flags */ execute_action_ipo(achan, pchan); } - do_constraint_channels(&pchan->constraints, &achan->constraintChannels, ctime); + /* 0 = do all ipos, not only drivers */ + do_constraint_channels(&pchan->constraints, &achan->constraintChannels, ctime, 0); } } diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 9ee158be531..b3f84e700f0 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -886,7 +886,7 @@ void constraints_clear_evalob (bConstraintOb *cob) /* -------------------------------- Constraint Channels ---------------------------- */ /* does IPO's of constraint channels only */ -void do_constraint_channels (ListBase *conbase, ListBase *chanbase, float ctime) +void do_constraint_channels (ListBase *conbase, ListBase *chanbase, float ctime, int onlydrivers) { bConstraint *con; bConstraintChannel *chan; @@ -901,13 +901,15 @@ void do_constraint_channels (ListBase *conbase, ListBase *chanbase, float ctime) calc_ipo(chan->ipo, ctime); for (icu=chan->ipo->curve.first; icu; icu=icu->next) { - switch (icu->adrcode) { - case CO_ENFORCE: - { - /* Influence is clamped to 0.0f -> 1.0f range */ - con->enforce = CLAMPIS(icu->curval, 0.0f, 1.0f); + if(!onlydrivers || icu->driver) { + switch (icu->adrcode) { + case CO_ENFORCE: + { + /* Influence is clamped to 0.0f -> 1.0f range */ + con->enforce = CLAMPIS(icu->curval, 0.0f, 1.0f); + } + break; } - break; } } } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 7b869f8b0e8..eb651a925e0 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -348,6 +348,7 @@ static void dag_add_driver_relation(Ipo *ipo, DagForest *dag, DagNode *node, int static void build_dag_object(DagForest *dag, DagNode *scenenode, Object *ob, int mask) { bConstraint *con; + bConstraintChannel *conchan; DagNode * node; DagNode * node2; DagNode * node3; @@ -401,9 +402,12 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Object *ob, int if(key && key->ipo) dag_add_driver_relation(key->ipo, dag, node, 1); + for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next) + if(conchan->ipo) + dag_add_driver_relation(conchan->ipo, dag, node, 0); + if(ob->action) { bActionChannel *chan; - bConstraintChannel *conchan; for (chan = ob->action->chanbase.first; chan; chan=chan->next){ if(chan->ipo) dag_add_driver_relation(chan->ipo, dag, node, 1); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ba8d047644b..20d61456f05 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1542,12 +1542,14 @@ void where_is_object_time(Object *ob, float ctime) else do_all_object_actions(ob); - /* do constraint ipos ..., note it needs stime */ - do_constraint_channels(&ob->constraints, &ob->constraintChannels, stime); + /* do constraint ipos ..., note it needs stime (0 = all ipos) */ + do_constraint_channels(&ob->constraints, &ob->constraintChannels, stime, 0); } else { /* but, the drivers have to be done */ if(ob->ipo) do_ob_ipodrivers(ob, ob->ipo, stime); + /* do constraint ipos ..., note it needs stime (1 = only drivers ipos) */ + do_constraint_channels(&ob->constraints, &ob->constraintChannels, stime, 1); } if(ob->parent) {