Commit Graph

28865 Commits

Author SHA1 Message Date
Hans Goudey
cec05ab440 Cleanup: Use mesh helper functions to access vertex group data 2025-07-10 16:17:05 +02:00
Hans Goudey
c21a98d76a Cleanup: Use references for CustomData arguments in data transfer 2025-07-10 16:17:05 +02:00
Hans Goudey
325ceabb09 Fix #141721: Adding curve attributes doesn't invalidate caches
In this report, adding the "resolution" attribute didn't clear the
evaluated positions cache. In some cases capturing an attribute on
the mesh might just add the mesh rather than using an attribute
writer.
2025-07-10 10:02:25 -04:00
Nathan Vegdahl
69433a181e Fix #141024: Normalize active vertex group properly
When manually setting a group's vertex weight, auto-normalization would
fail in some circumstances, such as when all other groups are locked.

The root cause of this issue was our approach for ensuring that the
weight specified by the user remained as-is when possible during
normalization. Rather than "when possible", it erroneously *always*
ensured the weight stayed as-is even when that made normalization
impossible. It came down to this:

1. Normalization is done as a post process, with no knowledge of what
   changes were just made to the weights.
2. In order to (try to) make up for that and ensure that the just-set
   weight remains as the user specified, the active group was
   temporarily locked during normalization, which could prevent
   normalization in some cases.

This PR fixes the issue by introducing a new internal-only concept of
"soft locked" vertex groups to the normalization functions, intended to
be used in exactly these cases where there are weights that have just
been set and we want to avoid altering them when possible. Soft-locked
groups are left untouched whenever normalization is achievable without
touching them, but are still modified if normalization can't be achieved
otherwise.

This has been implemented by introducing a new bool array alongside the
"locked" bool array in the core normalization functions.  Although all
uses in this PR only ever specify a single group as "soft locked", using
a bool array will make it easy to use this concept in other weight
painting tools in the future, which may modify more than one group at
once.

Pull Request: https://projects.blender.org/blender/blender/pulls/141045
2025-07-10 14:51:50 +02:00
Nathan Vegdahl
caddde1eb7 Refactor: Clean up and modernize core vertex weight normalize functions
- Add code documentation.
- Use Span and references rather than pointers everywhere.
- Move all core normalization logic into
  `BKE_defvert_normalize_lock_map()`, and have the other variants call
  that. This keeps all the logic in one place, which will help make
  future changes easier since they only need to be made in one place.
- Add unit tests for `BKE_defvert_normalize_lock_map()`.
- Refactor `vgroup_normalize_all()` to be clearer and avoid an
  unnecessary `goto`.
- Make both `vgroup_normalize_all()` and `paint_weight_gradient_exec()`
  only call into a single core vertex normalization function, rather
  than branching into one of many.

No functional change intended.
2025-07-10 14:51:49 +02:00
Campbell Barton
ad29066d9c Merge branch 'blender-v4.5-release' 2025-07-10 21:10:20 +10:00
Campbell Barton
841b3e9d81 Fix: avoid divide by zero in the "Stretch To" constraint
A zero scaled axis resulted in the matrix containing NAN values.
Use `safe_divide` to avoid this.

Ref !141654
2025-07-10 21:05:52 +10:00
Pratik Borhade
f4dbe20940 Fix: Grease Pencil: Assert duplicating layer with attributes
When duplicating a layer with layer attribute, caught an assert hit
at `attribute_to_writer()` due to size mismatch between attribute
domain (layers count) and attribute length.
Now fixed by moving `add_node()` prior to `foreach_attribute()`. This way,
extra node already added to runtime data and layer count is updated
inside `ensure_nodes_cache` with the next layers() call

Noticed it during review of !141090

Pull Request: https://projects.blender.org/blender/blender/pulls/141722
2025-07-10 12:13:30 +02:00
Campbell Barton
5dd160c39c Cleanup: indentation in cmake, sort files 2025-07-10 00:40:42 +00:00
Brecht Van Lommel
4653b65f7c Logging: Add DEBUG, TRACE severity, replace numeric levels
The numeric levels have no obvious meaning. This removes the distinction
between severity and levels, instead there is a single list of named levels
with defined meaning.

