Commit Graph

29202 Commits

Author SHA1 Message Date
Sean Kim
9cae162597 Cleanup: Rename various multires functions
* `multires_reshape_evaluate_limit_at_grid` to
  `multires_reshape_evaluate_base_mesh_limit_at_grid`

Pull Request: https://projects.blender.org/blender/blender/pulls/145457
2025-09-06 23:55:16 +02:00
Campbell Barton
c17f676966 Fix: 3D text line end misses last character
Regression in [0] caused line-end not to select the last character.

[0]: 98fd1a942c
2025-09-06 21:11:13 +10:00
Jesse Yurkovich
3e3ee35e9d Fix #145711: Packed images may fail to export with USD
Certain packed images, like those loaded directly into memory with
`BKE_image_packfiles_from_mem`, would cause USD to process the images as
"in memory" rather than as "packed" because the API was not removing the
IMG_GEN_TILE flag.

Additionally, be sure to use the packed filepath whenever possible
rather than the name given to the Image datablock as this ensures the
correct file names are used inside the USD file and for the resulting
file on disk after export.

This also fixes 2 render tests which now match when compared to the
native renders.

Pull Request: https://projects.blender.org/blender/blender/pulls/145749
2025-09-05 19:41:20 +02:00
Brecht Van Lommel
6a083a5464 Color Management: Add working color space for blend files
* Store scene linear to XYZ conversion matrix in each blend file, along
  with the colorspace name. The matrix is the source of truth. The name
  is currently only used for error logging about unknown color spaces.
* Add Working Space option in color management panel, to change the
  working space for the entire blend file. Changing this will pop up
  a dialog, with a default enabled option to convert all colors in
  the blend file to the new working space. Note this is necessarily only
  an approximation.
* Link and append automatically converts to the color space of the main
  open blend file.
* There is builtin support for Rec.709, Rec.2020 and ACEScg working spaces,
  in addition to the working space of custom OpenColorIO configs.
* Undo of working space for linked datablocks isn't quite correct when going
  to a smaller gamut working space. This can be fixed by reloading the file
  so the linked datablocks are reloaded.

Compatibility with blend files saved with a custom OpenColorIO config
is tricky, as we can not detect this.

* We assume that if the blend file has no information about the scene
  linear color space, it is the default one from the active OCIO config.
  And the same for any blend files linked or appended. This is effectively
  the same behavior as before.
* Now that there is a warning when color spaces are missing, it is more
  likely that a user will notice something is wrong and only save the
  blend file with the correct config active.
* As no automatic working space conversion happens on file load, there is
  an opportunity to correct things by changing the working space with
  "Convert Colors" disabled. This can also be scripted for all blend files
  in a project.

Ref #144911

Pull Request: https://projects.blender.org/blender/blender/pulls/145476
2025-09-05 19:04:47 +02:00
Brecht Van Lommel
a4e9e4869d Refactor: Add foreach_working_space_color to ID type
Left for future work:
* Freestyle modifiers, dynamic paint, legacy texture mapping
* Editor colors: should be changed to sRGB?
* Studio light preferences: also sRGB, though less clear

Pull Request: https://projects.blender.org/blender/blender/pulls/145476
2025-09-05 19:03:32 +02:00
Hans Goudey
d939de98a9 Cleanup: Formatting 2025-09-05 11:10:28 -04:00
luz paz
0760b2d5aa Fix typos in source/blender/blenkernel
Fixes various user-facing and non-user-facing typos.

Pull Request: https://projects.blender.org/blender/blender/pulls/145767
2025-09-05 16:25:32 +02:00
Brecht Van Lommel
ffa4f8c7ad Refactor: Split off lighter BLI_color_types.hh from BLI_color.hh
Functions for convert between the color types and ostream support are
now outside the classes.

Many files were changed to fix cases where direct includes for headers
were missing.

Pull Request: https://projects.blender.org/blender/blender/pulls/145756
2025-09-05 11:11:32 +02:00
Brecht Van Lommel
9d2058eb1e Color Management: Warn when OpenColorIO config for blend file is likely missing
If any display, view or colorspace is not found, these would be changed to an
existing one and show warnings in the console. Now also warn about this in the
user interface using the same mechanism as loading new blend files in older Blender
versions, with a warning in the status bar and on file save.

