In previous code, the owner ID info would not be available when
processing an embedded ID in two cases, and was incorrectly set to the
processed (embedded) ID instead:
1. When directly calling `BKE_library_foreach_ID_link` on an embedded ID.
2. When using recursive processing (`IDWALK_RECURSE`).
This commit mostly fixes both cases, by using `BKE_id_owner_get` to find
the owner ID when it is unknown.
There are some caveats here though: in a few specific cases (mainly ID
copying, and depsgraph ID copying), `BKE_library_foreach_ID_link` can be
called on embedded IDs which owner ID is not yet valid. In such case, a
new flag can be used to keep using the previous behavior
(`IDWALK_IGNORE_MISSING_OWNER_ID`).
Fixing the issue with copy code being unaware of the owner ID when
copying an embedded one should also be fixed, but this will be addressed
separately.
Note that as 'side efect', this commit also fixes a matching issue in
the `lib_remap` code, where the `IDRemap.id-owner` pointer would also
wrongly be set to the remapped embedded ID instead of its actual owner.
This change is not expected to have any effect in current codebase.
Currently for node tools we create and evaluate a temporary depsgraph
with all the selected object data-blocks and all data-blocks referenced
by the node tree.
Needless to say, this can be very slow when those data-blocks contain
arbitrary procedural operations. Re-evaluating all the selected objects
is particularly because it will give a slowdown even in very basic uses
of node tools.
Originally I hoped that geometry nodes could be made to work with
original as well as evaluated data-blocks. But that would require far
too many tricky changes and arguably isn't right design-wise anyway.
Instead of that, this commit makes node tools dependency graph
evaluation more fine-grained in a few ways.
1. Remove the evaluation of selected objects. These are always visible
in the viewport and part of the active depsgraph anyway. To protect
against cyclic dependencies, we now compare `orig_id` instead of the
object pointer itself.
2. Evaluate the node group and its dependencies in a separate depsgraph
used only when necessary. This allows using the original node tree
without any copies when it doesn't reference any data-blocks.
3. Evaluate IDs from node group inputs (from the redo panel) in the extra
depsgraph as well, only when necessary.
Pull Request: https://projects.blender.org/blender/blender/pulls/120723
Avoid re-copying the scene when the scene is tagged for frame change.
For scenes with many objects scrubbing & jumping between first/last
caused noticeably worse performances.
Resolve by:
- Returning false from need_tag_cow_before_update when the recalc flag
is ID_RECALC_FRAME_CHANGE.
- Change deg_graph_tag_parameters_if_needed to consider
ID_RECALC_FRAME_CHANGE a clean flag.
Ref !104801
Collections which were pointed by a modifier used to follow visibility of the
current object, and this visibility is static throughout the lifetime of the
dependency graph.
Change the code so that collections pointed by modifiers rely on the visibility
flushing, allowing to be optimized out from evaluation.
Pull Request: https://projects.blender.org/blender/blender/pulls/120516
This is actually a deeper issue, which roots to the fact that updating
relations of the dependency graph does not properly handle cases when an
operation was previously skipped from evaluation (i.e. as a visibility
optimization).
The fix is to preserve needs-update flag throughout relations update of
a dependency graph, similar to the entry tags.
Pull Request: https://projects.blender.org/blender/blender/pulls/120477
Expand the `AnimData` struct with an `Animation *` + an
`binding_stable_index` field, and properly handle those relations.
This also adds functionality for actually pointing animated IDs to
`Animation` data-blocks, and automatically hooking up the relevant
`Binding`.
The Depsgraph code is extended to take these new relations into account,
but doesn't trigger any animation evaluation yet.
For more info, see #113594.
Pull Request: https://projects.blender.org/blender/blender/pulls/118677
Regression since 7a2d04a5c4.
Mask evaluation is part of parameters component, and there is no explicit
tags other than copy-on-eval for masks in a lot of cases.
Restore the previous graph topology for the link from copy-on-eval to the
parameters components of mask ID.
Potential candidate for 4.1.1.
Pull Request: https://projects.blender.org/blender/blender/pulls/119956
A regression caused by 7a2d04a5c4.
The offending commit made it so selection tag does not imply parameters
update, which also avoids transitive re-evaluation of the curve geometry.
However, the active curve index is stored on a Curve, and curve modifier
stack creates a copy of the curve to hold the evaluation results, which
makes it so evaluated curve object does not intrinsically share the active
spline index.
This change makes it so changes in selection triggers geometry evaluation
on curves, matching the behavior prior to the offending commit.
AN ideal fix would somehow avoid such geometry re-evaluation, but it would
be a bigger change, not suitable for possible corrective release.
Potential candidate for 4.1.1.
Pull Request: https://projects.blender.org/blender/blender/pulls/119918
The issue was caused by 29aaa2922d.
With the change from the offended commit there was nothing that
would have informed objects previously linked to a light that they
need to re-calculate their light linking collections.
This change makes it so scene's hierarchy is tagged for update,
which propagates to all dependencies which do depend on hierarchy
of objects and collections in the scene.
This brings behavior closer to what it used to be, without causing
slowdown with full re-evaluation (which was fixed by the offending
commit).
Pull Request: https://projects.blender.org/blender/blender/pulls/119698
"Own" (the adjective) cannot be used on its own. It should be combined
with something like "its own", "our own", "her own", or "the object's own".
It also isn't used separately to mean something like "separate".
Also, "its own" is correct instead of "it's own" which is a misues of the verb.
Introduce new DNA for the `Animation` data-block and its sub-data.
This includes the blenkernel code for reading & writing to blend files,
and for memory management (freeing, duplicating). Minimal C++ wrappers
are included, with just the functionality needed for blenkernel to do
its job.
The Outliner code is extended so that it knows about the new data-type,
nothing more.
For more info, see issue #113594.
Pull Request: https://projects.blender.org/blender/blender/pulls/119077
This adds a new `DEG_graph_build_from_collection` function and related
pipeline to more easily build a graph of all relevant IDs from a given
Collection.
It was modeled after the `FromIDsBuilderPipeline` with the difference
being that the list of IDs is gathered from the Collection rather than
passed in. It also slightly differs in that the filtering class shares a
common `Set` rather than building it twice, once for the node builder
and once for the relation builder.
It will eventually be used for the Collection IO project where various
IO exporters will be tied to a Collection and will be limited to just
IDs contained in said Collection.
Pull Request: https://projects.blender.org/blender/blender/pulls/118732
`RootPChanMap` will be nullptr when building DEG object-level
constraints (as as opposed to bone constraints where this map is built
prior), and in that case we don't need to check for the common chains in
`bone_target_opcode`.
Thx @sergey for additional confirmation
Pull Request: https://projects.blender.org/blender/blender/pulls/118745
The depsgraph CoW mechanism is a bit of a misnomer. It creates an
evaluated copy for data-blocks regardless of whether the copy will
actually be written to. The point is to have physical separation between
original and evaluated data. This is in contrast to the commonly used
performance improvement of keeping a user count and copying data
implicitly when it needs to be changed. In Blender code we call this
"implicit sharing" instead. Importantly, the dependency graph has no
idea about the _actual_ CoW behavior in Blender.
Renaming this functionality in the despgraph removes some of the
confusion that comes up when talking about this, and will hopefully
make the depsgraph less confusing to understand initially too. Wording
like "the evaluated copy" (as opposed to the original data-block) has
also become common anyway.
Pull Request: https://projects.blender.org/blender/blender/pulls/118338
The `object_to_world` and `world_to_object` matrices are set during
depsgraph evaluation, calculated from the object's animated location,
rotation, scale, parenting, and constraints. It's confusing and
unnecessary to store them with the original data in DNA.
This commit moves them to `ObjectRuntime` and moves the matrices to
use the C++ `float4x4` type, giving the potential for simplified code
using the C++ abstractions. The matrices are accessible with functions
on `Object` directly since they are used so commonly. Though for write
access, directly using the runtime struct is necessary.
The inverse `world_to_object` matrix is often calculated before it's
used, even though it's calculated as part of depsgraph evaluation.
Long term we might not want to store this in `ObjectRuntime` at all,
and just calculate it on demand. Or at least we should remove the
redundant calculations. That should be done separately though.
Pull Request: https://projects.blender.org/blender/blender/pulls/118210
The issue was caused by Cycles doing dependency tracking on its
side, relying on the fact that view layer needs to be tagged as
modified when its properties change.
This was not the case when custom property on the a view layer is
modified via a driver.
Now the dependency graph will tag IDs which generic properties did
change as ID_RECALC_PARAMETERS, giving it a chance to render engines
to react to it.
Since this is quite generic code which might have unforeseen side
effects the change is not targeted to the current release branch.
Note that this chaneg does not fix the #103140, as the issue there
is use of RNA path to another data-block, without the node tree
registering relation to that data-block.
Pull Request: https://projects.blender.org/blender/blender/pulls/118134
This feature is useful for many production scenarios as it allows for the
creation of separate render passes with specific worlds. This would help
workflows that require different skies or other backgrounds for compositing.
Ref #117919
Pull Request: https://projects.blender.org/blender/blender/pulls/117920
This implements layer parenting and layer transforms.
* Adds a new "Transform" panel in the object-data properties with the (local) translation, rotation and scale.
* Adds a new "Relations" panel with the parent property (and also bone name in case the parent is an armature).
* When converting from GPv2 to GPv3, the parent and transforms are converted too.
* Bone names are updated if they are renamed in the armature.
Implementation details:
* The positions in the drawings are always in layer space. During extraction, we transform the positions to object space. Note that this could be optimized further and done in the render engine itself.
* This means that e.g. the selection code (which needs to know where the positions are on screen) now takes this transform into account.
* The layer transform is calculated when accessed (from the location, rotation, scale properties).
* Code that needs to know where the positions are on screen now takes this new transform into account.
Pull Request: https://projects.blender.org/blender/blender/pulls/117247
Since 1497005054, there is a new `ModifierData.persistent_uid` which
has more use cases than the old `session_uid`. This patch removes
`ModifierData.session_uid` and replaces its usages with the new `persistent_uid`.
Pull Request: https://projects.blender.org/blender/blender/pulls/117909
Cused by 29aaa2922d
This change is more of a work-around, since there should be no such
tagging required. This change brings the behavior closer to what it
was before the offending commit, and solve an immediate user-level
regression.
Pull Request: https://projects.blender.org/blender/blender/pulls/117834
The dependency graph builder takes the original data-block's recalc
flags to tag IDs after the dependency graph has been built, while
the evaluation of the graph only re-sets tho recalc flag to 0 only
for active dependency graph. This could have caused an inconsistency
of the handled tags: for example, if a headless render modifies some
object's properties and then renders the scene multiple times without
re-creating dependency graph (using Eevee or having Persistent Data,
and rendering multiple view layers, for example).
This change makes it so the recalc flags from the original ID are
only considered by active dependency graph, of when an ID is first
evaluated within a non-active dependency graph. This is a bit of a
conservative change to avoid possible breakage. In theory it should
be possible to never consider original recalc flags for render, and,
eventually, also ignore it for the active graphs. This needs to be
with more care and, so follow safer approach for now.
In practice this change fixes an issue with missing particle hair
when rendering second view layer of rlayer_flags_01.blend with Eevee.
Pull Request: https://projects.blender.org/blender/blender/pulls/117854
With this patch, materials are kept intact in simulation zones and bake nodes
without any additional user action.
This implements the design proposed in #108410 to support referencing
data-blocks (only materials for now) in the baked data. The task also describes
why this is not a trivial issue. A previous attempt was implemented in #109703
but it didn't work well-enough.
The solution is to have an explicit `name (+ library name) -> data-block`
mapping that is stored in the modifier for each bake node and simulation zone.
The `library name` is necessary for it to be unique within a .blend file. Note
that this refers to the name of the `Library` data-block and not a file path.
The baked data only contains the names of the used data-blocks. When the baked
data is loaded, the correct material data-block is looked up from the mapping.
### Automatic Mapping Generation
The most tricky aspect of this approach is to make it feel mostly automatic.
From the user point-of-view, it should just work. Therefore, we don't want the
user to have to create the mapping manually in the majority of cases. Creating
the mapping automatically is difficult because the data-blocks that should
become part of the mapping are only known during depsgraph evaluation. So we
somehow have to gather the missing data blocks during evaluation and then write
the new mappings back to the original data.
While writing back to original data is something we do in some cases already,
the situation here is different, because we are actually creating new relations
between data-blocks. This also means that we'll have to do user-counting. Since
user counts in data-blocks are *not* atomic, we can't do that from multiple
threads at the same time. Also, under some circumstances, it may be necessary to
trigger depsgraph evaluation again after the write-back because it actually
affects the result.
To solve this, a small new API is added in `DEG_depsgraph_writeback_sync.hh`. It
allows gathering tasks which write back to original data in a synchronous way
which may also require a reevaluation.
### Accessing the Mapping
A new `BakeDataBlockMap` is passed to geometry nodes evaluation by the modifier.
This map allows getting the `ID` pointer that should be used for a specific
data-block name that is stored in baked data. It's also used to gather all the
missing data mappings during evaluation.
### Weak ID References
The baked/cached geometries may have references to other data-blocks (currently
only materials, but in the future also e.g. instanced objects/collections).
However, the pointers of these data-blocks are not stable over time. That is
especially true when storing/loading the data from disk, but also just when
playing back the animation. Therefore, the used data-blocks have to referenced
in a different way at run-time.
This is solved by adding `std::unique_ptr<bake::BakeMaterialsList>` to the
run-time data of various geometry data-blocks. If the data-block is cached over
a longer period of time (such that material pointers can't be used directly), it
stores the material name (+ library name) used by each material slot. When the
geometry is used again, the material pointers are restored using these weak name
references and the `BakeDataBlockMap`.
### Manual Mapping Management
There is a new `Data-Blocks` panel in the bake settings in the node editor
sidebar that allows inspecting and modifying the data-blocks that are used when
baking. The user can change what data-block a specific name is mapped to.
Pull Request: https://projects.blender.org/blender/blender/pulls/117043
This significantly simplifies memory management, mostly by avoiding
the need to free the memory manually. It may also improve performance,
since std::string has an inline buffer that can prevent heap
allocations and it stores the size.
Pull Request: https://projects.blender.org/blender/blender/pulls/117695