Debug means information that's mainly useful for developers, and trace is for
very verbose code execution tracing.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Brecht Van Lommel
8d8e61fefd Logging: Change various categories and log levels
* Remove bke, ed and wm prefixes
* Add prefixes like: geom, object, blend, lib.
* Shorten some category names
* A few log level changes to improve --log-level info output

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Brecht Van Lommel
15d5f957ac Logging: Use CLOG for render progress
* Add render category, which is automatically enabled when using -f or -a
  command line flags for background rendering.
* Add extra logs to mention scene, view layer and frame ahead of time rather
  than including it in every line.
* Remaining time was removed from Cycles, this will be added back for animations
  at the render pipeline level.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Brecht Van Lommel
9e0e860835 Logging: Redirect BKE_report prints to CLOG
For more consistent formatting of logs.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:25 +02:00
Thomas Dinges
82f75f22ef Release: Bump 4.5 to release candidate 2025-07-09 12:56:08 +02:00
Lukas Tönne
bb293e5677 Regression test for armature deformation on lattice
This is a basic armature deformation test for #141535  using Lattices instead of
Mesh as the target object type. Lattice deformation was briefly broken, which is
caught by this test.

The test adds the general-purpose `unit_test_compare` function to lattice object
data. It only compares lattice point counts and positions for now, more data can
be added later if necessary.

The `MeshTest` class did not support lattice object types yet, so needed some
changes. The Curves case was already supported, but only by full conversion to
mesh data, without actually using the `unit_test_compare` function specific for
curves geometry. This is unchanged, because applying constructive modifiers on
curves does not work. If it were not for this limitation the test could do
actual curves comparisons now.

For lattice support the `MeshTest` class comparison function has been
generalized to all supported object data types. It runs the appropriate
`unit_test_compare` api function and validation where supported (only meshes at
this point).

Pull Request: https://projects.blender.org/blender/blender/pulls/141546
2025-07-09 09:53:00 +02:00
Campbell Barton
93ae46c68b Merge branch 'blender-v4.5-release' 2025-07-09 15:53:30 +10:00
Campbell Barton
35882493f4 Merge branch 'blender-v4.5-release' 2025-07-09 15:53:28 +10:00
Campbell Barton
0d944c16c6 Fix: assertion filling curve caps with a zero normal vector
Don't attempt to fill curve caps when the direction vector is invalid.

This prevents the crash in #141612 however the root cause of that
report isn't directly related to curve filling.
2025-07-09 15:44:22 +10:00
Campbell Barton
3d6e9756c7 Fix #141400: Metaball tessellation unresponsive with a scaled parent
The check to prevent overly complex tessellation checked the objects
scale directly instead of the final evaluated scale.

Also corrects the scale check which wasn't accounting for negative axes.
2025-07-09 15:23:42 +10:00
Sean Kim
ab7a30b1bd Refactor: Use std::array and blender::Span instead of pointer array
* Changes pointer array to std::array of optionals
* Returns by value
* Passes blender::Span to dependent functions

Pull Request: https://projects.blender.org/blender/blender/pulls/141586
2025-07-09 02:02:16 +02:00
Sean Kim
f80a3e5cbc Refactor: Add explicit default initialization to reshape_smooth structs
Pull Request: https://projects.blender.org/blender/blender/pulls/141585
2025-07-09 00:26:37 +02:00
Hans Goudey
13f32fdf6c Merge branch 'blender-v4.5-release' 2025-07-08 10:14:45 -04:00
Hans Goudey
4eefd4d6dc Fix: Potential assert in curves AttributeStorage versioning
The runtime type map needs to be updated even if the CustomData
ends up being empty.
2025-07-08 10:04:01 -04:00
Campbell Barton
cce5dee245 Merge branch 'blender-v4.5-release' 2025-07-08 20:35:22 +10:00
Falk David
a1893bf5e1 Fix #139194: Grease Pencil: Crazyspace deformation broken when evaluated layers don't match original
When the layer tree in the evaluated state of the Grease Pencil object changed,
the code would fail to get the crazyspace deformation.

Currently we rely on a 1 to 1 index mapping of the original and evaluated
layers. For obvious reasons, this is very weak and can easily break.

