Depsgraph: Connect duplicating geometry to duplicator

This allows to force duplicated object to be fully evaluated for
display/draw.

Previously only transform component of duplicated object was
forced to become evaluated.
This commit is contained in:
Sergey Sharybin 2018-09-19 15:09:55 +02:00
parent 1b98fff713
commit cc061d349b
7 changed files with 34 additions and 1 deletions

View File

@ -620,6 +620,11 @@ void DepsgraphNodeBuilder::build_object(int base_index,
is_parent_collection_visible_ = is_visible;
build_collection(object->dup_group);
is_parent_collection_visible_ = is_current_parent_collection_visible;
add_operation_node(&object->id,
DEG_NODE_TYPE_DUPLI,
NULL,
DEG_OPCODE_PLACEHOLDER,
"Dupli");
}
}

View File

@ -468,6 +468,8 @@ void DepsgraphRelationBuilder::build_collection(
OperationKey object_transform_final_key(object != NULL ? &object->id : NULL,
DEG_NODE_TYPE_TRANSFORM,
DEG_OPCODE_TRANSFORM_FINAL);
ComponentKey duplicator_key(object != NULL ? &object->id : NULL,
DEG_NODE_TYPE_DUPLI);
if (!group_done) {
LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
build_object(NULL, cob->ob);
@ -480,7 +482,22 @@ void DepsgraphRelationBuilder::build_collection(
FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(collection, ob, graph_->mode)
{
ComponentKey dupli_transform_key(&ob->id, DEG_NODE_TYPE_TRANSFORM);
add_relation(dupli_transform_key, object_transform_final_key, "Dupligroup");
add_relation(dupli_transform_key,
object_transform_final_key,
"Dupligroup");
/* Hook to special component, to ensure proper visibility/evaluation
* optimizations.
*/
add_relation(dupli_transform_key, duplicator_key, "Dupligroup");
const eDepsNode_Type dupli_geometry_component_type =
deg_geometry_tag_to_component(&ob->id);
if (dupli_geometry_component_type != DEG_NODE_TYPE_UNDEFINED) {
ComponentKey dupli_geometry_component_key(
&ob->id, dupli_geometry_component_type);
add_relation(dupli_geometry_component_key,
duplicator_key,
"Dupligroup");
}
}
FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END;
}

View File

@ -408,6 +408,7 @@ static void deg_debug_graphviz_node(const DebugContext &ctx,
case DEG_NODE_TYPE_COPY_ON_WRITE:
case DEG_NODE_TYPE_OBJECT_FROM_LAYER:
case DEG_NODE_TYPE_BATCH_CACHE:
case DEG_NODE_TYPE_DUPLI:
{
ComponentDepsNode *comp_node = (ComponentDepsNode *)node;
if (!comp_node->operations.empty()) {

View File

@ -101,6 +101,8 @@ const char *nodeTypeAsString(eDepsNode_Type type)
STRINGIFY_TYPE(SHADING_PARAMETERS);
STRINGIFY_TYPE(CACHE);
STRINGIFY_TYPE(BATCH_CACHE);
/* Duplication. */
STRINGIFY_TYPE(DUPLI);
/* Total number of meaningful node types. */
case NUM_DEG_NODE_TYPES: return "SpecialCase";

View File

@ -155,6 +155,11 @@ typedef enum eDepsNode_Type {
/* Batch Cache Component - TODO (dfelinto/sergey) rename to make it more generic. */
DEG_NODE_TYPE_BATCH_CACHE,
/* Duplication system. Used to force duplicated objects visible when
* when duplicator is visible.
*/
DEG_NODE_TYPE_DUPLI,
/* Total number of meaningful node types. */
NUM_DEG_NODE_TYPES,
} eDepsNode_Type;

View File

@ -393,6 +393,7 @@ DEG_COMPONENT_NODE_DEFINE(Shading, SHADING, ID_RECALC_DRAW)
DEG_COMPONENT_NODE_DEFINE(ShadingParameters, SHADING_PARAMETERS, ID_RECALC_DRAW);
DEG_COMPONENT_NODE_DEFINE(Transform, TRANSFORM, ID_RECALC_TRANSFORM);
DEG_COMPONENT_NODE_DEFINE(ObjectFromLayer, OBJECT_FROM_LAYER, ID_RECALC);
DEG_COMPONENT_NODE_DEFINE(Dupli, DUPLI, 0);
/* Node Types Register =================================== */
@ -414,6 +415,7 @@ void deg_register_component_depsnodes()
deg_register_node_typeinfo(&DNTI_SHADING_PARAMETERS);
deg_register_node_typeinfo(&DNTI_TRANSFORM);
deg_register_node_typeinfo(&DNTI_OBJECT_FROM_LAYER);
deg_register_node_typeinfo(&DNTI_DUPLI);
}
} // namespace DEG

View File

@ -193,6 +193,7 @@ DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(Shading);
DEG_COMPONENT_NODE_DECLARE_GENERIC(ShadingParameters);
DEG_COMPONENT_NODE_DECLARE_GENERIC(Transform);
DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(ObjectFromLayer);
DEG_COMPONENT_NODE_DECLARE_GENERIC(Dupli);
/* Bone Component */
struct BoneComponentDepsNode : public ComponentDepsNode {