Commit Graph

28596 Commits

Author SHA1 Message Date
Sean Kim
582c7d94b8 Paint: Scale brush size in preparation for planned 5.0 changes
This commit, in conjunction with !139561, is used to ensure consistent
values for the brush size while we transition it from representing
radius to diameter.

Related to #134204

Pull Request: https://projects.blender.org/blender/blender/pulls/139813
2025-06-05 00:46:10 +02:00
Sean Kim
2bbc9e73fc Merge branch 'blender-v4.5-release' 2025-06-04 15:45:32 -07:00
Sean Kim
6a03e8249d Paint: Add forward compatibility code for brush size
In 5.0, we plan to change the brush size from representing radius to
diameter. This means that for 5.0 files loaded in 4.5, we need to
scale the stored value when reading the relevant brush fields.

Related to #134204

Pull Request: https://projects.blender.org/blender/blender/pulls/139561
2025-06-05 00:44:43 +02:00
Hans Goudey
178f1d6fc5 Merge branch 'blender-v4.5-release' 2025-06-04 14:44:22 -04:00
Laurynas Duburas
46bc894570 Fix: Curves: Custom knots in Curves and GP operators
Current strategy to deal with operators not supporting custom NURBS
knots is to fall back to calculated knots for curves of the custom mode
but with no `CurvesGeometry::custom_knots` allocated. Such curves are
the result of operators that copy only `Point` and `Curve` domains. This
way the problem is only postponed. It is not possible to add new custom
knot curves to such `CurvesGeometry` as custom knot offsets are
calculated all together and there is no way to distinguish between old
curves with lost knots and new ones. This is more a future problem.

The actual problem in `main` can be shown with an attached blend file
(see PR) by applying `Subdivide` to some points and then adding new
`Bezier` curve to the same object. This particular problem could be
addressed somewhere in `realize_instances.cc` but the actual problem
would persist.

This PR handles custom knots in all places where `BKE_defgroup_copy_list`
is iused, and where `bke::curves::copy_only_curve_domain` is called.
Here the assumption is made that only these places can copy custom knots
modes without copying custom knots. Depending on operator logic knots are
handled most often in one of two ways:
 - `bke::curves::nurbs::copy_custom_knots`:
   copies custom knots for all curves excluding `selection`. Knot modes
   for excluded curves are altered from the custom mode to calculated.
   This way only curves modified by the operator will loose custom knots.
 - `bke::curves::nurbs::update_custom_knot_modes;`
   alters all curves to calculated mode.

In some places (e.g. `reorder.cc`) it is possible to deal with knots
without side effects.

PR also adds `BLI_assert` in `load_curve_knots` function to check if
`CurvesGeometry::custom_knots` exists for custom mode curves. Thus
versioning code is needed addressing the issue in files in case such
already exists.
Pull Request: https://projects.blender.org/blender/blender/pulls/139554
2025-06-04 20:43:15 +02:00
Hans Goudey
d7ae9cbfeb Cleanup: Sculpt: Remove unused argument
Missing from baa2ae6a59
2025-06-04 13:47:18 -04:00
Sean Kim
baa2ae6a59 Sculpt: Remove dyntopo BMesh reordering
In certain cases, when a Mesh is generated from a BMesh as part of
Dyntopo sculpting, (e.g. when the data is invalidated when leaving
Dyntopo or Sculpt mode) the face and vert indices are compressed to
remove any gaps that may exist due to deletion of elements. This step is
redundant to perform prior to converting to a Mesh, as the process of
doing so already compresses the indices

To avoid doing extra work, this commit simply removes this conversion
and any associated helper methods.

Pull Request: https://projects.blender.org/blender/blender/pulls/139313
2025-06-04 18:19:08 +02:00
Hans Goudey
4ccf435058 Brush: Remove legacy icon replaced by asset preview image
This icon was useful before the brush assets change. Nowadays
the workflow is different, and users have had time to use the
asset preview instead.

Resolves #121365.

Pull Request: https://projects.blender.org/blender/blender/pulls/139844
2025-06-04 18:16:30 +02:00
Hans Goudey
84bee96757 Mesh: 5.0 changes for mask, custom normals, UV seam
Complete the versioning and writing changes from these commits:
- f9b627d29c
- f2bcd73bd2
- c5ba8bd7c2

4.5 has the forward compatibility handling to support reading files
written by 5.0. This removes the conversion when writing files
and removes the lookup of ".uv_seam" as a fallback for "uv_seam".

