Commit Graph

29130 Commits

Author SHA1 Message Date
Sybren A. Stüvel
00abaa571a Rendering: check return value of mkdir before using directory
When rendering to an image/video file, check whether the recursive
directory creation actually succeeded. If not, log an error and stop,
instead of trying to write the file.

This results in easier to understand error messages, and will help to
triage some (what we think are) race conditions with the Blender Studio
render farm.

Pull Request: https://projects.blender.org/blender/blender/pulls/145118
2025-08-25 16:30:40 +02:00
Jacques Lucke
7e7b05a054 Fix #145113: Nodes: menu error not automatically resolving 2025-08-25 16:06:46 +02:00
Falk David
1122a05cb6 VSE: Scene Selector & Scene Time Synchronization
Implements the proposed design (with some modifications) in #135058.

## Sequencer Scene

This adds a new property called `sequencer_scene` to workspaces. This scene is used
by the video sequence editors in the current workspace for their context.
This is a first step towards "detaching" the VSE from the active scene in the window.

Each sequencer timeline editor shows the sequencer scene that is being used.
By default, when no sequencer scene is selected, the timeline and preview are empty.

Pressing the "new" button will add a new scene and assign it to the sequencer
scene for the current workspace.

## Contextual Playback

Pressing `Space` (by default) for starting the animation playback is now contextual:
depending on the context (where your mouse cursor is), the scene that is played back
might be different. E.g. with a 3D Viewport and a Sequencer open, pressing "play"
in the 3D Viewport will play the _active scene_ of the window, while pressing "play"
in the sequencer will play the _sequencer scene_.

## Time & Scene Synchronization

Additionally, this adds a toggle called "Sync Active Scene".
With the property turned on, the active scene & scene time in the window will be
synced with the time & scene of the current scene strip in the sequencer.

Note that this is _not_ bi-directional. The sequencer can change the active scene
and map time, but it's not possible the other way around since it one can have
multiple strips using the same scene (+camera, and even time!).

Currently this setting is exposed in the footer of the sequencer timeline as well
as in the workspace settings.

This allows for one of the core concepts that the story tools projects aims at: Working
in a scene (e.g. in the 3D viewport) while also working with the edit
(in the sequencer timeline).

## Some technical notes

* Undoing while playback is running will now cancel playback. This is to avoid the timer,
   that points to the scene and viewlayer that are playing, to get de-synced after loading
   the memfile undo step.
* When the sequencer scene is not the same as the active scene, we ensure it has
   a depsgraph.
* Normally, when a `NC_SCENE` notifier points to a specific scene, the notifier is dropped
   if that scene doesn't match the active one in the window. We now also check that it
   doesn't match the sequencer scene in the active workspace.
* When loading older files, we need to make sure that the active workspace in a window
   uses the active scene as the sequencer scene. This is to make sure that the file opens with
   the same sequences open.
* Tool settings are stored per scene. To make sure the sequencer uses the tool settings for
   the sequencer scene, the "context.tool_settings" and `CTX_data_tool_settings` members
   are overridden in the sequence editors.

Pull Request: https://projects.blender.org/blender/blender/pulls/140271
2025-08-25 11:58:17 +02:00
Campbell Barton
904794e330 Fix #144970: Crash selecting the text on a linked duplicated text object
Restrict EditFont manipulation to the object which is in edit-mode
previously multiple threads could clear & assign EditFont::selboxes
at once which crashed when in edit-mode with linked duplicates.
2025-08-25 06:40:55 +00:00
Campbell Barton
98fd1a942c Refactor: move run-time flags from CharInfo::flag to CharTrans
The Curve, Curve::strinfo & EditFont::textbufinfo are now read-only
during evaluation. CharTrans is now used to store some evaluation
options such as wrap/overflow/smallcaps.

Since it's no longer possible to inspect evaluation flags from operators
without evaluating the curve, line beginning/end functionality has been
moved from the operator into vfont_to_curve.
2025-08-25 06:40:53 +00:00
Campbell Barton
e17677ce73 Refactor: move font-curve initialization & validation out of evaluation
Ensure arrays are valid when reading instead of evaluation.
In general correcting data in evaluation is error prone since
data may be accessed from other parts of Blender before evaluation
(Python scripts for example), and isn't thread-safe in edit-mode
where the edit-data is shared, see #144970.