The new implementation works as follows:
* Caller that wants to get the crazyspace deformation passes the evaluated and original
   object + the original drawing to get the deformation of.
* Fallback deformation are the original positions.
* If there are drawing edit hints in the evaluated geoemtry set, then
  * find the edit hint that corresponds to the original drawing
  * use the positions in the edit hint.

To create the drawing edit hints, we need to know what evaluated layer corresponds
to which original layer. Currently, this simply stores the original layer index on the
evaluated layer runtime data.

The solution is not ideal and there are some possible improvements like:
* Find a way to solve the more general case, e.g. when there are multiple original
  IDs involved.
* Propagate the "mapping" to original layers even when the type of geometry is
  changed, like going to curve instances and back.

Pull Request: https://projects.blender.org/blender/blender/pulls/139285
2025-07-08 12:11:42 +02:00
Benjamin Beilharz
b709984df6 Compositor: Add Extension Mode for Transform node
This commit introduces the extension modes to the transform node and
further streamlines the node properties by wrapping all props in a node
storage. Therefore, the interpolation mode has been removed from the
custom properties of the node and moved into the node storage.

Pull Request: https://projects.blender.org/blender/blender/pulls/141487
2025-07-08 11:34:29 +02:00
Benjamin Beilharz
00ed2030cb Compositor: Add Extension Mode for Scale node
This commit introduces Extension Mode for the Scale node.

Pull Request: https://projects.blender.org/blender/blender/pulls/141485
2025-07-08 11:07:28 +02:00
Hans Goudey
75f4cd19e6 Merge branch 'blender-v4.5-release' 2025-07-07 16:17:40 -04:00
Hans Goudey
0ce5738415 Fix #141262: Undo speed regression (4.5)
The memfile undo data-block change detection didn't work for meshes
because we ended up writing a new pointer every time. In practice the
array the pointer references is always empty anyway, so we can just add
a check and write null instead.

Unfortunately this fix only applies to 4.5, since the attribute DNA
data (which is actually used at runtime in 5.0) is created temporarily
specifically for writing, so it gets a new address every time.
We'll probably need to solve #127706 in 5.0 to fix this.

Pull Request: https://projects.blender.org/blender/blender/pulls/141457
2025-07-07 22:06:59 +02:00
Sean Kim
333e2068b6 Fix #141556: Multires Apply Base deforms mesh greatly
Introduced in 27433106cd

Pull Request: https://projects.blender.org/blender/blender/pulls/141566
2025-07-07 19:27:26 +02:00
Sean Kim
7f3aa617ce Refactor: Move Paint_Runtime out of DNA
This commit takes the previously defined `Paint_Runtime` struct and
moves it into the BKE namespace, initializing it on demand instead of it
being a default-allocated member. This data does not need to be
persisted and is runtime only.

Pull Request: https://projects.blender.org/blender/blender/pulls/141413
2025-07-07 16:53:12 +02:00
Lukas Tönne
090d3ea994 Refactor: Armature deform API and threading function cleanup
Improved readability of `armature_deform.cc` high level API functions
by using spans, references, and optional values instead of raw pointers.
Threading callbacks are reorganized to avoid unused function parameters
in code branches and makes it easier to verify which parts of the code
are executed for given input arguments.

Pull Request: https://projects.blender.org/blender/blender/pulls/141453
2025-07-07 15:50:38 +02:00
Lukas Tönne
c40d8f50b6 Fix #141535: Lattice deform without dverts causes crash
Using armature deformation with a lattice object that doesn't have
vertex groups creates an invalid span that crashes during deformation.
This was caused by refactoring which replaced raw pointers with spans,
but has to check for nullptr to avoid creating an invalid span.

Pull Request: https://projects.blender.org/blender/blender/pulls/141538
2025-07-07 12:01:01 +02:00
Campbell Barton
0ceedc2a7d Cleanup: various non-functional changes in C++ 2025-07-05 09:03:09 +10:00
Campbell Barton
932d37ba0b Cleanup: sort file lists in CMake 2025-07-05 08:54:18 +10:00
Namit Bhutani
e5db240434 Mesh: Spatial Reordering for Sculpt Speed Improvements
**Problem Description**

