Commit Graph

26758 Commits

Author SHA1 Message Date
Campbell Barton
f4308aa2d0 UV: remove per-UV-map selection data
Replace per UV map selection with a single UV selection for all UV's.
This uses the same data as UV sync select, meaning that it's no longer
possible to keep a different selection when sync-select is disabled.

There is a minor improvement to functionality - previously not possible
to de-select a single face surrounding by selected faces.
Now this is possible because true face selection is supported.

The selection from the active UV-map is converted to use the shared
selection data.

Ref !147523

Co-authored-by: Hans Goudey <hans@blender.org>
2025-10-08 15:05:20 +11:00
Campbell Barton
0fcbae8c00 Cleanup: spelling, duplicate terms (check_spelling_*)
Also add colon after argument params.
2025-10-07 23:55:12 +00:00
Christoph Lendenfeld
a09d0cfd8c Anim: Move pose bone selection state to bPoseChannel
Move the selection flag for pose bones, from the (edit)bone to the
pose bone.

Previously having multiple instances of armatures in pose mode at the
same time caused issues because selecting a pose bone on one armature
would automatically select it on all instances of it.

This is now fixed since the selection state is stored on the pose bone
(Object level) Doing so breaks API compatibility with 4.5 since the
RNA property on the Bone no longer affects the pose bone. Instead,
there is a new property on the pose bone for that.

Due to this change, some runtime flags for the transform system also
had to be moved to the pose bone. This is due to the fact that these
flags are used by the transform system to pass information between
functions. If we keep the flag at the bone level, this wouldn't work
with armature instances. See `bPoseChannelRuntimeFlag`

Fixes #117892

Pull Request: https://projects.blender.org/blender/blender/pulls/146102
2025-10-07 19:59:36 +02:00
Sean Kim
5e6c3e720d BKE: CurveMap: Update more curve presets
Similar to 9b5f23c7a3

This commit updates the remaining three non-trivial preset curve types:
* CURVE_PRESET_ROUND - approximating `sqrtf(2x - x^2)`
* CURVE_PRESET_ROOT - approximating `sqrtf(x)`
* CURVE_PRESET_SHARP - approximating x^2

Like in the above commit, this change only affects the defined presets,
but does not change any existing curves in any files.

Related to #145208

Pull Request: https://projects.blender.org/blender/blender/pulls/147012
2025-10-07 19:47:42 +02:00
Bastien Montagne
a6cea64b3a Fix #147461: Implement packed data support for generic ID copy-paste.
Adding support for packed IDs in the PartialWriteContext was completely
missed in initial work...

This somewhat complexifies the handling of libraries in
PartialWriteContext, as packed IDs need to be handled in specific ways.

It also exposes `bke::library::ensure_archive_library` as a public function,
to avoid duplicating this complex logic of finding or creating a new
archive library for a given ID.

Finally, prevent attempts to copy a packed ID for now, as pasting them
is not supported (linking/appending these directly is not supported).

Pull Request: https://projects.blender.org/blender/blender/pulls/147468
2025-10-07 16:11:47 +02:00
Cartesian Caramel
8f41d46d74 Constraint: Geometry Attribute
Add a new constraint called "Geometry Attribute", which directly
samples vector, quaternion, or 4x4 matrix attributes from geometry and
applies these to an object's or bone's transform.

This can be used to transfer data generated by geometry nodes to the
object or bone level. By default the constraint will sample a vector
on the vertex domain. The default attribute is `position` for
simplicity, but the attribute value does not have to have anything to
do with neither the transform of the geometry object nor the geometry
itself.

Pull Request: https://projects.blender.org/blender/blender/pulls/136477
2025-10-07 15:14:22 +02:00
Iliya Katushenock
157e7e0351 Mesh: Propagate attributes in automatic edge calculation
Support propagation of attributes from the original mesh edges when
generating mesh edges. This implies both deduplication of original edges
and creation of new edges needed for faces. While original edges are not
propagated, attributes are still propagated if an edge was part of any
face. To make original edges distinct we simply choose the first one to
be a value source.

One important part of this patch is definition of invariant of the
mesh on input:
1. All edges must be valid (their vertices must be correct). The
   algorithm only deal with duplicate and implicit edges.