This also removes material index correction, this doesn't cause
problems as the evaluated `Nurb` must already support out of range
material indices.
2025-08-25 06:20:11 +00:00
Campbell Barton
dae9bed968 Refactor: move the evaluated font size into EditFont
Avoids manipulating the Curve when evaluating fonts.
2025-08-25 06:20:10 +00:00
Campbell Barton
88129ffa6b Cleanup: pass a curve to BKE_vfont_select_* instead of an object
Let callers use a curve without depending on the object.
2025-08-25 06:20:08 +00:00
Campbell Barton
352575d620 Cleanup: remove unused Curve::lines & disabled RNA definition 2025-08-25 06:20:07 +00:00
Campbell Barton
1b559b4f78 Cleanup: quiet class-memaccess warning 2025-08-24 19:50:40 +10:00
Campbell Barton
a080a2f4d0 Cleanup: use doxygen comments for BKE_subdiv* 2025-08-24 16:19:48 +10:00
Harley Acheson
0b6255a292 Cleanup: UNUSED_VARS referencing unknown variable
Function argument was removed but now we have an UNUSED_VARS that
references it when running without WITH_OPENSUBDIV.
2025-08-22 11:19:28 -07:00
Sergey Sharybin
628f53a28c Refactor: Consolidate baking settings into BakeData
Almost all settings were duplicated between BakeData and RenderData.
The only missing field was the bake type, which is stored as a custom
property in Cycles.

This change:
- Removes unused bake_samples and bake_biasdist.
- Migrates settings like bake_margin to BakeData.
- Switches multires baker to use bake_margin.
- Introduces bake type in the BakeData, the same way how it was
  defined in RenderData::bake_mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/144984
2025-08-22 19:18:03 +02:00
Sergey Sharybin
e0154de320 Rework Bake from Multires
The main idea is to switch Bake from Multires from legacy DerivedMesh
to Subdiv. On the development side of things this change removes a lot
of code, also making it easier easier to rework CustomData and related
topics, without being pulled down by the DerivedMesh.

On the user level switch to Subdiv means:

- Much more closer handling of the multi-resolution data: the derived
  mesh code was close, but not exactly the same when it comes to the
  final look of mesh.

  Other than less obvious cases (like old DerivedMesh approach doing
  recursive subdivision instead of pushing subdivided vertices on the
  limit surface) there are more obvious ones like difference in edge
  creases, and non-supported vertex creases by the DerivedMesh.

- UV interpolation is done correctly now when baking to non-base level
  (baking to multi-resolution level >= 1).

  Previously in this case the old derived mesh interpolation was used
  to interpolate face-varying data, which gives different results from
  the OpenSubdiv interpolation.

- Ngon faces are properly supported now.

A possible remaining issue is the fact that getting normal from CCG
always uses smooth interpolation. Based on the code it always has been
the case, so while it is something to look into it might be considered
a separate topic to dig into.
2025-08-22 17:59:27 +02:00
Sergey Sharybin
c9a87558d4 Refactor: Mass Mesh as const to multires displacement
The only annoying part is that for the external MDISPS the mesh
needs to be cast to non-const.

Arguably it is semantically correct behavior as the details of
how external data is read is kind of implementation details.
2025-08-22 17:15:06 +02:00
Sergey Sharybin
0c3136de84 Refactor: Use float2 in the multires baker
Shortens some formulas, and reduces the number of arguments.
Also reduce the variables scope.

No functional changes expected.
2025-08-22 17:15:06 +02:00
Sergey Sharybin
1e4764a9a5 Refactor: Simplify subdiv utilities
- Return evaluated points as function return value.
  Used in cases when only limit or final point is requested, without
  partial derivatives.

- Re-order function argument list and use default argument values to
  simplify usage in the simple/typical cases.

No functional changes expected.
2025-08-22 17:15:06 +02:00
Brecht Van Lommel
7d7562e849 Color Management: Support for saving wide gamut images
* Bundled ICC profiles for display spaces supported by Blender, and
  embed them in the image file when saving.
* Verified to work for PNG, TIFF, JPEG and WebP, but not all file
  formats support this.
* No ICC profile is written for sRGB currently. It would be a matter
  of adding an icc file, however this may be a breaking change for
some use cases.
* Fix save as render of EXR files not properly changing the image
  colorspace to match.