Blender's current mesh data layout often lacks spatial coherence,
causing performance bottlenecks during BVH construction for sculpting
and painting operations. Each time a BVH is built, the system must
recompute spatial partitioning and vertex groupings from scratch,
leading to redundant calculations and suboptimal memory access patterns.

**Proposed Solution**

This patch implements pre-computed spatial organization of mesh data
through a new `mesh_apply_spatial_organization()` function that:

- Reorders vertices and faces based on spatial locality using recursive
  spatial partitioning.
- Stores pre-computed MeshGroup hierarchies in MeshRuntime for reuse.
- Enables the BVH system to bypass expensive spatial computation when
  pre-organized data is available.

This approach separates the expensive spatial computation from more
frequent BVH rebuilds, providing sustained performance improvements
across multiple sculpting operations.

**Limitations**

- Requires manual invocation (occurs automatically only during remesh
  operations).
- Additional memory overhead for storing MeshGroup metadata.
- One-time computational cost during initial organization.
- Spatial group references are not yet stored in files.

**User Interface**

The feature is accessible via a new "Reorder Mesh Spatially" operator in
the Mesh Data Properties panel under the Geometry Data section. Users
can invoke it manually when needed, or it will be applied automatically
during quadriflow and voxel remesh operations. The operator provides
feedback confirming successful spatial reordering.

Pull Request: https://projects.blender.org/blender/blender/pulls/139536
2025-07-04 20:02:37 +02:00
Hans Goudey
123267933c Fix #141430: Crash with viewer node on invalid domain
Since 68759af516, it was possible
to add attributes on invalid domains. Just add a check for that.

Pull Request: https://projects.blender.org/blender/blender/pulls/141460
2025-07-04 18:57:33 +02:00
Falk David
93d83bdad4 Merge branch 'blender-v4.5-release' 2025-07-04 14:57:53 +02:00
Falk David
859d271528 Fix: Grease Pencil: Crash when geometry has no drawings
Adds checks to the `get_drawing` functions to make sure that there is at
least one drawing in the geometry.
2025-07-04 14:57:08 +02:00
Lukas Tönne
455a8554e2 Refactor: Utility "mixer" class to simplify armature deform functions
The main armature deform functions compute a vector and/or matrix from
a weighted sum of bone deformations. This can be done either with
linear interpolation or using dual quaternions.

The linear and dual-quaternion methods were mixed together in the same
functions, which makes the code unnecessarily hard to follow. This patch
introduces a "Mixer" concept (similar to attribute math) that abstracts
the process of adding bone influence to the target vector/matrix. It also
takes care of finalizing the value. This way the code iterating over the
vertex group and/or bone envelopes can be agnostic of the target data.

The ArmatureUserData also receives significant refactoring to remove
unnecessary variables, utilize modern math classes, and generally improve
variable naming.

Pull Request: https://projects.blender.org/blender/blender/pulls/141348
2025-07-04 10:13:48 +02:00
Guillermo Venegas
eb3c6c0505 Fix: Collection name is clamped to 64 characters on creation
Noticed while adding the `Move to Collection` menu #140883.
This follows #137608

Pull Request: https://projects.blender.org/blender/blender/pulls/141350
2025-07-04 05:33:07 +02:00
Sean Kim
34ce46322c Refactor: Change SubdivCCG adjacency structs to use containers
This commit changes the `SubdivCCGAdjacentEdge` and
`SubdivCCGAdjacentVertex` structs to be simple wrappers around standard
container types, avoiding the need for manual memory management.

Pull Request: https://projects.blender.org/blender/blender/pulls/141163
2025-07-03 23:03:57 +02:00
Jesse Yurkovich
d303ab59d8 Merge branch 'blender-v4.5-release' 2025-07-03 11:44:23 -07:00
Jesse Yurkovich
c8a4026984 Mesh: Tune the parallelism of normals_calc_corners
Tune the grain size used for the parallel_for to alleviate excessive
mutex contention inside `handle_fan_result_and_custom_normals`.