Ref #145476

Pull Request: https://projects.blender.org/blender/blender/pulls/145756
2025-09-05 11:11:32 +02:00
Brecht Van Lommel
76a446deba Fix: Wrong color space for gizmo, fluid grid line and stamp colors
Mark these as sRGB, as they already were or should be interpreted this way.

Pull Request: https://projects.blender.org/blender/blender/pulls/145755
2025-09-05 11:11:32 +02:00
Harley Acheson
91997ea89f UI: Save Temp Window Sizes & Positions
Allow temporary windows (like File Browser, Preferences, Render,
Drivers, Info) to open at their last positions and sizes.

Pull Request: https://projects.blender.org/blender/blender/pulls/104727
2025-09-05 00:05:50 +02:00
Mattias Fredriksson
ccd8926717 Curves: Simplify calculation of NURBS basis functions
Replaces current basis function calculation which seems to be a direct
implementation of the recursive NURBS formulation. New implementation
avoids the need to check for zero divisions during iteration. Out of
bounds checks are also converted to asserts, assuming input provides
valid span index.

Performance wise this nets a 7+% performance improvement with the
average result being as fast or faster then the fastest execution
from previous implementation!

Pull Request: https://projects.blender.org/blender/blender/pulls/144457
2025-09-04 21:49:58 +02:00
Jonas Holzman
fff3af04c4 UI: Nodes: Rename Shader / Compositing RGB nodes to Color
This PR renames the Shader and Compositing RGB nodes to unify them with
the Geometry Color input node. The Compositing node output socket was
also renamed from "RGBA" to "Color" following other nodes. This is a
5.0 breaking change as part of #96219

Pull Request: https://projects.blender.org/blender/blender/pulls/140495
2025-09-04 21:42:53 +02:00
Campbell Barton
7250eef0a3 Cleanup: pass const context to CTX_py_init_get 2025-09-04 23:05:17 +10:00
Falk David
866fcd0a09 VSE: Update Strip Modifier UI
This PR updates the VSE strip modifiers interface.
It now uses the same design as the object modifiers.

Changes:

* Except for the "Mask Input" subpanel, the modifier UIs are unchanged.
* Modifiers can now be rearranged using drag & drop.
* Additionally, there is now an active strip modifier. This is exposed
   though python via `strip.modifiers.active`.

This is in part for !139634 which needs the concept of an active modifier.

Notes:

* The `modifier.cc` file included all the implementation of all modifiers.
   With the addition of a another new callback in this PR, this file was
   getting quite big so I split everything out into individual files for all
  modifiers. The modifiers are getting registered at launch.
* The modifier panels are getting added using a UI template
  (`template_strip_modifiers`) very similar to the object modifiers.

Pull Request: https://projects.blender.org/blender/blender/pulls/145367
2025-09-04 15:01:57 +02:00
Hans Goudey
5418f0bc68 Fix: Geometry nodes reorders attributes in some cases
Currently attribute names are often added to a hash map that doesn't
maintain the original order. This is convenient for developers but it's
better for users if attributes aren't arbitrarily reordered. Instead,
use `VectorSet` which gives the benefit of a hash map but maintains the
insertion order. The main downside is the loss of O(1) removal which we
benefited from in a few cases. I used string comparison instead for now.

Fixes #144491, #122994

Pull Request: https://projects.blender.org/blender/blender/pulls/145668
2025-09-04 13:59:44 +02:00
Campbell Barton
75a3dad4b9 Fix #145714: mesh.validate() asserts editing immutable layers
Ensure corners layers are mutable, was only called on face-data.
2025-09-04 19:00:30 +10:00
Campbell Barton
16246d06d5 Fix: missing newlines loading 3D text from older blend files
Resolve regression in [0] which removed checks for `\r` without
versioning blend files.