Uses CC0 licensed ICC files from the Compact ICC Profiles project.

This does not include support for saving HDR images. While there exist
ICC profiles for PQ, they are not well supported and the preferred method
for HDR is to write CICP tags. However OpenImageIO support for this is
still under development.

Ref #144911

Pull Request: https://projects.blender.org/blender/blender/pulls/144565
2025-08-21 15:25:21 +02:00
Brecht Van Lommel
235fdc6356 Color Management: Fix wrong use of display color space
* PROP_COLOR_GAMMA is sRGB, not display space
* Hex colors are always sRGB
* Image byte buffers are in byte_buffer.colorspace

Fixes for sequencer text, image painting, render stamp and tooltips.
The default display space is sRGB, so this change will not be noticed
in most files.

Ref #144911

Pull Request: https://projects.blender.org/blender/blender/pulls/144565
2025-08-21 15:24:40 +02:00
W_Cloud
24308a9f21 Nodes: Inherit color tag when grouping a single node
The `Ctrl + G` make group operator now inherits the color_tag
from the selected node when only one node is selected.

Pull Request: https://projects.blender.org/blender/blender/pulls/144861
2025-08-21 14:50:19 +02:00
Campbell Barton
fc7141f582 Fix #142137: Dynamic paint crashes when evaluating poses
DEG_add_collision_relations was only adding relationships for objects in
the brush collection, however dynamic paint also updates parent objects
and armature poses which weren't accounted for. Failing to include these
relations meant the evaluating the depsgraph could evaluate a pose
object from multiple threads at once - causing a crash.

Resolve by sharing logic between DEG_add_collision_relations &
BKE_object_modifier_update_subframe so depsgraph relationships match
objects the dynamic-paint modifier updates as part of its evaluation.

Ref !144844
2025-08-21 22:13:18 +10:00
Campbell Barton
cc553739d8 Cleanup: various minor changes BKE_object_modifier_update_subframe
- Rename `parent_recursion` to `parent_recursion_limit`.
- Use a define for the recursion default.
- Use const arguments.
2025-08-21 22:13:18 +10:00
Campbell Barton
b1cd0ff91e Cleanup: add missing headers to source lists 2025-08-21 17:09:18 +10:00
Sean Kim
abe1b9d895 Cleanup: Rename BKE_paint_brush_poll to BKE_paint_can_use_brush
The prior naming is a bit confusing given that it returns `true` if
`brush` is `nullptr`. My initial expectation on reading the old name is
that it would only return true if both are non-null.

Pull Request: https://projects.blender.org/blender/blender/pulls/144822
2025-08-20 20:59:28 +02:00
Hans Goudey
8b9e667eab Revert "Sequencer: Avoid storing un-tracked pointers in blend files"
This reverts commit 58554964e4.
Caused unexpected test failures, may need more review.
2025-08-20 11:31:02 -04:00
Hans Goudey
58554964e4 Sequencer: Avoid storing un-tracked pointers in blend files
Currently, sequencer structs contain several pointers to data within
other structs. These pointers need to be remapped as the structs are
reallocated when reading from blend files. That has worked so far
because the pointers are exactly the values from the Blender session
that saved the file. WIth the implementation of #127706, the pointers
in the file aren't "real" anymore, and we can't offset them to get the
struct that contained the data.

This commit replaces these 4 mid-struct pointers to point to the
containing strips instead, and uses some trivial logic to access the
fallback root sequence channels and strips. This makes the pointer
remapping on file load possible again.

The downside is that this isn't strictly backward or forward compatible,
but only on a UI-level. The active meta-strip information will be lost,
and the sequencer will reset to displaying the root sequence.

Depends on #144624

Pull Request: https://projects.blender.org/blender/blender/pulls/144626
2025-08-20 16:49:41 +02:00
Hans Goudey
4d6646c91e Fix #143958: Dynamic paint crash due to thread-unsafe brush mesh writing
Alternative to #144563.
This fix adds a lock to the runtime data, and holds the lock whenever the
brush mesh is accessed. While there may be more efficient solutions,
dynamic paint is at the end of its life and guaranteeing correctness is
more important.

