Depsgraph: Cleanup, make it easier to create relations with flags
This commit is contained in:
parent
3d77517ad5
commit
a20d350dd5
|
@ -304,10 +304,12 @@ DepsRelation *DepsgraphRelationBuilder::add_time_relation(
|
|||
TimeSourceDepsNode *timesrc,
|
||||
DepsNode *node_to,
|
||||
const char *description,
|
||||
bool check_unique)
|
||||
bool check_unique,
|
||||
int flags)
|
||||
{
|
||||
if (timesrc && node_to) {
|
||||
return graph_->add_new_relation(timesrc, node_to, description, check_unique);
|
||||
return graph_->add_new_relation(
|
||||
timesrc, node_to, description, check_unique, flags);
|
||||
}
|
||||
else {
|
||||
DEG_DEBUG_PRINTF((::Depsgraph *)graph_,
|
||||
|
@ -323,13 +325,15 @@ DepsRelation *DepsgraphRelationBuilder::add_operation_relation(
|
|||
OperationDepsNode *node_from,
|
||||
OperationDepsNode *node_to,
|
||||
const char *description,
|
||||
bool check_unique)
|
||||
bool check_unique,
|
||||
int flags)
|
||||
{
|
||||
if (node_from && node_to) {
|
||||
return graph_->add_new_relation(node_from,
|
||||
node_to,
|
||||
description,
|
||||
check_unique);
|
||||
check_unique,
|
||||
flags);
|
||||
}
|
||||
else {
|
||||
DEG_DEBUG_PRINTF((::Depsgraph *)graph_,
|
||||
|
@ -2499,10 +2503,10 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node
|
|||
OperationKey data_copy_on_write_key(object_data_id,
|
||||
DEG_NODE_TYPE_COPY_ON_WRITE,
|
||||
DEG_OPCODE_COPY_ON_WRITE);
|
||||
DepsRelation *rel = add_relation(data_copy_on_write_key,
|
||||
copy_on_write_key,
|
||||
"Eval Order");
|
||||
rel->flag |= DEPSREL_FLAG_GODMODE;
|
||||
add_relation(data_copy_on_write_key,
|
||||
copy_on_write_key,
|
||||
"Eval Order",
|
||||
DEPSREL_FLAG_GODMODE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "BLI_string.h"
|
||||
|
||||
#include "intern/builder/deg_builder_map.h"
|
||||
#include "intern/depsgraph.h"
|
||||
#include "intern/nodes/deg_node.h"
|
||||
#include "intern/nodes/deg_node_component.h"
|
||||
#include "intern/nodes/deg_node_operation.h"
|
||||
|
@ -186,19 +187,28 @@ struct DepsgraphRelationBuilder
|
|||
DepsRelation *add_relation(const KeyFrom& key_from,
|
||||
const KeyTo& key_to,
|
||||
const char *description,
|
||||
bool check_unique = false);
|
||||
bool check_unique = false,
|
||||
int flags = 0);
|
||||
|
||||
template <typename KeyFrom, typename KeyTo>
|
||||
DepsRelation *add_relation(const KeyFrom& key_from,
|
||||
const KeyTo& key_to,
|
||||
const char *description,
|
||||
eDepsRelation_Flag flag);
|
||||
|
||||
template <typename KeyTo>
|
||||
DepsRelation *add_relation(const TimeSourceKey& key_from,
|
||||
const KeyTo& key_to,
|
||||
const char *description,
|
||||
bool check_unique = false);
|
||||
bool check_unique = false,
|
||||
int flags = 0);
|
||||
|
||||
template <typename KeyType>
|
||||
DepsRelation *add_node_handle_relation(const KeyType& key_from,
|
||||
const DepsNodeHandle *handle,
|
||||
const char *description,
|
||||
bool check_unique = false);
|
||||
bool check_unique = false,
|
||||
int flags = 0);
|
||||
|
||||
void add_customdata_mask(const ComponentKey &key, uint64_t mask);
|
||||
void add_special_eval_flag(ID *object, uint32_t flag);
|
||||
|
@ -306,11 +316,13 @@ protected:
|
|||
DepsRelation *add_time_relation(TimeSourceDepsNode *timesrc,
|
||||
DepsNode *node_to,
|
||||
const char *description,
|
||||
bool check_unique = false);
|
||||
bool check_unique = false,
|
||||
int flags = 0);
|
||||
DepsRelation *add_operation_relation(OperationDepsNode *node_from,
|
||||
OperationDepsNode *node_to,
|
||||
const char *description,
|
||||
bool check_unique = false);
|
||||
bool check_unique = false,
|
||||
int flags = 0);
|
||||
|
||||
template <typename KeyType>
|
||||
DepsNodeHandle create_node_handle(const KeyType& key,
|
||||
|
|
|
@ -49,14 +49,16 @@ template <typename KeyFrom, typename KeyTo>
|
|||
DepsRelation *DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from,
|
||||
const KeyTo &key_to,
|
||||
const char *description,
|
||||
bool check_unique)
|
||||
bool check_unique,
|
||||
int flags)
|
||||
{
|
||||
DepsNode *node_from = get_node(key_from);
|
||||
DepsNode *node_to = get_node(key_to);
|
||||
OperationDepsNode *op_from = node_from ? node_from->get_exit_operation() : NULL;
|
||||
OperationDepsNode *op_to = node_to ? node_to->get_entry_operation() : NULL;
|
||||
if (op_from && op_to) {
|
||||
return add_operation_relation(op_from, op_to, description, check_unique);
|
||||
return add_operation_relation(
|
||||
op_from, op_to, description, check_unique, flags);
|
||||
}
|
||||
else {
|
||||
if (!op_from) {
|
||||
|
@ -81,18 +83,31 @@ DepsRelation *DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
template <typename KeyFrom, typename KeyTo>
|
||||
DepsRelation *DepsgraphRelationBuilder::add_relation(
|
||||
const KeyFrom& key_from,
|
||||
const KeyTo& key_to,
|
||||
const char *description,
|
||||
eDepsRelation_Flag flag)
|
||||
{
|
||||
return add_relation(
|
||||
key_from, key_to, description, false, static_cast<int>(flag));
|
||||
}
|
||||
|
||||
template <typename KeyTo>
|
||||
DepsRelation *DepsgraphRelationBuilder::add_relation(
|
||||
const TimeSourceKey &key_from,
|
||||
const KeyTo &key_to,
|
||||
const char *description,
|
||||
bool check_unique)
|
||||
bool check_unique,
|
||||
int flags)
|
||||
{
|
||||
TimeSourceDepsNode *time_from = get_node(key_from);
|
||||
DepsNode *node_to = get_node(key_to);
|
||||
OperationDepsNode *op_to = node_to ? node_to->get_entry_operation() : NULL;
|
||||
if (time_from != NULL && op_to != NULL) {
|
||||
return add_time_relation(time_from, op_to, description, check_unique);
|
||||
return add_time_relation(
|
||||
time_from, op_to, description, check_unique, flags);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -102,13 +117,15 @@ DepsRelation *DepsgraphRelationBuilder::add_node_handle_relation(
|
|||
const KeyType &key_from,
|
||||
const DepsNodeHandle *handle,
|
||||
const char *description,
|
||||
bool check_unique)
|
||||
bool check_unique,
|
||||
int flags)
|
||||
{
|
||||
DepsNode *node_from = get_node(key_from);
|
||||
OperationDepsNode *op_from = node_from ? node_from->get_exit_operation() : NULL;
|
||||
OperationDepsNode *op_to = handle->node->get_entry_operation();
|
||||
if (op_from != NULL && op_to != NULL) {
|
||||
return add_operation_relation(op_from, op_to, description, check_unique);
|
||||
return add_operation_relation(
|
||||
op_from, op_to, description, check_unique, flags);
|
||||
}
|
||||
else {
|
||||
if (!op_from) {
|
||||
|
|
|
@ -341,8 +341,7 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
|
|||
* Unsolved Issues:
|
||||
* - Care is needed to ensure that multi-headed trees work out the same as
|
||||
* in ik-tree building
|
||||
* - Animated chain-lengths are a problem...
|
||||
*/
|
||||
* - Animated chain-lengths are a problem. */
|
||||
RootPChanMap root_map;
|
||||
bool pose_depends_on_local_transform = false;
|
||||
LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) {
|
||||
|
@ -359,8 +358,7 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
|
|||
break;
|
||||
|
||||
/* Constraints which needs world's matrix for transform.
|
||||
* TODO(sergey): More constraints here?
|
||||
*/
|
||||
* TODO(sergey): More constraints here? */
|
||||
case CONSTRAINT_TYPE_ROTLIKE:
|
||||
case CONSTRAINT_TYPE_SIZELIKE:
|
||||
case CONSTRAINT_TYPE_LOCLIKE:
|
||||
|
@ -377,15 +375,13 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
|
|||
//root_map.print_debug();
|
||||
if (pose_depends_on_local_transform) {
|
||||
/* TODO(sergey): Once partial updates are possible use relation between
|
||||
* object transform and solver itself in it's build function.
|
||||
*/
|
||||
* object transform and solver itself in it's build function. */
|
||||
ComponentKey pose_key(&object->id, DEG_NODE_TYPE_EVAL_POSE);
|
||||
ComponentKey local_transform_key(&object->id, DEG_NODE_TYPE_TRANSFORM);
|
||||
add_relation(local_transform_key, pose_key, "Local Transforms");
|
||||
}
|
||||
/* Links between operations for each bone. */
|
||||
LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) {
|
||||
DepsRelation *relation;
|
||||
OperationKey bone_local_key(&object->id,
|
||||
DEG_NODE_TYPE_BONE,
|
||||
pchan->name,
|
||||
|
@ -404,18 +400,17 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
|
|||
DEG_OPCODE_BONE_DONE);
|
||||
pchan->flag &= ~POSE_DONE;
|
||||
/* Pose init to bone local. */
|
||||
relation = add_relation(
|
||||
pose_init_key, bone_local_key, "Pose Init - Bone Local");
|
||||
relation->flag |= DEPSREL_FLAG_GODMODE;
|
||||
add_relation(pose_init_key,
|
||||
bone_local_key,
|
||||
"Pose Init - Bone Local",
|
||||
DEPSREL_FLAG_GODMODE);
|
||||
/* Local to pose parenting operation. */
|
||||
add_relation(bone_local_key, bone_pose_key, "Bone Local - Bone Pose");
|
||||
/* Parent relation. */
|
||||
if (pchan->parent != NULL) {
|
||||
eDepsOperation_Code parent_key_opcode;
|
||||
|
||||
/* NOTE: this difference in handling allows us to prevent lockups
|
||||
* while ensuring correct poses for separate chains.
|
||||
*/
|
||||
* while ensuring correct poses for separate chains. */
|
||||
if (root_map.has_common_root(pchan->name, pchan->parent->name)) {
|
||||
parent_key_opcode = DEG_OPCODE_BONE_READY;
|
||||
}
|
||||
|
@ -449,8 +444,7 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
|
|||
add_relation(bone_pose_key, constraints_key, "Constraints Stack");
|
||||
/* Constraints -> ready/ */
|
||||
/* TODO(sergey): When constraint stack is exploded, this step should
|
||||
* occur before the first IK solver.
|
||||
*/
|
||||
* occur before the first IK solver. */
|
||||
add_relation(
|
||||
constraints_key, bone_ready_key, "Constraints -> Ready");
|
||||
}
|
||||
|
@ -461,12 +455,10 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
|
|||
/* Bone ready -> Bone done.
|
||||
* NOTE: For bones without IK, this is all that's needed.
|
||||
* For IK chains however, an additional rel is created from IK
|
||||
* to done, with transitive reduction removing this one..
|
||||
*/
|
||||
* to done, with transitive reduction removing this one. */
|
||||
add_relation(bone_ready_key, bone_done_key, "Ready -> Done");
|
||||
/* assume that all bones must be done for the pose to be ready
|
||||
* (for deformers)
|
||||
*/
|
||||
/* Assume that all bones must be done for the pose to be ready
|
||||
* (for deformers). */
|
||||
add_relation(bone_done_key, pose_done_key, "PoseEval Result-Bone Link");
|
||||
add_relation(bone_done_key, pose_cleanup_key, "Cleanup dependency");
|
||||
/* Custom shape. */
|
||||
|
|
|
@ -393,34 +393,40 @@ void Depsgraph::clear_id_nodes()
|
|||
DepsRelation *Depsgraph::add_new_relation(OperationDepsNode *from,
|
||||
OperationDepsNode *to,
|
||||
const char *description,
|
||||
bool check_unique)
|
||||
bool check_unique,
|
||||
int flags)
|
||||
{
|
||||
DepsRelation *rel = NULL;
|
||||
if (check_unique) {
|
||||
rel = check_nodes_connected(from, to, description);
|
||||
}
|
||||
if (rel != NULL) {
|
||||
rel->flag |= flags;
|
||||
return rel;
|
||||
}
|
||||
/* Create new relation, and add it to the graph. */
|
||||
rel = OBJECT_GUARDED_NEW(DepsRelation, from, to, description);
|
||||
rel->flag |= flags;
|
||||
return rel;
|
||||
}
|
||||
|
||||
/* Add new relation between two nodes */
|
||||
DepsRelation *Depsgraph::add_new_relation(DepsNode *from, DepsNode *to,
|
||||
const char *description,
|
||||
bool check_unique)
|
||||
bool check_unique,
|
||||
int flags)
|
||||
{
|
||||
DepsRelation *rel = NULL;
|
||||
if (check_unique) {
|
||||
rel = check_nodes_connected(from, to, description);
|
||||
}
|
||||
if (rel != NULL) {
|
||||
rel->flag |= flags;
|
||||
return rel;
|
||||
}
|
||||
/* Create new relation, and add it to the graph. */
|
||||
rel = OBJECT_GUARDED_NEW(DepsRelation, from, to, description);
|
||||
rel->flag |= flags;
|
||||
return rel;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,12 +141,14 @@ struct Depsgraph {
|
|||
DepsRelation *add_new_relation(OperationDepsNode *from,
|
||||
OperationDepsNode *to,
|
||||
const char *description,
|
||||
bool check_unique = false);
|
||||
bool check_unique = false,
|
||||
int flags = 0);
|
||||
|
||||
DepsRelation *add_new_relation(DepsNode *from,
|
||||
DepsNode *to,
|
||||
const char *description,
|
||||
bool check_unique = false);
|
||||
bool check_unique = false,
|
||||
int flags = 0);
|
||||
|
||||
/* Check whether two nodes are connected by relation with given
|
||||
* description. Description might be NULL to check ANY relation between
|
||||
|
|
Loading…
Reference in New Issue