[0]: c742a4b62b
2025-09-04 17:08:48 +10:00
Jacques Lucke
df68dc5768 Nodes: remove writing legacy node group interface
When panels in node groups were introduced, the interface data of a tree was
moved from `tree.inputs_legacy/outputs_legacy` to `tree.tree_interface`. For
forward compatibility, the old interface was still written. Since Blender 4.5
can read the new format and older versions are not able to open files created in
5.0 directly anymore, it's fine to remove this forward-compatibility code now.

Also fixes #145278.

Pull Request: https://projects.blender.org/blender/blender/pulls/145489
2025-09-04 06:45:32 +02:00
илья _
6c51993aa3 Geometry Nodes: COW Elision for attribute default filling
Avoid `*_for_write` calls if will not perform any write actions later.
This is a theoretical optimization, only in some fairly specific
situations though.

Pull Request: https://projects.blender.org/blender/blender/pulls/145540
2025-09-04 02:41:55 +02:00
Brecht Van Lommel
9d7330a223 Refactor: Color Management: Pass ImageFormatData to movie writing
Like image saving, this may be modified from the scene ImageFormatData
to contain the effective color management settings taking into account
overrides.

For upcoming changes, we will need to know the image buffer colorspace when
starting to write the video instead of only on the first frame.

Pull Request: https://projects.blender.org/blender/blender/pulls/145373
2025-09-03 16:32:01 +02:00
Brecht Van Lommel
3c9bc4070c Fix #145340: Object.to_mesh API change with subdivision and shape keys
Don't inherit shape keys in this case, as they are not valid.

This is to avoid an API breaking change that affects the glTF exporter.

Pull Request: https://projects.blender.org/blender/blender/pulls/145343
2025-09-03 16:17:49 +02:00
Campbell Barton
d1e0e32769 Cleanup: use more common abbreviation for ToolSettings 2025-09-03 20:10:49 +10:00
Omar Emara
3d3f0d1b64 Fix #145498: Cryptomatte assets are not selectable by name
Cryptomatte assets are not selectable by name in the Cryptomatte node
due to missing metadata. This patch adds he necessary meta-data to make
this work.

Pull Request: https://projects.blender.org/blender/blender/pulls/145643
2025-09-03 10:48:00 +02:00
Campbell Barton
d77aac594f Fix #145590: translations causing driver expressions to fail
Resolve regression in [0] where name was translated for the name but
not the Python expressions, it's possible to translate both but this
doesn't seem so simple as these functions don't necessarily run at
the same time.

[0]: 6926596174
2025-09-03 17:40:29 +10:00
Sean Kim
3c0f8b0def Refactor: Move paint cursor fields to runtime struct
* Moves the paint cursor pointer to `PaintRuntime`
* Removed the stored runtime color value - this was effectively
  hardcoded to a shade of red (255, 100, 100) with an alpha of 128.

The red color was only used for the smooth stroke overlay (the trailing
line) and the alpha value was only ever used for the *Line* stroke type.

Pull Request: https://projects.blender.org/blender/blender/pulls/145371
2025-09-03 07:13:11 +02:00
Toby Yang
5f8311f596 Paint: Add pressure mapping curves for size, jitter, and strength
This commit adds support for users to customize individual pressure
mapping curves for size, strength, and position jitter on a per-brush
basis to improve expression when using drawing tablets. This feature is
already implemented in Grease Pencil, and this PR adds the same
functionality to Texture/Image paint, Vertex/Weight paint, and Sculpt
modes.

The UI and functionality are the same as those in Grease Pencil.

Co-authored-by: Sean Kim <SeanCTKim@protonmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/144428
2025-09-03 05:34:38 +02:00
Hans Goudey
848ced8fe6 Curves: Parallelize nurbs custom knots offsets cache calculation
Build the size for each curve in parallel, then accumulate the sizes
to offsets afterwards. This way it's easy to parallel. Also only count
custom knots for NURBS.

Pull Request: https://projects.blender.org/blender/blender/pulls/145581
2025-09-03 04:29:08 +02:00
Campbell Barton
2ee1b0fa84 Cleanup: minor changes to target_project_edge error checking
- Move divide-by-zero check earlier.
- Operate on int before float conversion.
- Use float literals.
- Use const variables.
2025-09-03 10:40:06 +10:00
Sean Kim
709286ecc9 UV: Add forwards compatibility conversion for brush size
The prior change missed that `UvSculpt` brushes have their own isolated
`size` value stored at the `ToolSetting` level and not stored as either
brush assets or on the `UnifiedPaintSettings` struct

