Depsgraph: Add proper API functions for CustomDataMask dependencies.
There were a few copies of the same few lines in depsgraph build code, so it seems to be logical to introduce a function for it, and make it accessible from C code for completeness. As an example, register the mask needs of the Data Transfer modifier.
This commit is contained in:
parent
9a38a91f41
commit
cd48d4576b
|
@ -53,6 +53,8 @@ struct ViewLayer;
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
/* Graph Building -------------------------------- */
|
||||
|
||||
/* Build depsgraph for the given scene, and dump results in given
|
||||
|
@ -139,6 +141,11 @@ void DEG_add_object_relation(struct DepsNodeHandle *node,
|
|||
struct Object *object,
|
||||
eDepsObjectComponentType component,
|
||||
const char *description);
|
||||
void DEG_add_object_customdata_relation(struct DepsNodeHandle *node,
|
||||
struct Object *object,
|
||||
eDepsObjectComponentType component,
|
||||
uint64_t customdata_mask,
|
||||
const char *description);
|
||||
void DEG_add_bone_relation(struct DepsNodeHandle *handle,
|
||||
struct Object *object,
|
||||
const char *bone_name,
|
||||
|
|
|
@ -274,6 +274,17 @@ bool DepsgraphRelationBuilder::has_node(const OperationKey &key) const
|
|||
return find_node(key) != NULL;
|
||||
}
|
||||
|
||||
void DepsgraphRelationBuilder::add_customdata_mask(const ComponentKey &key, uint64_t mask)
|
||||
{
|
||||
if (mask != 0) {
|
||||
OperationDepsNode *node = find_operation_node(key);
|
||||
|
||||
if (node != NULL) {
|
||||
node->customdata_mask |= mask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DepsRelation *DepsgraphRelationBuilder::add_time_relation(
|
||||
TimeSourceDepsNode *timesrc,
|
||||
DepsNode *node_to,
|
||||
|
@ -760,10 +771,7 @@ void DepsgraphRelationBuilder::build_object_parent(Object *object)
|
|||
add_relation(parent_key, ob_key, "Vertex Parent");
|
||||
|
||||
/* XXX not sure what this is for or how you could be done properly - lukas */
|
||||
OperationDepsNode *parent_node = find_operation_node(parent_key);
|
||||
if (parent_node != NULL) {
|
||||
parent_node->customdata_mask |= CD_MASK_ORIGINDEX;
|
||||
}
|
||||
add_customdata_mask(parent_key, CD_MASK_ORIGINDEX);
|
||||
|
||||
ComponentKey transform_key(&object->parent->id, DEG_NODE_TYPE_TRANSFORM);
|
||||
add_relation(transform_key, ob_key, "Vertex Parent TFM");
|
||||
|
@ -974,10 +982,7 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
|
|||
ComponentKey target_key(&ct->tar->id, DEG_NODE_TYPE_GEOMETRY);
|
||||
add_relation(target_key, constraint_op_key, cti->name);
|
||||
if (ct->tar->type == OB_MESH) {
|
||||
OperationDepsNode *node2 = find_operation_node(target_key);
|
||||
if (node2 != NULL) {
|
||||
node2->customdata_mask |= CD_MASK_MDEFORMVERT;
|
||||
}
|
||||
add_customdata_mask(target_key, CD_MASK_MDEFORMVERT);
|
||||
}
|
||||
}
|
||||
else if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
|
||||
|
|
|
@ -200,6 +200,8 @@ struct DepsgraphRelationBuilder
|
|||
const char *description,
|
||||
bool check_unique = false);
|
||||
|
||||
void add_customdata_mask(const ComponentKey &key, uint64_t mask);
|
||||
|
||||
void build_id(ID *id);
|
||||
void build_layer_collections(ListBase *lb);
|
||||
void build_view_layer(Scene *scene, ViewLayer *view_layer);
|
||||
|
|
|
@ -129,10 +129,7 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object,
|
|||
add_relation(target_key, solver_key, con->name);
|
||||
|
||||
if (data->tar->type == OB_MESH) {
|
||||
OperationDepsNode *node2 = find_operation_node(target_key);
|
||||
if (node2 != NULL) {
|
||||
node2->customdata_mask |= CD_MASK_MDEFORMVERT;
|
||||
}
|
||||
add_customdata_mask(target_key, CD_MASK_MDEFORMVERT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -164,10 +161,7 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object,
|
|||
add_relation(target_key, solver_key, con->name);
|
||||
|
||||
if (data->poletar->type == OB_MESH) {
|
||||
OperationDepsNode *node2 = find_operation_node(target_key);
|
||||
if (node2 != NULL) {
|
||||
node2->customdata_mask |= CD_MASK_MDEFORMVERT;
|
||||
}
|
||||
add_customdata_mask(target_key, CD_MASK_MDEFORMVERT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -131,6 +131,23 @@ void DEG_add_object_relation(DepsNodeHandle *handle,
|
|||
description);
|
||||
}
|
||||
|
||||
void DEG_add_object_customdata_relation(DepsNodeHandle *handle,
|
||||
Object *object,
|
||||
eDepsObjectComponentType component,
|
||||
uint64_t customdata_mask,
|
||||
const char *description)
|
||||
{
|
||||
DEG::eDepsNode_Type type = deg_build_object_component_type(component);
|
||||
DEG::ComponentKey comp_key(&object->id, type);
|
||||
DEG::DepsNodeHandle *deg_handle = get_handle(handle);
|
||||
deg_handle->builder->add_node_handle_relation(comp_key,
|
||||
deg_handle,
|
||||
description);
|
||||
if (object->type == OB_MESH) {
|
||||
deg_handle->builder->add_customdata_mask(comp_key, customdata_mask);
|
||||
}
|
||||
}
|
||||
|
||||
void DEG_add_object_cache_relation(DepsNodeHandle *handle,
|
||||
CacheFile *cache_file,
|
||||
eDepsObjectComponentType component,
|
||||
|
|
|
@ -836,7 +836,7 @@ static void rna_DataTransferModifier_use_data_update(Main *bmain, Scene *scene,
|
|||
dtmd->data_types &= ~DT_TYPE_POLY_ALL;
|
||||
}
|
||||
|
||||
rna_Modifier_update(bmain, scene, ptr);
|
||||
rna_Modifier_dependency_update(bmain, scene, ptr);
|
||||
}
|
||||
|
||||
static void rna_DataTransferModifier_data_types_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
|
@ -857,7 +857,7 @@ static void rna_DataTransferModifier_data_types_update(Main *bmain, Scene *scene
|
|||
dtmd->flags |= MOD_DATATRANSFER_USE_POLY;
|
||||
}
|
||||
|
||||
rna_Modifier_update(bmain, scene, ptr);
|
||||
rna_Modifier_dependency_update(bmain, scene, ptr);
|
||||
}
|
||||
|
||||
static void rna_DataTransferModifier_verts_data_types_set(struct PointerRNA *ptr, int value)
|
||||
|
|
|
@ -129,7 +129,9 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
|||
{
|
||||
DataTransferModifierData *dtmd = (DataTransferModifierData *) md;
|
||||
if (dtmd->ob_source != NULL) {
|
||||
DEG_add_object_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_GEOMETRY, "DataTransfer Modifier");
|
||||
CustomDataMask mask = BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types);
|
||||
|
||||
DEG_add_object_customdata_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_GEOMETRY, mask, "DataTransfer Modifier");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue