Commit Graph

2215 Commits

Author SHA1 Message Date
Hans Goudey e0567eadbd Cleanup: Use FunctionRef for IDProperty iteration callback
Avoid the need for a seaprate user_data argument.
2024-03-26 15:39:39 -04:00
Hans Goudey efee753e8f Cleanup: Move BKE_idprop.h to C++ 2024-03-26 13:07:04 -04:00
Sergey Sharybin d3504a6bab Fix #119907: Active curve vertex/spline not visualizing properly
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
2024-03-26 13:58:55 +01:00
Hans Goudey c61ecf1f40 Cleanup: Move Mesh edit_mesh pointer to runtime data
The edit mesh is never saved to files, so it should be in the runtime struct.

Pull Request: https://projects.blender.org/blender/blender/pulls/119766
2024-03-21 23:18:49 +01:00
Sergey Sharybin e0b413f818 Merge branch 'blender-v4.1-release' 2024-03-20 16:06:36 +01:00
Sergey Sharybin 4eab8fae5a Fix #119697: Incorrect update after disabling light linking
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
2024-03-20 16:06:06 +01:00
Brecht Van Lommel 7a395e2e7f Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was f57e4c5b98.

After this one more fix was committed, this one is preserved as well:
67bd678887.
2024-03-18 15:04:12 +01:00
Hans Goudey 744f3b2823 Cleanup: Grammar in comments: Fix uses of "own"
"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.
2024-03-07 16:23:35 -05:00
Sybren A. Stüvel 90ef46baa1 Anim: DNA for `Animation` data-block
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
2024-03-07 16:41:25 +01:00
Jesse Yurkovich 7bf4247b09 Depsgraph: add a DEG_graph_build_from_collection convenience function
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
2024-03-04 06:25:33 +01:00
Bastien Montagne de5451b112 Cleanup: Move `BKE_anim_data` header to be fully C++. 2024-02-28 11:51:03 +01:00
Philipp Oeser 663c1ea14d Merge branch 'blender-v4.1-release' 2024-02-26 17:16:33 +01:00
Philipp Oeser ae022e515b Fix 104657: crash when trying to create a Pivot Constraint for armature
`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
2024-02-26 17:15:58 +01:00
Brecht Van Lommel 0f2064bc3b Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was 4bf6a2e564.
2024-02-19 15:59:59 +01:00
Hans Goudey 81a63153d0 Despgraph: Rename "copy-on-write" to "copy-on-evaluation"
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
2024-02-19 15:54:08 +01:00
Campbell Barton 5c87dfd269 Cleanup: use BLI_time_ prefix for time functions
Also use the term "now" instead of "check" for clarity.
2024-02-15 13:15:56 +11:00
Hans Goudey a52323d711 Cleanup: Move BKE_duplilist.hh to C++ 2024-02-14 10:51:46 -05:00
Hans Goudey 1c0f374ec3 Object: Move transform matrices to runtime struct
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
2024-02-14 16:14:49 +01:00
Campbell Barton aa6ab9caf9 Cleanup: various non-functional changes for C++ 2024-02-14 13:56:58 +11:00
Sergey Sharybin 18b594075c Fix #118034: Cycles: Driven View Layer property not considered in realtime
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
2024-02-12 12:52:43 +01:00
Bastien Montagne 5aaadebbe4 Cleanup: Make `BKE_scene.h` a full Cpp header. 2024-02-10 19:16:25 +01:00
Bastien Montagne 54618dbae3 Cleanup: Make `BKE_global.h` a Cpp header. 2024-02-10 18:25:14 +01:00
Bastien Montagne e71ae3b16c Cleanup: Move `BKE_collection.h` to CPP header. 2024-02-09 19:42:38 +01:00
Bastien Montagne deab8c085a Cleanup: Move `BKE_callbacks.h` and `BKE_cachefile.h` to CPP headers. 2024-02-09 19:29:34 +01:00
JonasDichelle f2e27ef7b6 Cycles: Override World option per View Layer
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
2024-02-09 12:16:16 +01:00
Falk David 0a45acbe3b GPv3: Layer Parenting/Transforms
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
2024-02-07 16:28:14 +01:00
Jacques Lucke 29e2dcd2c8 Modifiers: remove modifier session_uid in favor of persistent_uid
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
2024-02-06 18:02:32 +01:00
Campbell Barton 9996d95ab9 Cleanup: spelling in comments 2024-02-06 22:28:10 +11:00
Sergey Sharybin 7abc1bc7d4 Fix #117760: Regression: Ctrl+Z causes Losing Audio Sound
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
2024-02-06 09:06:46 +01:00
Sergey Sharybin 4f0ec384ce Fix incorrect update tag handling in inactive depsgraphs
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
2024-02-05 16:59:14 +01:00
Jacques Lucke 2d2b087fcf Geometry Nodes: support baking data block references
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
2024-02-01 09:21:55 +01:00
Hans Goudey f04bc75f8c Cleanup: Use std::string for some RNA function return values
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
2024-01-31 17:08:09 +01:00
Hans Goudey 19e2b13cec Cleanup: Move BKE_key.h to C++ 2024-01-30 14:42:13 -05:00
Jacques Lucke 932b2d1727 Cleanup: simplify naming of get_default_hash 2024-01-26 11:45:56 +01:00
Hans Goudey 500f09b88a Cleanup: Move metaball BKE headers to C++ 2024-01-24 11:46:39 -05:00
Hans Goudey 02582213de Cleanup: Move BKE_layer.hh to C++ 2024-01-24 10:55:16 -05:00
Campbell Barton 6cc8ac7cb3 Cleanup: rename ImBuf anim & anim_index structs
Rename: anim -> ImBufAnim
Rename: anim_index -> ImBufAnimIndex

There were cases where removing redundant "struct" qualifier caused
a warning since the name of the struct member was also anim.

Use uppercase type name to conform with other types names.

Ref !117394
2024-01-23 20:26:55 +11:00
Jacques Lucke 311ca3e6af Core: rename Session UUID to Session UID
`UUID` generally stands for "universally unique identifier". The session identifier that
we use is neither universally unique, nor does it follow the standard. Therefor, the term
"session uuid" is confusing and should be replaced.

In #116888 we briefly talked about a better name and ended up with "session uid".
The reason for "uid" instead of "id" is that the latter is a very overloaded term in Blender
already.

This patch changes all uses of "uuid" to "uid" where it's used in the context of a
"session uid". It's not always trivial to see whether a specific mention of "uuid" refers
to an actual uuid or something else. Therefore, I might have missed some renames.
I can't think of an automated way to differentiate the case.

BMesh also uses the term "uuid" sometimes in a the wrong context (e.g. `UUIDFaceStepItem`)
but there it also does not mean "session uid", so it's *not* changed by this patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/117350
2024-01-22 13:47:13 +01:00
Sergey Sharybin 29aaa2922d Fix performance issue when tagging relations for update
The relations update code does tagging needed to ensure that the
array of bases is updated when relations are updated. It was done
by tagging the Scene ID node, and potentially recursing into all
dependent depsgraph nodes. If there is a driver on a scene property
it was unnecessarily re-evaluated.

This solves the slow behavior of adding objects in the test file
from #117335.

Pull Request: https://projects.blender.org/blender/blender/pulls/117403
2024-01-22 12:27:55 +01:00
Sergey Sharybin 7a2d04a5c4 Fix #117335: Slow selection in scene with drivers
Change parameters tagging from implicit based on the copy-on-write to
more explicit, allowing to ignore tagging of parameters component for
changes which do not affect drivers.

There is still implicit parameters tagging based on tags for geometry
or transform components to avoid making changes in too many places of
Blender.

Should be no functional changes, only expecting better performance.

Pull Request: https://projects.blender.org/blender/blender/pulls/117336
2024-01-22 11:23:19 +01:00
Sergey Sharybin 85ff988f99 Depsgraph: Move scene evaluation node to own component
This node is needed to ensure evaluation order of scene and modifiers
which might access scene for custom data masks, or for the current
frame.

Move it to own component, so that evaluation of scene does not lead
to changes in the parameters component, hence does not trigger
driver evaluation.

Should be no functional changes.

Ref #117335
2024-01-22 11:23:14 +01:00
Bastien Montagne af5731ce03 Cleanup: Move `BKE_idtype.h` to Cpp header `BKE_idtype.hh` 2024-01-20 19:17:36 +01:00
Jacques Lucke 4b47b46f9c Cleanup: rename PIL to BLI
The term `PIL` stands for "platform independent library." It exists since the `Initial Revision`
commit from 2002. Nowadays, we generally just use the `BLI` (blenlib) prefix for such code
and the `PIL` prefix feels more confusing then useful. Therefore, this patch renames the
`PIL` to `BLI`.

Pull Request: https://projects.blender.org/blender/blender/pulls/117325
2024-01-19 14:32:28 +01:00
Sergey Sharybin 1dfb41bc75 Fix #117280: Cycles: Lights from instancer not working randomly
The issue was caused by light and shadow linking runtime data not
evaluated first time for lights linked to scene indirectly.

Simple solution is to hook up shading component to the instance
operation, so that visibility flag is properly propagated to the
shading component, and the light linking is evaluated.

Do it as non-flushing operation to prevent possible unwanted
re-evaluated of instancers.

Pull Request: https://projects.blender.org/blender/blender/pulls/117301
2024-01-19 09:24:59 +01:00
Sergey Sharybin 2cc6eab244 Cleanup: Simplify tracking of relations for instancing
Instead of having a set of hardcoded rules in the collection and
object instance collection builder introduce new node on object's
INSTANCING component which is to be hooked up to the node which is
duplicating the object.

Should be no functional changes.
2024-01-19 09:24:57 +01:00
Sergey Sharybin fc42227b2d Cleanup: Make duplication node and ocmponent name more clear
Follow the new terminology of instancing, and make it clear what
side it is (instancer or instancee).
2024-01-19 09:24:57 +01:00
Sergey Sharybin efba5f0432 Depsgraph: Add explicit object shading exit operation
Currently there is no functional changes.

In the future it allows to more easily hook the shading component
to other nodes to ensure the visibility flow.

Note that since the operation is not used by any relation it will
appear disconnected in the graphviz debugger. This is due to the
current behavior of deg_graph_remove_unused_noops().
2024-01-19 09:24:57 +01:00
Bastien Montagne 03c1cc4310 Cleanup: Move `BKE_lib_query` header to Cpp era. 2024-01-18 12:21:19 +01:00
Hans Goudey 3e76a1a6c2 Cleanup: Move BKE_lib_id.h to C++ 2024-01-15 12:44:14 -05:00
Bastien Montagne 4fe4a52cd7 Fix missing tagging of collections in some BKE_collections codepath.
In particular, while Object (un)linking was already tagged in relevant
BKE code, collection (un)linking was not in several cases.

This was (partially) done by user code, though almost never for the
whole hierarchy of parents.

Technically, the tag is done as part of
`collection_object_cache_free_parent_recursive`/`collection_object_cache_free`,
since currently clearing this cache is done everytime to collection
hierarchy or their content is modified.

It also removes `collection_tag_update_parent_recursive`, which was
already doing something similar, but was only called from code
adding/removing objects to collections, and was walking the same parent
hierarchy as `collection_object_cache_free_parent_recursive`.

This commit implements the decision made in #116601, to tag modified
data as close as possible from the code modifying it.

---------------------

This has an impact on deg tagging, which takes over twice as much cycles
with this commit compared to previous code  when opening a Pets production
file with several liboverrides (`deggraph_id_tag_update_single_flag` goes
from less than 0.03% to over 0.06%).

The overhead remains extremely low though, and is totally unmeasurable in
global execution timing. Timing of the liboverride processing on opening
the production file also did not show any measurable differences.

Pull Request: https://projects.blender.org/blender/blender/pulls/116986
2024-01-12 16:24:22 +01:00