2. There is no way to provide info about corner edges attribute (whether
   it'svalid or not). If all input edges are valid and there are no new
   edges then we could skip re-generation of already valid corner edge
   indices. But for now we always do.

The new implementation depends on input mesh invariant so this drops an
old patch to fix hard crash related with duplicate edge vertices. New
code will crash independently to such patch. Hopefully there must be
no problems after #138633.

The changes don't affect performance much. If anything, in some cases
the edge calculation can become a few percent faster. See the PR for
more performance testing details.

Pull Request: https://projects.blender.org/blender/blender/pulls/132492
2025-10-07 14:36:15 +02:00
Jacques Lucke
894d9883b1 Cleanup: Geometry Nodes: use cache mutex for lazy function graph generation
This is a more standard way to handle caches and avoids the need for
a custom double checked lock.

Pull Request: https://projects.blender.org/blender/blender/pulls/147345
2025-10-07 10:46:59 +02:00
Bastien Montagne
2f3b321f29 Fix (unreported): PackedID: Clear deephash when making them local.
Fixed the two most obvious entry points (actually making a linked ID
local, and making a local copy of linked data), there may be more
unusual ways to do that still hidden in the code though.

Also added a couple of 'sanity asserts' to the writefile code regarding
cases where IDs are expected to have a null deep_hash data.
2025-10-06 16:43:24 +02:00
Jacques Lucke
d7611d2c6b Fix: inverted return value 2025-10-06 16:19:18 +02:00
Jacques Lucke
90d10a8408 Fix #147175: packing baked data shows error
This showed an error while it actually worked as expected. The issue was that it
attempted to pack the entires named `.` and `..`, which have special meaning.
Filtering those out quiets the error message.

Pull Request: https://projects.blender.org/blender/blender/pulls/147455
2025-10-06 16:17:33 +02:00
Falk David
f694ef839d Cleanup: VSE: Rename for_each_callback to foreach_strip
The function name `for_each_callback` is ambigous (what are we iterating?)
and also doesn't align with the naming of other "for each" functions in Blender
which usually are named `foreach_<thing>` like `IndexMask::foreach_index`
or `animrig::foreach_fcurve_in_action` etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/147440
2025-10-06 14:02:32 +02:00
Falk David
6b75fe7658 Fix #147106: VSE: Show keyframes of compositor node trees in dopesheet
Any keyframes for properties inside the compositor node
trees that were used by strips did not show up in the dopesheet.
This was because the compositor tree is its own ID and needs to
be manually added by the dopesheet code.

This fix adds the node trees to the filtering code in
`animdata_filter_dopesheet_scene`.

Note that the dopesheet still uses the active scene as its context.
So this means that if the sequencer scene differes from the active
scene, the animation data from the sequencer scene will not
be shown. This is currently expected behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/147301
2025-10-06 12:17:17 +02:00
Hans Goudey
21d2ce19f8 Fix #147260: Freestyle mark not saved in files in some cases
When there was no other data written in the CustomData for edges
or faces, the layers pointer would be null, and even though the layer
array we write isn't empty, the writing would be skipped. The fix
is just to make sure the layer pointer isn't null.

Pull Request: https://projects.blender.org/blender/blender/pulls/147411
2025-10-06 02:25:09 +02:00
Falk David
bbfcffb54d Fix #147294: Crash when duplicating scene strip
Seems to have been introduced by 1104c69a0e.
In `BKE_paint_copy` the `src->runtime` can be `nullptr` in some cases.

This adds a check to make sure to only copy the settings
when `src->runtime` exists.

Pull Request: https://projects.blender.org/blender/blender/pulls/147304
2025-10-04 06:39:37 +02:00
Falk David
20921fef48 Cleanup: Copy toolsettings from source scene in scene_copy_data
This was copying the toolsettings from `scene_dst` which, confusingly,
will work because the ID got shallow copied before running
`scene_copy_data` so the pointer to `scene_dst->toolsettings` is the
same as `scene_src->toolsettings`.

This changes that line to copy from `scene_src->toolsettings` to
`scene_dst->toolsettings` to avoid any future confusion.
2025-10-03 17:54:16 +02:00
Bastien Montagne
258f449783 Refactor: Library: Be explicit about runtime data copied with ID copying.
Note that this commit keeps the same behavior as before this commit,
except for the newly introduced vector of archived libraries, which is
reset to empty. This behavior may have to be further tweaked still.

Root of the issue was from original commit enabling Library ID copying
(87a4c0d3a8), but the later move to an allocated runtime pointer
using a copy constructor in 87a4c0d3a8 made this behavior even
more confusing/hidden.

In general, what is re-used/copied in runtime data should be explicit,
such that by default new data can be assumed reset to their default
value there in the copy ID.
2025-10-03 17:16:32 +02:00
Jacques Lucke
2a0a07654a Geometry Nodes: add Voxel Index node
This node gives access to the integer coordinates of the the voxel that is
currently being evaluated by a field. It can be used together with e.g. the
Integer Math and Sample Grid Index node to sample neighboring voxel values.
Previously, one could only get the position of the voxel in object space.

Since sometimes field are evaluated on tiles of many voxels, just having the
voxel coordinates can be misleading. Therefore, this same node also outputs
whether it is a tile and the extent of the tile (which is 1 for normal voxels).

Pull Request: https://projects.blender.org/blender/blender/pulls/147268
2025-10-03 14:25:14 +02:00
Brady Johnston
66851c6c9a Fix: Geometry Nodes: Link drawing for grids and single values in Simulation Zone
Fixes link drawing for grids and single values connected through a Simulation
Zone. They are currently drawn as dashed field links and this PR adds
Simulation Zone to special link inference that is currently used for
Repeat Zone.

Pull Request: https://projects.blender.org/blender/blender/pulls/147035
2025-10-03 13:56:38 +02:00
Jacques Lucke
6e61eb9648 Fix: Geometry Nodes: packed baked volume grids can't be loaded 2025-10-03 11:43:33 +02:00
Kace
c989add4cd VSE: Sound pitch correction
Add sound pitch correction functionality, so that retimed sound strips
can preserve their original pitch.

This has been implemented as a GSoC 2025 project. Actual pitch
correction is done with Rubberband library, which has been already
included into Blender 5.0 library builds; and then most of the other
code has been in Audaspace, which was already updated within Blender
tree earlier.

So this PR just flips on Rubberband build option, and adds the
checkbox to VSE sound strips for pitch correction (on by default for
newly created sound strips). Pitch correction works with both
simple whole-strip retiming, as well as more complex retiming setups
where different parts of the strip use different speeds.

Co-authored-by: Aras Pranckevicius <aras@nesnausk.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/143347
2025-10-03 09:42:48 +02:00
Hans Goudey
6df0c2001b Mesh: Handle free custom normals properly for object joining
Use the same rules as the realize instances node to make sure that
free and tangent-space custom normals aren't joined together with
implicit conversions and that there is as little data loss as possible
when joining combinations of no custom normals, free normals, etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/147241
2025-10-03 01:57:51 +02:00
Hans Goudey
340f9d7ff3 Refactor: Use separate result for mesh joining, fix multires data join
Instead of modifying the active mesh in place, which means we can't
use the size of its data arrays when copying its data, and its caches
are immediately invalidated, copy data to a separate out-of-main
result mesh first. The only downside is that for a moment during
the operator the shape key array sizes will be out of sync with the
mesh size.

Also the custom data for multires layers wasn't copied properly
after the recent refactor that rewrote this code. Take the opportunity
to fix that too.

The motivation for this change is an improvement to copy different
kinds of custom normals properly to the joined mesh, which never
worked since free custom normals were introduced.

This contains a few changes to the expected results in the tests.
Those are edge cases, and the new results make more sense.
2025-10-03 01:57:49 +02:00
Hans Goudey
d3278249a8 Geometry Nodes: Volume grid Prune and Voxelize nodes
Add two common building blocks for volume-grid workflows.

- **Voxelize** turns all active tiles into fully dense voxels. For fog
  volumes, this will mean the "inside" sparse tiles will become
  individually adjustable voxel values.
- **Prune** is the opposite action as voxelize. It can be important for
  certain workflows when large regions of constant values are created.
  The node can collapsed those regions into more efficient tiles or
  inner nodes. There are a few modes which are each useful for
  different use cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/147148
2025-10-02 20:53:42 +02:00
Sean Kim
1ac1090271 Fix: 'Reset Curve' applies incorrect transformation for positive slopes
Currently, the 'Reset Curve' button, corresponding to the
`BKE_curvemap_reset` function, converts a predefined negative slope
curve to a positive slope by inverting the order of y axis points. This
has the implicit dependency on these points being at inverse x
positions. For most preset curves, this works well, but for the round
curve, which has points at 0, 0.5, 0.86, and 1, this condition does not
hold true.

To fix this, take the inverted x value for a given control point
instead of the raw value. For the above example this means that the
round curve now has x values at 0, 0.14, 0.5, and 1.

Pull Request: https://projects.blender.org/blender/blender/pulls/147008
2025-10-02 19:14:04 +02:00
Hans Goudey
a68d39e9d9 Cleanup: Formatting
Run `make format` after the library update in the previous commit.
2025-10-02 12:55:42 -04:00
Bastien Montagne
fdfbb3ad20 Fix (unreported) memleak in IDHash when computing the hash fails.
Code would early-return on failure, forgetting to free the xxhash state.

Use the `BLI_SCOPED_DEFER` util to ensure the state is always properly freed
when it gets out of scope.

Pull Request: https://projects.blender.org/blender/blender/pulls/147189
2025-10-02 16:26:03 +02:00
Bastien Montagne
289e5ef0b7 Fix #147057: Crash when Asset Library Pack-Importing a Missing Data Block.
Do not delete linked data if the packing fails.

Pull Request: https://projects.blender.org/blender/blender/pulls/147190
2025-10-02 16:20:08 +02:00
Jacques Lucke
9d20c8d3c8 Spreadsheet: show volume grid stats
This adds support for showing various stats of volume grids in the spreadsheet:
* Extent: Number of voxels in each direction of the bounding box of the grid.
* Voxels: Total number of active voxels in the grid. This includes all voxels
  which are stored in tiles (e.g. one leaf tile contains 512 voxels).
* Leaf Voxels: Number of active voxels stored in leaf nodes. This does not
  contain any voxels that are part of tiles.
* Tiles: Number of active tiles in the grid.
* Size: Estimated size of the volume grid in memory.

All these stats are cached on the volume grid now. A new `tag_tree_changed`
method has been added to invalidate the cache. Computing these stats is not
cheap (but not more than a few ms even for large grids). That mainly means that
we can't do it for socket inspection because that would cause too much overhead.
However, doing it just for the grids that are currently visible in the
spreadsheet seems fine and useful.

This also adds some general improvements to the spreadsheet:
* Support `int64_t` and `int3` columns.
* Draw ints with thousand separators.
* Support showing ints as number of bytes such as `23 MB`.

Pull Request: https://projects.blender.org/blender/blender/pulls/147191
2025-10-02 13:50:25 +02:00
Pratik Borhade
a48bb36588 Fix #147098: No Default Import method being set on new asset library path
`append and reuse` is chosen as default in DNA but this enumpropertyitem
isn't added to the array when `Non data block packing` is disabled in
Developer tools (see `rna_preference_asset_libray_import_method_itemf`).
To fix this, change default in DNA to `ASSET_IMPORT_PACK`. In case of
"non packing", change import_method inside `asset_library_add()`
function. Also introduce `rna_preference_asset_libray_import_method_default`
so that "reset to default value" operator works correctly.

Pull Request: https://projects.blender.org/blender/blender/pulls/147104
2025-10-02 13:27:13 +02:00
Campbell Barton
b78c5fadf3 Cleanup: various non functional changes for C++ 2025-10-01 23:22:44 +00:00
Campbell Barton
74a7cd4d41 Build: unbreak building WITH_OPENVDB=OFF 2025-10-01 21:45:21 +00:00
Hans Goudey
a774ebd5af Geometry Nodes: Field to Grid Node
The purpose of this node is to create a grid with new voxel values on
the same grid topology as an existing grid. The new values are the
result of field evaluation. Multiple grids can be created at the same
time, so that intermediate results used for multiple grids can be
efficiently reused during evaluation. This is more efficient than the
"Volume Cube" node, for instance, because the output grid shares the
sparseness of the input topology grid.

Pull Request: https://projects.blender.org/blender/blender/pulls/147074
2025-10-01 18:40:49 +02:00
Lukas Tönne
059ac46439 Fix #147129: Crash when using zone pointer without null check
The zone add operator necessarily has to add the input and output nodes
separately one at a time. After the first node is added a tree update is
executed, but the zone is incomplete and the runtime update will temporarily
remove all zones until the second node is added. Using zone lookup without
checking the pointer will crash in this state.

Pull Request: https://projects.blender.org/blender/blender/pulls/147131
2025-10-01 16:44:40 +02:00
Habib Gahbiche
fb7818e55e Python: Create default node tree for new materials and worlds
The motivation is to keep backward compatibility after deprecating
 `material.use_nodes()` and `world.use_nodes`. For example the
following script would behave the same way in 4.5 and 5.0:
```python
mat = bpy.data.materials.new("My new mat")
mat.use_nodes = True
```

Pull Request: https://projects.blender.org/blender/blender/pulls/147052
2025-10-01 15:05:16 +02:00
Bastien Montagne
3f6ef965b9 Refactor: LightLinking: Add creation/copy/delete API for Object data.
Similar to what we do with modifiers, constraints, and so on. Avoids
spreading knowledge about internal data handling in several parts of the
code.

Pull Request: https://projects.blender.org/blender/blender/pulls/147122
2025-10-01 15:03:41 +02:00
Sean Kim
0a72429ea8 UV Sculpt: Rename strength_curve and curve_preset
Similar to 327a1925cf

* Renames `strength_curve` to `curve_distance_falloff`
* Renames `curve_preset` to `curve_distance_falloff_preset`

These changes are done for consistency with the other concepts in the
other paint modes.

Pull Request: https://projects.blender.org/blender/blender/pulls/147071
2025-09-30 20:57:19 +02:00
Lukas Tönne
8697bffe22 Fix #146946: Breaking a node zone crashes on valid pointer assumption
The Node Wrangler addon has a _Reset Nodes_ operator that can remove the input
node of a node zone. This crashes in reference set updates because the code
expects valid input/output node pairs in each zone.

The fix is two-fold:
1. Finding zones for the runtime now returns an empty result to ensure no
  invalid node pointers are being accessed. This should not happen in practice,
  all operators should make sure zone relationships are not broken.
2. The node wrangler addon is updated to ignore all zone types, including the
  newer repeat, closure, and for-each-element zones. The type filtering was
  outdated and now uses the `bl_idname` consistently.

Pull Request: https://projects.blender.org/blender/blender/pulls/147028
2025-09-30 10:49:20 +02:00
Sybren A. Stüvel
acde9be6fd Fix: correctly update Actions when renaming/re-typing a custom property
Fix: correctly update Actions when renaming/re-typing a custom property

When renaming a custom property on a data-block, only update the
animation in a slot for that data-block. Previously all F-Curves were
updated, even when they were meant for other data-blocks.

This also handles the cases where the type of a custom property is
changed, and not just its name.

This is part of #146586

Pull Request: https://projects.blender.org/blender/blender/pulls/146979
2025-09-30 10:23:20 +02:00
Sean Kim
af8cb99b10 Paint: Add asserts for BKE_brush_curve_strength
Neither the `distance` or `brush_radius` parameters make sense to be
negative and can cause odd behaviors.

Pull Request: https://projects.blender.org/blender/blender/pulls/146698
2025-09-29 19:13:56 +02:00
Jacques Lucke
ae2034e6c5 Attributes: make id attribute generic instead of built-in
The "id" attribute was built-in on curves (point domain), mesh (point domain)
and instances, but not on e.g. point clouds. This mismatch causes issues because
of the special rules regarding built-in attribute propagation. Furthermore, an
implication of this was that the id attribute had to be an integer attribute on
a specific domain, which is not always ideal.

This patch turns the id attribute into a normal generic attribute, except that
some nodes internally modify this attribute in special ways. This may cause some
compatibility breakage in rare cases, but that can generally be easily fixed by
either removing the id attribute or setting it explicitly on the right domain. I
can't think if a feasible way to avoid this unfortunately.

The internal special cases for the id attributes are generally skipped unless
the attribute is an integer attribute on the point/instance domain.

Pull Request: https://projects.blender.org/blender/blender/pulls/146941
2025-09-29 18:47:51 +02:00
Jacques Lucke
01ccf31d20 Fix: Nodes: propagated menu expanded state to group input
Previously, when a new group input was created from an expanded menu
socket, the expanded flag was not set on the group input.
2025-09-29 18:28:20 +02:00
Jacques Lucke
ef92735a95 Nodes: support optional labels for group inputs
Built-in nodes already used the functionality to hide the input labels in a few
situations. However, this functionality was not exposed for node groups before.
It required some refactoring to get the semantics of the flag right. The tricky
aspect is that "Hide Label" would be an incorrect name, because the label is
still shown under various circumstances. Instead, the flag merely indicates that
drawing code may skip drawing the label.

This adds a new "Optional Label" input for node group inputs. Other names are
possible like "Requires Label" which would be the inverse.

Overall the implementation is pretty straight forward after
1f489ea31a,
469a70dba9 and
f79896f5b9.

Pull Request: https://projects.blender.org/blender/blender/pulls/146939
2025-09-29 18:14:41 +02:00
Jacques Lucke
02bdc709c2 Shader Nodes: support Menu Switch node
This implements the Menu Switch node in shader nodes. It's the same node that is
used in Geometry Nodes and the Compositor.

The Menu Switch node is purely handled during preprocessing and thus builds on
top of #141936. Hence, it's input has to be a single value, just like the
iteration count for repeat zones. This limitation can be lifted in the future,
but currently there is no way to produce a non-single menu value in shader
nodes. This will become possible if other Switch nodes are added though.

Pull Request: https://projects.blender.org/blender/blender/pulls/146896
2025-09-29 17:26:38 +02:00
Pablo Vazquez
b5a6587ef9 Cleanup: Make format 2025-09-29 17:15:04 +02:00
MattiasF
29b27bb19b Curves: Numerically robust curve tangents
Current approach for computing the curve tangent approximations using
the average of the sum of the normalized segment direction vectors
suffers from catastrophic cancellation as the angle between the segments
approach 0°, with increasingly large error in resulting tangent.

Improving current behavior by conditionally computing the tangent using
the cross product to rotate the difference around the orthogonal axis
show a significant improvement for small angles. For segments in an axis
aligned plane, additional errors from computing the cross product is
avoided as terms cancel out. When the rotation axis is not axis aligned,
the method still shows a constant improvement for angles smaller
than ~45°.

Changes improves behavior for cases such as #145558.

For more information see https://projects.blender.org/blender/blender/pulls/146332.

Pull Request: https://projects.blender.org/blender/blender/pulls/146332
2025-09-29 16:45:12 +02:00
Lukas Tönne
b121142828 Fix #144983: Skip attribute transfer when no attribute writer is created
Attribute writer creation can fail in cases where a built-in attribute exists
and prevents arbitrary name/type/domain combinations. In those cases the
attribute should just be skipped.

Pull Request: https://projects.blender.org/blender/blender/pulls/146976
2025-09-29 16:38:31 +02:00
Bastien Montagne
24a33045cd Fix #146763: Texture Paint Memory Leak.
Deletion of NTree IDs through custom code path using
`blender::bke::node_tree_free_tree` is fully by-passing standard ID
management code, and was missed when ID::runtime was made an allocated
pointer.

We should really spend some time at some point to get these custom temp
node IDs handling code under control, there should be little to no need
for all this custom allocation and deletion code anymore nowadays.
2025-09-29 15:05:40 +02:00
Lukas Tönne
8f8d267a69 Fix #146145: Fluid domain initialization uses face attribute without checking
Attribute VArray is only valid if there actually are faces in the geometry.

Pull Request: https://projects.blender.org/blender/blender/pulls/146974
2025-09-29 14:47:22 +02:00
Casey Bianco-Davis
e8bb5a6558 Python: Rename IDType_ID_GP.name_plural to grease_pencils
This renames `IDType_ID_GP.name_plural` for Grease Pencil from
`grease_pencil_v3` to `grease_pencil`.

Part of #125058.

Pull Request: https://projects.blender.org/blender/blender/pulls/146903
2025-09-29 12:33:42 +02:00