Fix #126949: Regression: Geometry nodes - instances and boolean operation bug

The issue is due to a dependency cycle which leads to access of data
which is not ready yet.
The dependency cycle was introduced in ada367a0e9.

This change makes it so there is no dependency cycle in the setup from
the report by re-routing dependencies a bit: the light linking now
bypasses the geometry component and is only wired to an operation
related on instancing collection (but not use by a boolean modifier).

Pull Request: https://projects.blender.org/blender/blender/pulls/127143
This commit is contained in:
Sergey Sharybin
2024-09-04 16:31:48 +02:00
committed by Sergey Sharybin
parent 3915a84fc6
commit 40ae2d7df6
4 changed files with 18 additions and 7 deletions

View File

@@ -857,6 +857,10 @@ void DepsgraphNodeBuilder::build_object(int base_index,
&object->id, NodeType::INSTANCING, OperationCode::INSTANCE);
instance_node->flag |= OperationFlag::DEPSOP_FLAG_PINNED;
OperationNode *instance_geometry_node = add_operation_node(
&object->id, NodeType::INSTANCING, OperationCode::INSTANCE_GEOMETRY);
instance_geometry_node->flag |= OperationFlag::DEPSOP_FLAG_PINNED;
build_object_light_linking(object);
build_object_shading(object);

View File

@@ -690,9 +690,9 @@ void DepsgraphRelationBuilder::build_collection(LayerCollection *from_layer_coll
const ComponentKey object_hierarchy_key{&object->id, NodeType::HIERARCHY};
add_relation(collection_hierarchy_key, object_hierarchy_key, "Collection -> Object hierarchy");
const OperationKey object_instance_key{
&object->id, NodeType::INSTANCING, OperationCode::INSTANCE};
add_relation(object_instance_key, collection_geometry_key, "Collection Geometry");
const OperationKey object_instance_geometry_key{
&object->id, NodeType::INSTANCING, OperationCode::INSTANCE_GEOMETRY};
add_relation(object_instance_geometry_key, collection_geometry_key, "Collection Geometry");
/* An instance is part of the geometry of the collection. */
if (object->type == OB_EMPTY) {
@@ -750,9 +750,13 @@ void DepsgraphRelationBuilder::build_object(Object *object)
add_relation(local_transform_key, parent_transform_key, "ObLocal -> ObParent");
}
add_relation(ComponentKey(&object->id, NodeType::TRANSFORM),
add_relation(OperationKey{&object->id, NodeType::INSTANCING, OperationCode::INSTANCE_GEOMETRY},
OperationKey{&object->id, NodeType::INSTANCING, OperationCode::INSTANCE},
"Transform -> Instance");
"Instance Geometry -> Geometry");
add_relation(ComponentKey(&object->id, NodeType::TRANSFORM),
OperationKey{&object->id, NodeType::INSTANCING, OperationCode::INSTANCE_GEOMETRY},
"Transform -> Instance Geometry");
/* Modifiers. */
build_object_modifiers(object);
@@ -2600,8 +2604,8 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
add_relation(scene_key, obdata_ubereval_key, "Copy-on-Eval Relation", RELATION_FLAG_NO_FLUSH);
/* Relation to the instance, so that instancer can use geometry of this object. */
add_relation(ComponentKey(&object->id, NodeType::GEOMETRY),
OperationKey(&object->id, NodeType::INSTANCING, OperationCode::INSTANCE),
"Transform -> Instance");
OperationKey(&object->id, NodeType::INSTANCING, OperationCode::INSTANCE_GEOMETRY),
"Transform -> Instance Geometry");
/* Shader FX. */
if (object->shader_fx.first != nullptr) {
ModifierUpdateDepsgraphContext ctx = {};

View File

@@ -204,6 +204,8 @@ const char *operationCodeAsString(OperationCode opcode)
return "INSTANCER";
case OperationCode::INSTANCE:
return "INSTANCE";
case OperationCode::INSTANCE_GEOMETRY:
return "INSTANCE_GEOMETRY";
}
BLI_assert_msg(0, "Unhandled operation code, should never happen.");
return "UNKNOWN";

View File

@@ -205,6 +205,7 @@ enum class OperationCode {
/* Operation on an object which is being instanced. */
INSTANCE,
INSTANCE_GEOMETRY,
};
const char *operationCodeAsString(OperationCode opcode);