Pull Request: https://projects.blender.org/blender/blender/pulls/139841
2025-06-04 17:46:48 +02:00
Hans Goudey
1ee43f7b2b Cleanup: Remove meaningless const for return by value 2025-06-04 11:00:47 -04:00
Hans Goudey
d9c7118983 Refactor: Move collection runtime struct out of DNA
Like other runtime structs, allocate it separately from the base
DNA struct. The main benefit is allowing the use of C++ features
for runtime data.

Pull Request: https://projects.blender.org/blender/blender/pulls/138605
2025-06-04 15:47:43 +02:00
Thomas Dinges
f224dbccce Revert "Release: Update 4.5 branch to beta"
This reverts commit ea5b1f7527.
2025-06-04 14:14:58 +02:00
Thomas Dinges
2aba7ec802 Merge branch 'blender-v4.5-release' 2025-06-04 14:13:55 +02:00
Thomas Dinges
ea5b1f7527 Release: Update 4.5 branch to beta
Splash by Blender Studio
2025-06-04 14:10:17 +02:00
Thomas Dinges
ccbcde4adb Release: Bump main to 5.0
Splash by Blender Studio
2025-06-04 13:55:07 +02:00
Omar Emara
6bf52d11f1 Fix #139327: Movie distortion result is cropped
The Movie distortion node crops its data if the movie size differs from
the input size. That's because boundary extensions do not take
calibration size into account. To fix this, we use the same coordinates
range as the distortion grid computation, which computes the distortion
in the space of the calibration size.

Pull Request: https://projects.blender.org/blender/blender/pulls/139822
2025-06-04 12:24:33 +02:00
Philipp Oeser
457cccd964 Fix #139782: USD MeshSequenceCache modifier using the wrong frame
It would run into using the same frame twice, looking like "freeze
frames"

Apparently we had a similar issue before, see 3f8ec963e3

Just a PoC to show that this looks like a precision/rounding issue when
getting a "working" `UsdTimeCode`.
In the modifier code, we are doing a roundtrip going from frame >> time
(in seconds -- via `BKE_cachefile_time_offset`) and then back to frame
before we store that in `USDMeshReadParams`.

To avoid the precision loss, this PR introduces
`BKE_cachefile_frame_offset` to stay in the "frame" domain and
circumvent going through FPS alltogether.

There might be better ways to let USD handle the "sightly off"
`UsdTimeCode` better though.

Pull Request: https://projects.blender.org/blender/blender/pulls/139793
2025-06-04 11:04:37 +02:00
Campbell Barton
6a1fa176ef Cleanup: spelling in comments & duplicate terms (check_spelling.py)
Also minor clarification in doc-string.
2025-06-04 01:51:29 +00:00
Sean Kim
463e543bc1 Cleanup: Rename and move BKE_sculpt_check_cavity_curves
* Move to paint.cc instead of scene.cc to be more specific
* Reword to `BKE_sculpt_cavity_curves_ensure` to better align with
  existing naming

Pull Request: https://projects.blender.org/blender/blender/pulls/139795
2025-06-03 20:38:37 +02:00
Hans Goudey
c0ec3ff044 Fix: Crash with frame nodes after recent fix 2025-06-03 11:28:30 -04:00
Sean Kim
b1eef8bdac Cleanup: Remove unnecessary struct prefix in BKE_brush.hh
Pull Request: https://projects.blender.org/blender/blender/pulls/139771
2025-06-03 17:27:41 +02:00
Clément Foucault
1d638c0f5e EEVEE: Add deferred texture loading
This adds a new function to query GPUtexture from an
Image datablock without actually creating them.

This allows to keep track of all the texture that
needs to be loaded and defer their loading in
end_sync. The texture are then only used in the
next sync. This is because we do not want to stage
the texture for drawing as it would require a
valid texture.

Multithreading is used to load the texture from disk
as soon as possible in a threaded way. It is still
blocking, but it is much faster (depending on
hardware).

Before (5.7s):
After (2.5s):

On Linux workstation: 2.28x speedup in texture loading
On M1 Backbook pro: 2.72x speedup in texture loading

This includes redraw overhead but it is not super significant.

Having a vector of all the textures to be loaded
will eventually be helpful in making the
texture uploading multi-threaded. Currently, it is
a bit difficult given the need of a valid GPUContext
per thread.

- [x] Bypass deffered loading on animated textures
- [x] Add throttling to only load a few textures per frame
- [x] Do not delay for viewport render