Similar to #139813

Pull Request: https://projects.blender.org/blender/blender/pulls/144837
2025-09-03 00:23:22 +02:00
Hans Goudey
dbf777569b Fix #145133: Invalid node link node pointer in certain file
Somehow the file in this report ended up with a node pointer that
disagreed with the socket pointer. Since we use the latter for drawing,
that's a better source of truth. This commit adds a versioning step
that corrects the node pointer. If this happens again we may need
to run the versioning again at some point, but that's not clear.

Pull Request: https://projects.blender.org/blender/blender/pulls/145409
2025-09-02 16:24:26 +02:00
Sybren A. Stüvel
15922bec71 Anim: fix crash when loading F-Curve with unknown modifier
When loading a blend file that has an F-Curve with an unknown modifier
on it, this should be gracefully handled.

Pull Request: https://projects.blender.org/blender/blender/pulls/145574
2025-09-02 16:08:38 +02:00
Bastien Montagne
329112c4d3 NodeTree: Add 'real' custom properties to Nodes.
Add back custom properties to nodes, and properly expose them in the UI
as such (new 'Custom Properties' panel for nodes in the the Node
Editor).

This shows like any other custom property panel in the UI, in the Node editor:

<img width="424" alt="image.png" src="attachments/adb50815-0db0-447f-ac3b-7860d9a3e3fc">

Although not initially intended for this, nodes 'mixed' IDProperties
were quite widely used by py/extensions developers to store per-node
data.

During the initial IDProperties split between User-defined (aka custom
data) and system-defined (runtime RNA properties), this was not known,
so decision was made to only keep system properties for Nodes. The fact
that these properties were not exposed at all in UI also played a role
in that decision. See also discussions in #141042.

This commit instead splits system properties out into their own new
storage, and keep existing ones for user-defined/custom properties
(as done for other IDProperty owners, like IDs, bones, etc.).

Pull Request: https://projects.blender.org/blender/blender/pulls/145424
2025-09-02 14:13:28 +02:00
Brecht Van Lommel
2eaa8dc7d5 Compositor: Add Convert to Display node
This applies an OpenColorIO display, view and look transform on a color
in the scene_linear colorspace.

In general, OpenColorIO configurations do not contain a colorspace for
every view + display, especially if they are modern configs using the
display colorspace and shared view mechanisms. Nor do they include looks.
So the Convert Colorspace node is not sufficient.

Additionally, we would like to avoid making the colorspace list too long
in the default config, as we are adding many new views and transforms.

Exposure, gamma curves and white point functionality are not included
in this node, as there are native ways of doing that in the compositor.
These settings are marked non-editable in the Python API.

Pull Request: https://projects.blender.org/blender/blender/pulls/145069
2025-09-01 16:28:07 +02:00
Bastien Montagne
77e700a081 Fix #145295: Crash if not finding the linked data after relocating the library.
Mistake in refactor of Relocate code in a1abf9a64e, the handling of
cases where a valid (exisitng, missing linked placeholder ID) was not
found in the searched library(-ies) was not handled properly in the new
code.

These need to be ignored by remapping from old to new (relocated) IDs,
since it's better to keep the placeholder 'empty reference' IDs, than
remap to null!
2025-09-01 15:41:20 +02:00
Sean Kim
8188dbd246 Paint: Change brush size values to represent diameter
This commit changes the internal storage and user-facing representation
of the brush size values (`size` and `unprojected_size`) from radius
to diameter.

This has a number of benefits:
* While the radius is more helpful for many internal operations, it is
  more natural to estimate the size of a brush by the diameter
* Because the pixel size is stored as an integer, users are currently
  unable to make brushes that have an odd numbered diameter, notably
  preventing the ability to make single pixel brushes.

Internally, the `Brush` and `UnifiedPaintSettings` size values are
versioned to double their on-disk values. The relevant `BKE` functions
that access the data return the radius at runtime, and any internal
`struct`s that stored radius continue to do so.