I happened to notice that the 4004 Moore Lane USD scene[1] experienced a
load time regression compared to the prior release. It looks due to the
grain size used and here are some 3-run averages for the import:
```
Grain      | Time in seconds
256 (main) | (14.6+14.6+14.8)/3 = 14.6667
1024       | (13+12.8+12.9)/3 = 12.9
4096       | (13.3+13.1+13.1)/3 = 13.1667
16384      | (12.2+12+ 12.5)/3 = 12.2333
65536      | (9.4+9.2+9.6)/3 = 9.4
131072     | (7.9+7.7+8)/3 = 7.8667
262144     | (7.3+7.1+7.2)/3 = 7.2
max(16384, #verts/2) (PR) | (7.1+6.9+6.8)/3 = 6.9333
```

This PR gets the scenario loading in just under 7 seconds now compared
to over 14 originally.
[1] https://dpel.aswf.io/4004-moore-lane/

Pull Request: https://projects.blender.org/blender/blender/pulls/141249
2025-07-03 20:43:43 +02:00
Hans Goudey
a9e6417e19 Cleanup: Remove unnecessary mutex for draw attribute requests
As noted in [0], locking or atomics are not required for merging
requests for a single mesh, because there is no multithreaded iteration
over objects that will process the same mesh in multiple threads. This
locking was  added preemptively over the years and has made code
needlessly complicated, even while the final design for parallel object
iteration isn't completely clear. This PR removes the locks to simplify
some changes necessary for mesh attribute storage refactors.

[0]: b6764e77ef

Pull Request: https://projects.blender.org/blender/blender/pulls/141405
2025-07-03 19:14:26 +02:00
Harley Acheson
619968eb87 merge blender-v4.5-release 2025-07-03 09:31:55 -07:00
Christoph Lendenfeld
d7dd45e4da Fix #138399: Key handle jumping when scaling to 0
When moving a handle so its length is 0, the other handle was automatically set to 0 as well.
Cancelling the action didn't move the other handle back to 0, but set its length to 1.

The reason for that was that the code tries to maintain the relation between the two handles,
but that would lead to a divide by 0 when either of the handles has a length of 0.
So it would set the handle length to 1 in that case.

The fix is to ensure that the length of a handle is never 0. This is done by clamping it at the key
position with a threshold of 0.001 and an extra floating point step to support large floating
point values.
This should not affect animation in any way.

This was discussed in the animation & rigging module meeting
https://devtalk.blender.org/t/2025-06-26-animation-rigging-module-meeting/41272#p-153605-patches-review-decision-time-5

Co-authored by Nathan Vegdahl

Pull Request: https://projects.blender.org/blender/blender/pulls/141029
2025-07-03 12:47:15 +02:00
Damien Picard
7f0d15b31f Python: Add new APIs to collection.exporters
Add three new RNA functions to `bpy.types.CollectionExports`:
- `collection.exporters.new('IO_FH_alembic', name="Alembic")`
- `collection.exporters.remove(exporter)`
- `collection.exporters.move(0, 1)`

which allow to respectively create, remove, and reorder collection
exporters. Previously, they were only achievable using operators and
not the Python data API.

Example usage:

```python
C.collection.exporters.new("test")
# Traceback (most recent call last):
#   File "<blender_console>", line 1, in <module>
# TypeError: CollectionExports.new(): error with argument 1, "type" -
#   enum "test" not found in ('IO_FH_alembic', 'IO_FH_usd',
#   'IO_FH_obj', 'IO_FH_ply', 'IO_FH_stl', 'IO_FH_fbx')

usd_exporter = C.collection.exporters.new('IO_FH_usd')
usd_exporter.filepath = "//exp.usd"

stl_exporter = C.collection.exporters.new('IO_FH_stl')

C.collection.exporters.move(0, 1)
C.collection.exporters.remove(stl_exporter)
```

The exporter UIList was updated to add arrows calling the move
operator.

Co-authored-by: Pratik Borhade <pratikborhade302@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/141076
2025-07-03 11:58:07 +02:00
Campbell Barton
62c063820c Merge branch 'blender-v4.5-release' 2025-07-03 18:39:21 +10:00
Campbell Barton
def2db3bdb Build: resolve error building without TBB 2025-07-03 18:36:29 +10:00