Pull Request: https://projects.blender.org/blender/blender/pulls/144816
2025-08-20 16:23:26 +02:00
Hans Goudey
89c5702d12 Fix: Reference binding to null pointer in normals-calc_corner
Mistake in ca60419b3a
2025-08-20 09:56:35 -04:00
Alberto12345678999
d803ee4c79 Nodes: Port shader Gamma node to Geometry Nodes
This patch unifies the Gamma node across editors:

- Compositor now uses the Shader Gamma node implementation.
- Geometry Nodes also uses the node as a new addition.
- UI-wise in the Compositor, only socket labels change to "Color".

Forward compatibility is broken for the compositor, and the python API
changed, since the node's ID name is now ShaderNodeGamma as opposed to
CompositorNodeGamma.

Pull Request: https://projects.blender.org/blender/blender/pulls/142414
2025-08-20 08:46:34 +02:00
Campbell Barton
9a1af169d9 Cleanup: use bool argument for object_cacheIgnoreClear 2025-08-20 16:10:54 +10:00
Campbell Barton
3a8a379ea2 Cleanup: use camel-case/pascal-case for struct names 2025-08-20 11:01:13 +10:00
Sean Kim
8723bd4f58 Cleanup: Change BKE_paint_brush_set to take in const reference
Changes the overload from accepting `const AssetWeakReference *` to
`const AssetWeakReference &` to more strongly indicate proper usage. We
should not have a usecase for setting a null `AssetWeakReference`

Pull Request: https://projects.blender.org/blender/blender/pulls/144821
2025-08-20 00:01:04 +02:00
Sean Kim
6e82e403df Fix: Image Editor can have no default active brush
Prior to this commit, determining the default brush asset used for a
particular mode was based on the object's mode. This is slightly
incorrect for the Image Editor, since it may be in Paint Mode no matter
the underlying object type. To fix this, use the runtime `PaintMode`
enum for determining these default values instead of `eObjectType` and
store the `PaintMode` on `PaintRuntime` for easy access.

Additionally, inside the toolsystem, prevent accidentally unsetting
the default brush by checking for the presence of the asset when
loading an `AssetWeakReference`.

Pull Request: https://projects.blender.org/blender/blender/pulls/144765
2025-08-19 22:44:24 +02:00
Hans Goudey
8b7a0b307b Cleanup: Make AttributeStorage method const 2025-08-19 10:23:13 -04:00
Bastien Montagne
a3c4b0b07a Fix #144749: Crash on opening a file with a Sculpt toolsettings gravity object.
Mistake in code is at least 2 years old, interesting that this was never
noticed/reported before...

Candidate for LTS's backport.
2025-08-19 12:12:47 +02:00
Campbell Barton
8e85423f63 Refactor: simplify zero stripping in units code
Passing negative precision to internal units functions made the code
difficult to follow, especially when the precision is being
adjusted/clamped.

While the public API remains unchanged, detect the negative precision
early and assign it to a boolean which is passed as an argument.

Also improve doc-strings.
2025-08-19 09:37:38 +00:00
илья _
3a6a663a15 Fix: Zero division exception in ca60419b3a
Pull Request: https://projects.blender.org/blender/blender/pulls/144770
2025-08-19 10:00:41 +02:00
Campbell Barton
087c442567 Build: unbreak lite builds (WITH_TBB=OFF) 2025-08-19 12:31:17 +10:00
илья _
ca60419b3a Mesh: Avoid mutex lock in hot loop for custom normals
Use a thread local buffer to gather info about the custom normal space
for each corners group in threading to concatenate them later. This
avoids need to lock a mutex to write into a buffer shared betwen threads
in the corner groups traversal hot loop.

The performance improvement depends on the mesh size and the number of
CPU threads. In some files there might be no change, in other files an
improvement of over 2x was observed, mostly because we can now remove
the compromise from c8a4026984.

Pull Request: https://projects.blender.org/blender/blender/pulls/144660
2025-08-19 03:46:03 +02:00
Hans Goudey
76c5bdf0be Refactor: Clear Panel and ARegion runtime pointers when writing files
Avoid writing unnecessary pointers to blend files.

Pull Request: https://projects.blender.org/blender/blender/pulls/144743
2025-08-18 20:56:40 +02:00
Hans Goudey
178eca9427 Refactor: Move various window manager runtime pointers out of DNA
All of these pointers were cleared on file read. It's clearer to just
move them to the runtime struct.