Pull Request: https://projects.blender.org/blender/blender/pulls/139644
2025-06-03 16:57:27 +02:00
Hans Goudey
c62b5929a7 Fix #139750: Crash in structure type inferencing with missing data-block
Socket declarations can be null in this case.
2025-06-03 10:08:22 -04:00
Campbell Barton
87fb14fc42 Cleanup: spelling in comments (make check_spelling_*)
Also use doxgen doc-strings.
2025-06-03 10:01:38 +10:00
Hans Goudey
77b14f2dcb Cleanup: Grammar: Fallback vs. fall back
The former is a noun or adjective, the latter is a verb.
2025-06-02 17:13:56 -04:00
Hans Goudey
166bfb3811 Fix #138175: EEVEE crash with multiple materials in sculpt mode multires
`BKE_id_material_used_with_fallback_eval` doesn't account for the case
the evaluated mesh is empty and `SubdivCCG` is used for drawing instead,
which only happens for workbench/EEVEE in sculpt mode. Instead of
further complicating the logic, change the multires modifier to produce
a copy of the input mesh with the SubdivCCG attached, rather than that
mesh being empty. This makes things like detecting the max material
index work "for free."

Pull Request: https://projects.blender.org/blender/blender/pulls/139742
2025-06-02 22:32:34 +02:00
Jacques Lucke
383b3fd678 Fix #139391: take dynamically added vertex groups into account in armature modifier
Previously, the armature modifier retrieved the list of available vertex group
names from the original mesh. However, that list may contain different vertex
groups then are actually on the mesh that is being deformed. This patch makes it
so that the vertex group list (`defbase`) is taken directly from the
mesh-to-deform if possible.

Pull Request: https://projects.blender.org/blender/blender/pulls/139734
2025-06-02 19:30:21 +02:00
Jacques Lucke
3afc1cbbe1 Refactor: Nodes: change int to enum for bNodeSocketType.type
This eliminates the need for explicit type casts in many places.

Pull Request: https://projects.blender.org/blender/blender/pulls/139710
2025-06-02 13:50:07 +02:00
Omar Emara
425be6bb02 Compositor: Turn Flip node options to inputs
This patch turns the Flip node options to inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/139722
2025-06-02 12:48:00 +02:00
Nathan Vegdahl
5ff12bdc98 Core: Show all path template errors in the UI
The path templates feature implemented in #134860 highlights path
properties that have syntax errors in red and provides a list of those
errors in the path's tool tip. However, syntax errors are not the only
kind of error.

For example, if given the render output path `//render/{blend_nam}`,
with a typo in the variable `blend_name`, this error is not indicated
until actually trying to render. This is because the path is
*syntactically* correct, and the error is due to `blend_nam` not being
an available variable.

This PR resolves this: paths with path template support now indicate all
errors in the UI, not just syntax errors, with red highlights and a list
of errors in the tool tip.

The primary mechanisms for this are:
- A new function `BKE_build_template_variables_for_prop()`, which takes
an RNA pointer and produces an appropriate template variable map for the
given property, which can then be used to fully validate a path
property's value in the UI code.
- A new enum `PropertyPathTemplateType` has been added to `PropertyRNA`,
which determines what variables should be made available to a property
and how they should be build. This is used by
`BKE_build_template_variables_for_prop()`.

Additionally, the following changes have been made to help ensure that
`BKE_path_apply_template()` and `BKE_path_validate_template()` produce
identical errors:
- Both functions now call into a third static function `eval_template()`
  that does the actual work, optionally modifying the input path or not.
- Previously only `BKE_path_apply_template()` had unit tests, but now
  the unit tests have been reorganized to simultaneously test both
  `BKE_path_apply_template()` and `BKE_path_validate_template()`.

Pull Request: https://projects.blender.org/blender/blender/pulls/138679
2025-06-02 11:40:05 +02:00
Jacques Lucke
2daa3cc65d Cleanup: typo 2025-06-02 06:56:31 +02:00
Campbell Barton
d23e3b3863 Fix invalid blend-file writing logic in "Add color jitter support"
Error in [0] caused out of bounds buffer reads when writing CurveMapping
data.

[0]: 96e549c092
2025-06-01 14:46:16 +10:00
Charles S
96e549c092 Paint: Add color jitter support
Add ability to randomize color of each stroke for or use perlin noise
randomization during the stroke. Works similarly to grease pencil stroke
color randomization. This feature is available for all mesh color
painting modes (Sculpt Paint brush, Texture Paint and Vertex Paint)

This setting is available both as a per-brush setting and a unified
setting on the scene level. Additionally, the equivalent Grease Pencil
options have been migrated to these more generic flags and values.

Based on this [1] RCS request.

[1]: https://blender.community/c/rightclickselect/mwgbbc/

