Depsgraph: Add missing expansion od custom bone shapes

This commit is contained in:
Sergey Sharybin 2017-07-19 12:44:27 +02:00
parent 5d9a1b440b
commit e49aa6beac
7 changed files with 34 additions and 20 deletions

View File

@ -72,14 +72,21 @@ struct DepsgraphNodeBuilder {
DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph);
~DepsgraphNodeBuilder();
void begin_build(Main *bmain);
ID *get_cow_id(const ID *id_orig) const;
template<typename T>
T *get_cow_datablock(const T *orig) const {
return (T *)get_cow_id(&orig->id);
}
template<typename T>
T *get_orig_datablock(const T *cow) const {
#ifdef WITH_COPY_ON_WRITE
return (T *)cow->id.newid;
#else
return cow;
#endif
}
void begin_build(Main *bmain);
IDDepsNode *add_id_node(ID *id);
TimeSourceDepsNode *add_time_source();

View File

@ -259,14 +259,12 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *object)
function_bind(BKE_pose_bone_done, _1, pchan),
DEG_OPCODE_BONE_DONE);
op_node->set_as_exit();
/* constraints */
/* Build constraints. */
if (pchan->constraints.first != NULL) {
build_pose_constraints(scene, object, pchan);
}
/**
* IK Solvers...
* IK Solvers.
*
* - These require separate processing steps are pose-level
* to be executed between chains of bones (i.e. once the
@ -291,6 +289,11 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *object)
break;
}
}
/* Custom shape. */
/* NOTE: Custom shape datablock is already remapped to CoW version. */
if (pchan->custom != NULL) {
build_object(scene, get_orig_datablock(pchan->custom));
}
}
}

View File

@ -521,7 +521,7 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o
build_proxy_rig(ob);
}
else {
build_rig(scene, ob);
build_rig(bmain, scene, ob);
}
break;

View File

@ -210,7 +210,7 @@ struct DepsgraphRelationBuilder
bPoseChannel *pchan,
bConstraint *con,
RootPChanMap *root_map);
void build_rig(Scene *scene, Object *ob);
void build_rig(Main *bmain, Scene *scene, Object *ob);
void build_proxy_rig(Object *ob);
void build_shapekeys(ID *obdata, Key *key);
void build_obdata_geom(Main *bmain, Scene *scene, Object *ob);

View File

@ -291,7 +291,7 @@ void DepsgraphRelationBuilder::build_splineik_pose(Object *ob,
}
/* Pose/Armature Bones Graph */
void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
void DepsgraphRelationBuilder::build_rig(Main *bmain, Scene *scene, Object *ob)
{
/* Armature-Data */
bArmature *arm = (bArmature *)ob->data;
@ -379,16 +379,12 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
OperationKey bone_pose_key(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_POSE_PARENT);
OperationKey bone_ready_key(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_READY);
OperationKey bone_done_key(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_DONE);
pchan->flag &= ~POSE_DONE;
/* pose init to bone local */
/* Pose init to bone local. */
add_relation(init_key, bone_local_key, "PoseEval Source-Bone Link");
/* local to pose parenting operation */
/* Local to pose parenting operation. */
add_relation(bone_local_key, bone_pose_key, "Bone Local - PoseSpace Link");
/* parent relation */
/* Parent relation. */
if (pchan->parent != NULL) {
eDepsOperation_Code parent_key_opcode;
@ -403,8 +399,7 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
OperationKey parent_key(&ob->id, DEG_NODE_TYPE_BONE, pchan->parent->name, parent_key_opcode);
add_relation(parent_key, bone_pose_key, "[Parent Bone -> Child Bone]");
}
/* constraints */
/* Buil constraints. */
if (pchan->constraints.first != NULL) {
/* constraints stack and constraint dependencies */
build_constraints(scene, &ob->id, DEG_NODE_TYPE_BONE, pchan->name, &pchan->constraints, &root_map);
@ -431,6 +426,10 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
/* assume that all bones must be done for the pose to be ready (for deformers) */
add_relation(bone_done_key, flush_key, "PoseEval Result-Bone Link");
/* Custom shape. */
if (pchan->custom != NULL) {
build_object(bmain, scene, pchan->custom);
}
}
}

View File

@ -312,7 +312,8 @@ static bool check_datablocks_copy_on_writable(const ID *id_orig)
return !ELEM(id_type, ID_BR,
ID_TE,
ID_IM,
ID_LS);
ID_LS,
ID_AC);
}
/* Callback for BKE_library_foreach_ID_link which remaps original ID pointer
@ -605,6 +606,8 @@ ID *deg_expand_copy_on_write_datablock(Depsgraph *depsgraph,
MEM_freeN(newid);
}
id_cow->tag |= LIB_TAG_COPY_ON_WRITE;
/* TODO(sergey): Is it safe to re-use newid for original ID link? */
id_cow->newid = (ID *)id_orig;
return id_cow;
}

View File

@ -183,6 +183,8 @@ void IDDepsNode::init(const ID *id, const char *UNUSED(subdata))
DEG_COW_PRINT("Create shallow copy for %s: id_orig=%p id_cow=%p\n",
id_orig->name, id_orig, id_cow);
id_cow->tag |= LIB_TAG_COPY_ON_WRITE;
/* TODO(sergey): Is it safe to re-use newid for original ID link? */
id_cow->newid = (ID *)id_orig;
#else
id_cow = id_orig;
#endif