Depsgraph: fixes for the eval_flags API behavior.
- Use the original ID pointer for lookup in DEG_get_eval_flags_for_id. - When the flags change after a DEG rebuild, tag the object for update. - Instead of mixing int and short in different places, use uint32_t. This fixes text not updating when a Follow Curve reference is set.
This commit is contained in:
@@ -156,7 +156,7 @@ void DEG_add_object_cache_relation(struct DepsNodeHandle *handle,
|
||||
eDepsObjectComponentType component,
|
||||
const char *description);
|
||||
|
||||
void DEG_add_special_eval_flag(struct DepsNodeHandle *handle, struct ID *id, short flag);
|
||||
void DEG_add_special_eval_flag(struct DepsNodeHandle *handle, struct ID *id, uint32_t flag);
|
||||
|
||||
struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *handle);
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ bool DEG_id_type_updated(const struct Depsgraph *depsgraph, short id_type);
|
||||
bool DEG_id_type_any_updated(const struct Depsgraph *depsgraph);
|
||||
|
||||
/* Get additional evaluation flags for the given ID. */
|
||||
short DEG_get_eval_flags_for_id(const struct Depsgraph *graph, struct ID *id);
|
||||
uint32_t DEG_get_eval_flags_for_id(const struct Depsgraph *graph, struct ID *id);
|
||||
|
||||
/* Get scene the despgraph is created for. */
|
||||
struct Scene *DEG_get_evaluated_scene(const struct Depsgraph *graph);
|
||||
|
||||
@@ -138,6 +138,10 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
|
||||
flag |= DEG_TAG_TIME;
|
||||
}
|
||||
}
|
||||
/* Tag rebuild if special evaluation flags changed. */
|
||||
if (id_node->eval_flags != id_node->previous_eval_flags) {
|
||||
flag |= DEG_TAG_TRANSFORM | DEG_TAG_GEOMETRY;
|
||||
}
|
||||
if (!deg_copy_on_write_is_expanded(id_node->id_cow)) {
|
||||
flag |= DEG_TAG_COPY_ON_WRITE;
|
||||
/* This means ID is being added to the dependency graph first
|
||||
|
||||
@@ -164,17 +164,20 @@ IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
|
||||
IDDepsNode *id_node = NULL;
|
||||
ID *id_cow = NULL;
|
||||
IDComponentsMask previously_visible_components_mask = 0;
|
||||
uint32_t previous_eval_flags = 0;
|
||||
IDInfo *id_info = (IDInfo *)BLI_ghash_lookup(id_info_hash_, id);
|
||||
if (id_info != NULL) {
|
||||
id_cow = id_info->id_cow;
|
||||
previously_visible_components_mask =
|
||||
id_info->previously_visible_components_mask;
|
||||
previous_eval_flags = id_info->previous_eval_flags;
|
||||
/* Tag ID info to not free the CoW ID pointer. */
|
||||
id_info->id_cow = NULL;
|
||||
}
|
||||
id_node = graph_->add_id_node(id, id_cow);
|
||||
id_node->previously_visible_components_mask =
|
||||
previously_visible_components_mask;
|
||||
id_node->previous_eval_flags = previous_eval_flags;
|
||||
/* Currently all ID nodes are supposed to have copy-on-write logic.
|
||||
*
|
||||
* NOTE: Zero number of components indicates that ID node was just created.
|
||||
@@ -356,6 +359,7 @@ void DepsgraphNodeBuilder::begin_build()
|
||||
}
|
||||
id_info->previously_visible_components_mask =
|
||||
id_node->visible_components_mask;
|
||||
id_info->previous_eval_flags = id_node->eval_flags;
|
||||
BLI_ghash_insert(id_info_hash_, id_node->id_orig, id_info);
|
||||
id_node->id_cow = NULL;
|
||||
}
|
||||
|
||||
@@ -231,6 +231,8 @@ struct DepsgraphNodeBuilder {
|
||||
* dependency graph.
|
||||
*/
|
||||
IDComponentsMask previously_visible_components_mask;
|
||||
/* Special evaluation flag mask from the previous depsgraph. */
|
||||
uint32_t previous_eval_flags;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
@@ -286,7 +286,7 @@ void DepsgraphRelationBuilder::add_customdata_mask(const ComponentKey &key, uint
|
||||
}
|
||||
}
|
||||
|
||||
void DepsgraphRelationBuilder::add_special_eval_flag(ID *id, short flag)
|
||||
void DepsgraphRelationBuilder::add_special_eval_flag(ID *id, uint32_t flag)
|
||||
{
|
||||
DEG::IDDepsNode *id_node = graph_->find_id_node(id);
|
||||
if (id_node == NULL) {
|
||||
|
||||
@@ -201,7 +201,7 @@ struct DepsgraphRelationBuilder
|
||||
bool check_unique = false);
|
||||
|
||||
void add_customdata_mask(const ComponentKey &key, uint64_t mask);
|
||||
void add_special_eval_flag(ID *object, short flag);
|
||||
void add_special_eval_flag(ID *object, uint32_t flag);
|
||||
|
||||
void build_id(ID *id);
|
||||
void build_layer_collections(ListBase *lb);
|
||||
|
||||
@@ -178,7 +178,7 @@ void DEG_add_bone_relation(DepsNodeHandle *handle,
|
||||
description);
|
||||
}
|
||||
|
||||
void DEG_add_special_eval_flag(struct DepsNodeHandle *handle, ID *id, short flag)
|
||||
void DEG_add_special_eval_flag(struct DepsNodeHandle *handle, ID *id, uint32_t flag)
|
||||
{
|
||||
DEG::DepsNodeHandle *deg_handle = get_handle(handle);
|
||||
deg_handle->builder->add_special_eval_flag(id, flag);
|
||||
|
||||
@@ -100,7 +100,7 @@ bool DEG_id_type_any_updated(const Depsgraph *graph)
|
||||
return false;
|
||||
}
|
||||
|
||||
short DEG_get_eval_flags_for_id(const Depsgraph *graph, ID *id)
|
||||
uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, ID *id)
|
||||
{
|
||||
if (graph == NULL) {
|
||||
/* Happens when converting objects to mesh from a python script
|
||||
@@ -113,7 +113,7 @@ short DEG_get_eval_flags_for_id(const Depsgraph *graph, ID *id)
|
||||
}
|
||||
|
||||
const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
|
||||
const DEG::IDDepsNode *id_node = deg_graph->find_id_node(id);
|
||||
const DEG::IDDepsNode *id_node = deg_graph->find_id_node(DEG_get_original_id(id));
|
||||
if (id_node == NULL) {
|
||||
/* TODO(sergey): Does it mean we need to check set scene? */
|
||||
return 0;
|
||||
|
||||
@@ -103,6 +103,7 @@ void IDDepsNode::init(const ID *id, const char *UNUSED(subdata))
|
||||
/* Store ID-pointer. */
|
||||
id_orig = (ID *)id;
|
||||
eval_flags = 0;
|
||||
previous_eval_flags = 0;
|
||||
linked_state = DEG_ID_LINKED_INDIRECTLY;
|
||||
is_directly_visible = true;
|
||||
|
||||
|
||||
@@ -78,7 +78,8 @@ struct IDDepsNode : public DepsNode {
|
||||
* TODO(sergey): Only needed for until really granular updates
|
||||
* of all the entities.
|
||||
*/
|
||||
int eval_flags;
|
||||
uint32_t eval_flags;
|
||||
uint32_t previous_eval_flags;
|
||||
|
||||
eDepsNode_LinkedState_Type linked_state;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user