Pull Request: https://projects.blender.org/blender/blender/pulls/128953
2025-05-31 23:48:59 +02:00
Hans Goudey
8e2c6bc617 Fix: Various fixes to unused CustomData to AttributeStorage conversion
So far this is unused, but it's used in #139165, and that pointed out
some obvious flaws in the code, like the resulting AttributeStorage
being completely ignored, and old CustomData layers not being freed.
Restructure the API a bit to make it simpler to use, and also make it
keep the non-generic layers in CustomData. That's not necessary for
point clouds but it will be necessary for curves (the next step) since
they have vertex groups.

Pull Request: https://projects.blender.org/blender/blender/pulls/139609
2025-05-30 14:46:39 +02:00
Sean Kim
308e47ef17 Fix #139617: Crash when activating brush
It is possible on file load that the `previous_active_brush_reference`
is an invalid old memory location. To prevent this, set the ptr to
nullptr on file load, as it should only be used within a given session.

Pull Request: https://projects.blender.org/blender/blender/pulls/139618
2025-05-30 07:39:23 +02:00
Pratik Borhade
2b0cc73ef6 Modifiers: Change softbody fuzzy default value
Set fuzzy=1 when softbody modifier is added. As of now, value is 0, this
raises concern of division by zero so bump it to 1.
Updated `softbody_test.blend` to fix the failing test.
Resolves #137849

Pull Request: https://projects.blender.org/blender/blender/pulls/137878
2025-05-30 06:32:08 +02:00
Campbell Barton
50f3240abd Cleanup: spelling & duplicate terms (check_spelling.py) 2025-05-30 11:03:56 +10:00
Sean Kim
af31eeb900 Sculpt: Lower Multires leaf node limit to 800
In a prior commit, the Mesh Paint BVH leaf node limit was reduced from
10000 faces to 2500 faces. This commit makes a proportional change
for the Multires paint BVH.

In performance testing of just the brush evaluation, this change
represents a 3x speedup (from 0.6326s to 0.2135s) on a Multires grid
with 25m vertices at multires level 5.

In a simulated brush stroke testing similar to what a user would do,
on a grid of 6m vertices at multires level 5 this change equals a 1.4x
improvement from 41.8 to 58.6 FPS.

See the related PR for the raw data and testing methodology.

Related to #137871

Pull Request: https://projects.blender.org/blender/blender/pulls/139311
2025-05-29 21:45:17 +02:00
Hans Goudey
91803e130f Cleanup: Grammar: Fix uses of "for e.g."
e.g. stands for "exempli gratia" in Latin which means "for example".
The best way to make sure it makes sense when writing is to just expand
it to "for example". In these cases where the text was "for e.g.", that
leaves us with "for for example" which makes no sense. This commit fixes
all 110 cases, mostly just just replacing the words with "for example",
but also restructuring the text a bit more in a few cases, mostly by
moving "e.g." to the beginning of a list in parentheses.

Pull Request: https://projects.blender.org/blender/blender/pulls/139596
2025-05-29 21:21:18 +02:00
Sean Kim
5402ce3929 Cleanup: Remove unnecessary qualifiers in BKE_paint.hh
Pull Request: https://projects.blender.org/blender/blender/pulls/139571
2025-05-29 20:02:32 +02:00
Sean Kim
000c635542 Cleanup: Remove unnecessary const in BKE_brush.hh
Pull Request: https://projects.blender.org/blender/blender/pulls/139570
2025-05-29 20:01:50 +02:00
Jacques Lucke
182797ea61 Geometry Nodes: new Format String node
This adds a new Format String node which simplifies constructing strings from
multiple values. The node takes a format string and a dynamic number of
additional parameters as input. The format string determines how the other
inputs are inserted into the string. Only integer, float and string inputs are
supported for now.

It supports two different format syntaxes:
* Python compatible format syntax which also mostly matches the behavior of the
  `fmt` C++ library. Most of this is supported, but there are some small
  limitations.
* Syntax of the form `###.##` where each `#` stands for a digit. This is the
  syntax that was introduced in #134860.

This node greatly simplifies common string operations which would have required
potentially many nodes before to convert numbers to strings and to concatenate
them. It also makes new conversions possible that were not supported before.
This node can also be used to insert e.g. frame numbers into a file path which
was surprisingly complex before.

This node has special behavior for the name of new inputs. For the purpose of
the node, the name of the inputs must be valid identifiers and it's usually
helpful when they are short. New names are therefore initialized to be single
characters. If possible, the first character of the linked input is used. This
works well when connecting e.g. a Separate Vector/Color node. Otherwise, inputs
are named `a` to `z` by default. If that's not possible, the source socket name
is used instead (converted to be a valid identifier). If that still doesn't
work, the name is made unique using the normal `.001` mechanism except that `_`
instead of `.` is used as separator to make the name a valid identifier.

