Use depsgraph's objects iterator to find sources of dupliobjects, instead of looping over bases of a viewlayer.
Details
- Reviewers
Sybren A. Stüvel (sybren) Sergey Sharybin (sergey) - Maniphest Tasks
- T86671: Background Scene Dupliface Not Instanced
Diff Detail
- Repository
- rB Blender
- Branch
- T86671 (branched from master)
- Build Status
Buildable 17726 Build 17726: arc lint + arc unit
Event Timeline
To me the DEG_get_evaluated_view_layer_of_object seems to be an ill-defined concept as an object might be used by multiple view layers. It also seems that the logic will not survive if the object is pulled into the active scene's view layer via dependencies.
Think the proper way of thoughts would be more in realms of: why the object_dupli.c even cares about view layer? Why doesn't it use depsgraph iterator (similar to how render engines do this, and how the evaluated state is supposed to be used) ?
All true... But that's best solution I can see given current code, that does not implies more invasive changes.
Think the proper way of thoughts would be more in realms of: why the object_dupli.c even cares about view layer? Why doesn't it use depsgraph iterator (similar to how render engines do this, and how the evaluated state is supposed to be used) ?
make_child_duplis iterates over the view_layer's bases, using their indices to generate a persistent_id value for the dupliobjects... I guess we could do the same while iterating over depsgraph's objects instead? But that makes that 'persistent' id even less persistent I think? Other solution could be to use object's session 'uuid' here instead maybe?
Use deg objects iterator instead of a viewlayer's bases to find dupliobjects from parent.
Bad news: the cycles_mesh_cpu test fails with this. You can also see that viewport drawing of lib/tests/render/mesh/visibility_instances.blend tries to instance object in first row twice (sorta).
Good news: using int deg_objects_visibility_flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET; solves the problem. It kind of makes sense from compatibility point of view with the previous code: only consider objects which has Base and don't consider objects which are in depsgraph due to dependency (i.e. when Boolean modifier needs object which is not in the viewlayer the object will be pulled into the depsgraph but will be flagged as linked indirectly). Using DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET makes it so you only consider objects which has bases in either scene itself or in the set scene.
Also consider using const qualifier for deg_objects_visibility_flags ;)
| source/blender/blenkernel/intern/object_dupli.cc | ||
|---|---|---|
| 312 | Maybe add a clue that we want to investigate usage of session_uuid? | |