Depsgraph: Pull indirect dependencies via pchan constraints

Was missing ID looper for pchan constraint.
This commit is contained in:
Sergey Sharybin 2018-04-05 18:03:36 +02:00
parent ea0e2f9bd3
commit 9b8a92b874
3 changed files with 66 additions and 46 deletions

View File

@ -114,51 +114,6 @@ extern "C" {
namespace DEG {
namespace {
struct BuilderWalkUserData {
DepsgraphNodeBuilder *builder;
};
static void modifier_walk(void *user_data,
struct Object * /*object*/,
struct ID **idpoin,
int /*cb_flag*/)
{
BuilderWalkUserData *data = (BuilderWalkUserData *)user_data;
ID *id = *idpoin;
if (id == NULL) {
return;
}
switch (GS(id->name)) {
case ID_OB:
data->builder->build_object(NULL, (Object *)id);
break;
case ID_TE:
data->builder->build_texture((Tex *)id);
break;
default:
/* pass */
break;
}
}
void constraint_walk(bConstraint * /*con*/,
ID **idpoin,
bool /*is_reference*/,
void *user_data)
{
BuilderWalkUserData *data = (BuilderWalkUserData *)user_data;
if (*idpoin) {
ID *id = *idpoin;
if (GS(id->name) == ID_OB) {
data->builder->build_object(NULL, (Object *)id);
}
}
}
} /* namespace */
/* ************ */
/* Node Builder */
@ -1148,4 +1103,50 @@ void DepsgraphNodeBuilder::build_movieclip(MovieClip *clip) {
DEG_OPCODE_MOVIECLIP_EVAL);
}
/* **** ID traversal callbacks functions **** */
void DepsgraphNodeBuilder::modifier_walk(void *user_data,
struct Object * /*object*/,
struct ID **idpoin,
int /*cb_flag*/)
{
BuilderWalkUserData *data = (BuilderWalkUserData *)user_data;
ID *id = *idpoin;
if (id == NULL) {
return;
}
switch (GS(id->name)) {
case ID_OB:
data->builder->build_object(NULL, (Object *)id);
break;
case ID_TE:
data->builder->build_texture((Tex *)id);
break;
default:
/* pass */
break;
}
}
void DepsgraphNodeBuilder::constraint_walk(bConstraint * /*con*/,
ID **idpoin,
bool /*is_reference*/,
void *user_data)
{
BuilderWalkUserData *data = (BuilderWalkUserData *)user_data;
ID *id = *idpoin;
if (id == NULL) {
return;
}
switch (GS(id->name)) {
case ID_OB:
data->builder->build_object(NULL, (Object *)id);
break;
default:
/* pass */
break;
}
}
} // namespace DEG

View File

@ -165,6 +165,20 @@ struct DepsgraphNodeBuilder {
void build_movieclip(MovieClip *clip);
protected:
struct BuilderWalkUserData {
DepsgraphNodeBuilder *builder;
};
static void modifier_walk(void *user_data,
struct Object *object,
struct ID **idpoin,
int cb_flag);
static void constraint_walk(bConstraint *constraint,
ID **idpoin,
bool is_reference,
void *user_data);
/* State which never changes, same for the whole builder time. */
Main *bmain_;
Depsgraph *graph_;

View File

@ -49,6 +49,7 @@ extern "C" {
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_constraint.h"
} /* extern "C" */
#include "DEG_depsgraph.h"
@ -68,7 +69,11 @@ void DepsgraphNodeBuilder::build_pose_constraints(Object *object,
bPoseChannel *pchan,
int pchan_index)
{
/* create node for constraint stack */
/* Pull indirect dependencies via constraints. */
BuilderWalkUserData data;
data.builder = this;
BKE_constraints_id_loop(&pchan->constraints, constraint_walk, &data);
/* Create node for constraint stack. */
add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name,
function_bind(BKE_pose_constraints_evaluate,
_1,