Python Syntax references:
* Python: https://docs.python.org/3/library/string.html#formatspec
* `fmt`: https://fmt.dev/latest/syntax/

More detailed notes about compatibility with the above syntax specifications:
* Conversion using e.g. `!r` like in Python is not supported (maybe the future).
* Sub-attribute access like `{vector.x}` is not supported (maybe the future).
* Using `%` like in Python is not supported (maybe in future).
* Using `#` for an alternate form is not supported. This might help in the
  future to make the syntax compatible with #134860.
* Using `L` like in the `fmt` library is not supported because it depends on the
  locale which is not good for determinism.
* Grouping with e.g. thousands separators using e.g. `,` or `_` like in Python
  is not supported (maybe in future). Need to think about the locale here too.
* Mixing of unnamed (`{}`) and named (`{x} or {0}`) specifiers is allowed.
  However, all unnamed specifiers must come before any named specifier.

The implementation uses the `fmt` library for the actual formatting. However,
the inputs are preprocessed to give us more control over the exact supported
syntax and error messages. The code is already somewhat written so that many
strings could be formatted with the same format but that's not actually used yet
because we don't have string fields yet.

Error messages are propagated using a new mechanism that allows a limited form
of error propagation from multi-functions to the node that evaluates them.
Currently, this only works in fairly limited circumstances, e.g. it does not
work during field evaluation. Since this node is never part of field evaluation
yet, that limitation seems ok, but it's something to work on at some point.
Properly supporting that requires some more changes to propagate enough context
information everywhere. Also showing errors of field evaluation on the field
node itself (instead of on the evaluation node) requires even more work because
our current logging system is not setup to support that yet.

This node comes with a few new requirements for the socket items system: names
must be valid identifiers and they are initialized in a non-trivial way.
Overall, this was fairly straight forward to implement but currently it requires
to adding a bunch of new members to all the accessors that don't really need it.
This is something that we should simplify at some point even if I'm not entirely
sure how yet. The same new requirements used in this node would probably also
exist in a potential future expression node.

Pull Request: https://projects.blender.org/blender/blender/pulls/138860
2025-05-29 13:17:03 +02:00
Hans Goudey
a7e3a81c84 Cleanup: Use functional style case for eCustomDataType 2025-05-28 22:05:03 -04:00
Campbell Barton
ebca01274f Cleanup: unused parameter warning 2025-05-29 11:01:29 +10:00
Campbell Barton
479d1f1d16 Cleanup: use doxygen doc-strings, spelling (make check_spelling_*) 2025-05-29 11:00:53 +10:00
Hans Goudey
c725bf324d Cleanup: Use functional style cast for node socket type enum 2025-05-28 15:47:26 -04:00
Sean Kim
5de2d48921 Cleanup: Use C++ style casts for Brush type
In most cases this is a simple switch for `reinterpret_cast` or
`static_cast`, but for `BKE_paint_brush` and `BKE_paint_eraser_brush`
code is duplicated to avoid a `const_cast`.

Pull Request: https://projects.blender.org/blender/blender/pulls/139119
2025-05-28 21:37:12 +02:00
Sebastian Parborg
5106c4e655 JACK: Fix a mutex deadlock when trying to start/stop playback 2025-05-28 19:32:34 +02:00
RedMser
24a2da62b3 Movie Clip Editor: Show preview range
Overall the goal of the PR is to show the preview range in the
clip editor's dopesheet and graph mode.

To accomplish this, some cleanup and refactor were needed:

- Clip editor had a nearly 1:1 copy paste of the timeline draw code,
  which has been replaced with `ANIM_draw_framerange`.
- Preview range draw code required `bContext`, which was only used to
  access scene. Now scene is passed explicitly, without need to know the
  context.
- The macro to access the preview range was removed. This is because the
  code is within `PRVRANGEON` check, so `PSFRA`/`PEFRA` were doing
  redundant checks.

Pull Request: https://projects.blender.org/blender/blender/pulls/138678
2025-05-28 16:28:38 +02:00
Mattias Fredriksson
92d83e136a Curves: Unit tests for curves::nurbs::calculate_knots
Unit tests veryfying expectation for curves::nurbs::calculate_knots.
While useful to avoid regressions, they might be more valuable as
reference of the output from the knot vector generator for different
options.

Pull Request: https://projects.blender.org/blender/blender/pulls/139508
2025-05-28 04:27:34 +02:00