The 'Radius' text for brushes is changed to 'Size' and all references
to it in descriptions are changed to 'size' as well.

Resolves #134204

Pull Request: https://projects.blender.org/blender/blender/pulls/142495
2025-08-30 00:18:41 +02:00
Nika Kutsniashvili
cb22938fe9 UI: Theme: Move keyframe properties to common
Continuing #140360

This PR moves keyframe theme properties from editors into Common.
Besides Dope Sheet, keyframe properties were in:

- Sequencer (almost all types, and might use more in the future)
- 3D Viewport, where the active object name overlay used a separate Object Keyframe color when
it had keyframes on the current frame. Now it uses the common Keyframe Selected color, instead
of having its own property just for this little text.
- Keyframes in Movie Clip Editor were hard-coded white, now they use a common Keyframe color.
Selected colors used wrong long key selected color, now they use common Keyframe Selected color.
- Movie Clip Editor also used separate colors for what it called "Strips", but they are visually
the exact same thing as "long keys" in Dope Sheet, so they use common long key colors now.

There are Keyframe Border properties in Dope Sheet, Sequencer, and NLA, but they're not shared
because they're drawn on very different backgrounds, in different sizes, with different fill colors, so
it's difficult to make one color work for all of them, and it can restrict customization and accessibility.

Video in PR

---

Details:
- Long keys in Dope Sheet/Clip Editor and Strips in NLA used the same internal "strip" attribute.
Those needed to be separated to properly use long key colors in common, without worrying
about affecting unrelated things, and those two are as unrelated as they can get.
To properly separate them I added new "long_key" attributes, and corresponding
`TH_LONGKEY` and `TH_LONGKEY_SELECT`.
- Long keys in Movie Clip Editor had hardcoded alpha. Now they use alpha of the theme color.

Pull Request: https://projects.blender.org/blender/blender/pulls/144259
2025-08-29 23:22:38 +02:00
Sean Kim
c84b81003f Refactor: Use container types for Subdiv face_ptex_offset
This commit changes the face_ptex_offset from a manually managed int
array to a blender::Array. This required a number of changes:

* The `Subdiv` struct is no longer trivial, so MEM_new and MEM_delete
  need to be used
* The Draw module API has an overloaded set of `origindex_buffer`
  methods created to take in a Span instead of an int pointer and size

Pull Request: https://projects.blender.org/blender/blender/pulls/141702
2025-08-29 21:52:19 +02:00
Hans Goudey
ae53dc3a60 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. I'm working on the pointer stability
solution now to address a memfile undo performance regression
in 5.0 due to the `AttributeStorage` read/write design.

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.

This change is backward compatible but not forward compatible.

Second try after #144626

Pull Request: https://projects.blender.org/blender/blender/pulls/144878
2025-08-29 16:58:08 +02:00
Campbell Barton
95990fdfe3 Cleanup: typo in VFontToCurveIter struct member 2025-08-29 13:45:59 +10:00
Campbell Barton
6d92bf00a6 Cleanup: use float2 for some 3D text logic 2025-08-29 03:40:33 +00:00
Sean Kim
d124f95311 Refactor: Deduplicate Paint BVH source of truth for position cache access
This commit refactors the relevant code to extract the
logic of determining which cache to use into a centralized location to
avoid missing updates happening in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/143580
2025-08-29 00:22:36 +02:00
Sean Kim
47362112a6 Fix #145305: Crash on loading file from 1.7x
Introduced in 7f3aa617ce

Pull Request: https://projects.blender.org/blender/blender/pulls/145369
2025-08-28 23:24:17 +02:00
Sean Kim
f074e3529d Cleanup: Remove unused 'DispOp' enum
Pull Request: https://projects.blender.org/blender/blender/pulls/145289
2025-08-28 22:47:06 +02:00
Hans Goudey
c01d4a4ee6 Refactor: Deduplicate position transform utilities
The pattern of transforming many position vectors at once is quite
common, both with separate source and result arrays, and when modifying
an array in place. In some cases at least we used a separate function
with a consistent name across files, but there were also many duplicate
parallel transform implementations.