Pull Request: https://projects.blender.org/blender/blender/pulls/144729
2025-08-18 20:44:44 +02:00
Hans Goudey
56646137fe Refactor: Move some wmWindowManager runtime lists out of DNA
Mainly for the purpose of #127706, though there's plenty more runtime
data to move to the runtime struct out of DNA.

Pull Request: https://projects.blender.org/blender/blender/pulls/144691
2025-08-18 16:13:07 +02:00
Hans Goudey
a5d5eca487 Cleanup: Sequencer: Replace seqbasep variable access with function
With the aim of removing `seqbasep` to remove the complicated logic for
repairing pointers within the `Strip` struct when loading files and undo
steps, this commit just moves access of the variable behind a function.
In the future the function will retrieve the list from a Strip pointer,
for now it just returns the existing pointer.

Overall motivation is that blend file pointer manipulation is incompatible
with the changes required for #127706.

Pull Request: https://projects.blender.org/blender/blender/pulls/144624
2025-08-18 15:39:58 +02:00
Jacques Lucke
a065d16ef4 Fix: Geometry Nodes: crash accessing empty instances 2025-08-18 13:16:58 +02:00
илья _
dba072ef93 Mesh: Avoid quadratic vertex valence complexity for corner normals
We have a set of corners around some vertex. They have arbitrary
connectivity between each other and form a set of linked lists through
shared smooth edges. We have to linearly traverse each of these lists to
mix the normals. And as a way to iterate over all these lists mixed in
some index space we use a mask of already visited corners. So we take
the first non-checked corner by mask lookup. And this lookup starts from
the beginning every time even if we know there is no way to find any
elements before current one. In a synthetic example with 20k fan fill
of circle this gives a 8x speed up.

Pull Request: https://projects.blender.org/blender/blender/pulls/144649
2025-08-17 20:11:40 +02:00
Hans Goudey
072d251b8e Refactor: Use optional Span instead of empty Span with no attribute
The semantics of checking "has_value()" (etc.) are much better than
checking for an empty span when dealing with the result of an attribute
lookup. This mainly affects the Bezier curve handle position attributes
currently. Plenty of places assume those attributes exist now. In a
couple places the code is a bit safer now, otherwise it's just a bit
more obvious.

Pull Request: https://projects.blender.org/blender/blender/pulls/144506
2025-08-17 18:08:18 +02:00
илья _
d65c059973 Cleanup: Mesh: Use edge_other_vert instead of ternary operator
Its generally preferable to use `edge_other_vert` if you have a set of
2 ints and know some of them and want to select other. This is
preferable since it will make a check that assumption is met and at
least one of the ints is the same as the known one. This function itself
is also made to work with topological indices so has invariant for
positive ints and can work without branches and even test instructions.

Pull Request: https://projects.blender.org/blender/blender/pulls/144631
2025-08-16 22:12:10 +02:00
Nika Kutsniashvili
7d2b024151 UI: Theme: Move curve handle properties in common
Continuing #140360, after 39c066ee53

Moving curve handle colors & size from space editors into common theme properties.

They are now shared by 3D Viewport, Image Editor, Graph Editor, and Movie Clip Editor,
instead of each of them having their own properties.

(Video in PR)

---

Details:
- NURB U/V lines, active spline, and last selected point colors were defined
in `rna_def_userdef_theme_spaces_curves` but were optional and only called by
3D viewport. Since no other editor calls that function anymore, I removed it and
moved those properties directly inside `rna_def_userdef_theme_space_view3d`.
- In Image Editor & Movie Clip Editor (Mask mode), curves don't ever show
selection colors, and Vector handles are generally never visible, that is
bug/missing in Blender in general, not a result of this PR.
- Handle vertex size were included in Dope Sheet and NLA, where handles don't
exist. Now as a side effect they're removed as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/143762
2025-08-15 21:40:56 +02:00
Hans Goudey
814d04aaf9 Attributes: Reset various runtime data for writing files
These fields are always reset at runtime. Writing zeros should be easier
to compress since a lot of other data is zeroed, and it also makes it
easier for developers to filter out noise when looking at data buffers.

Pull Request: https://projects.blender.org/blender/blender/pulls/144582
2025-08-14 23:39:16 +02:00
Julian Eisel
ea9e390f69 Cleanup: Improve & correct comment for asset system file flag 2025-08-14 18:18:47 +02:00