This commit adds these utilities to the BLI_math_matrix.hh API and uses
them where many positions from contiguous arrays are transformed at
once. While there might be a more ideal location for these utilities,
it's consistent with 3936d7a93e, and certainly better
than duplicating them.

This also reduces binary size of my build by 15 KB.

Pull Request: https://projects.blender.org/blender/blender/pulls/145352
2025-08-28 19:27:17 +02:00
Nika Kutsniashvili
ea47231a7b UI: Make selected track color in Movie Clip Editor themeable
Selected tracks in the Movie Clip Editor's Dope Sheet used hard-coded color.
Added a new theme property for them, and previously hard-coded color is now just a default.

Pull Request: https://projects.blender.org/blender/blender/pulls/144265
2025-08-28 19:12:11 +02:00
Bastien Montagne
fa61e3b9b8 Clenaup/Fix: Missing handling of ObHook::parent Object pointer.
While handling this pointer is technically not needed in `foreach_id`
code (and likely never will be), better not rely on such undocumented
implicit specifics, and instead properly handle it there, with comments
and asserts explaining why it should not be actually executed in current
code.

Pull Request: https://projects.blender.org/blender/blender/pulls/145345
2025-08-28 18:05:54 +02:00
Jacques Lucke
20956c69fa Fix: Nodes: crash when opening files with closure and bundle nodes saved in 4.5
This adds support for opening "invalid" files containing closure/bundle nodes that have
first been saved with 5.0, then resaved with 4.5. Note that loading them in 4.5 only works
after #145337.

Pull Request: https://projects.blender.org/blender/blender/pulls/145333
2025-08-28 16:31:33 +02:00
Jacques Lucke
2e4d2ad5ab Refactor: BLI: reduce code size for virtual arrays
Previously, `VArrayImpl` had a `materialize` and `materialize_to_uninitialized`
function. Now both are merged into one with an additional `bool
dst_is_uninitialized` parameter.  The same is done for the
`materialize_compressed` method as all as `GVArrayImpl`.

While this kind of merging is typically not ideal, it reduces the binary size by
~200kb while being basically free performance wise. The cost of this predictable
boolean check is expected to be negligible even if only very few indices are
materialized. Additionally, in most cases, this parameter does not even have to
be checked, because for trivial types it does not matter if the destination
array is already initialized or not when overwriting it.

It saves this much memory, because there are quite a few implementations being
generated with e.g. `VArray::from_func` and a lot of code was duplicated for
each instantiation.

This changes only the actual `(G)VArrayImpl`, but not the `VArray` and `GVArray`
API which is typically used to work with virtual arrays.

Pull Request: https://projects.blender.org/blender/blender/pulls/145144
2025-08-28 14:24:25 +02:00
Julian Eisel
450f428434 Fix #143699: Pose library asset shelf does not apply poses
This was quite involved to get to work. Basic idea is to make
`bl_activate_operator` work for the pose library asset shelf, and
introducing a `bl_drag_operator` for blending poses.

- Make pose asset operators take an asset reference, which is how
  `bl_activate_operator` usually gets the asset to operate on. This way
  poses references can be assigned to a shortcut, identified by asset
  library and relative asset path within the library. Falls back to
  getting the asset from context.
- Trigger `bl_activate_operator` on every click, instead of only when
  an un-active item becomes active. Needed so poses can be re-applied
  as before.
- Fix button context not passed to the `bl_activate_operator` when
  force-activating, e.g. on right-click events.
- Allow registering a `bl_drag_operator` in the asset shelf definition.
  Executed when dragging an asset in the shelf.
- When dragging an asset, highlight it as active, without calling the
  `bl_activate_operator`. This is important feedback to the user.
- Activate/select view items on click instead of drag, so dragging is
  possible.
- Let pose applying operators handle the Ctrl key to apply poses
  flipped. There's no simple way to attach such alternative behaviors
  to `bl_activate_operator`/`bl_drag_operator`
- Remove keymap items that were there for the previous "hacky" solution
  to apply & blend poses.

Pull Request: https://projects.blender.org/blender/blender/pulls/144023
2025-08-28 12:04:31 +02:00