Commit Graph

26454 Commits

Author SHA1 Message Date
Casey Bianco-Davis
6e7eb4d7b6 Fix: Grease Pencil: Sculpt Smooth Tool Bezier Handles
This makes so that bezier handles will be smoothed by the `Smooth Tool`.

Note: A `BLI_assert` is removed, the logic used was wrong.

Pull Request: https://projects.blender.org/blender/blender/pulls/141912
2025-08-04 14:23:53 +02:00
Jacques Lucke
99984b3b05 Nodes: optimize freeing all nodes
We generally expect `bNodeTreeRuntime::nodes_by_id` to be valid at all times, so
it also has to have the same order `bNodeTree.nodes`. When freeing a node, the
entire vector set was rebuild currently to ensure that invariant. This leads
O(n^2) behavior when all nodes are freed as is commonly the case with depsgraph
copies etc.

This patch implements an optimization where `nodes_by_id` is not rebuild if only
the last node was removed. In this case, that not can just be popped from
`nodes_by_id` without affecting the order of the other nodes. To use this
optimization, the node tree freeing code now frees nodes in reverse order.

Pull Request: https://projects.blender.org/blender/blender/pulls/143831
2025-08-02 12:35:16 +02:00
Jacques Lucke
9fd877e174 Fix: Nodes: copied node not always added to nodes_by_id 2025-08-02 11:34:09 +02:00
Jacques Lucke
5b73f798d0 Refactor: Nodes: allow passing already unique name/identifier to node copy function
This is useful when the src node name is not unique, but the caller can provide
a unique name more efficiently then if the function has to compute the name
automatically.
2025-08-02 11:02:10 +02:00
Jacques Lucke
252b983c0c Geometry Nodes: change idnames of experimental bundle and closure nodes
This removes the "Geometry" part from their name because we want to use them in
other node tree types too (see #141936).

Usually, we don't change idnames because they are the primary identifier of
nodes and is expected to stay the same. Since they are generally not shown to
users (just Python developers), it's also not urgent to change them. However, in
this specific case we have the opportunity to update the idname before the node
becomes an official feature, so it's not as bad to change it.

This patch has full backward compatibility, but no forward compatibility (for
files that used the experimental feature).

Pull Request: https://projects.blender.org/blender/blender/pulls/143823
2025-08-02 10:17:39 +02:00
Philipp Oeser
8678766c5a Fix #143648: Cannot add collection instances to light linking
Since c6c127bfd3, objects for which `OB_TYPE_IS_GEOMETRY` fails (e.g.
Empties) were skipped.
However, empties instancing collections works well with light linking if
they contain geometry so we should be supporting these.

In order to do this use an existing function from preview rendering
(`collection_preview_contains_geometry_recursive`), move that to BKE and
use that from light linking operators.

Pull Request: https://projects.blender.org/blender/blender/pulls/143776
2025-08-01 15:43:00 +02:00
Campbell Barton
2c27d2be54 Cleanup: grammar corrections, minor improvements to wording 2025-08-01 21:41:24 +10:00
Campbell Barton
f3e4b45115 Cleanup: typos in code comments 2025-07-31 06:17:48 +00:00
Sean Kim
978fa597c0 Fix: SculptSession#last_active_vert uses incorrect value
Error in ab5ce3061a

Pull Request: https://projects.blender.org/blender/blender/pulls/143672
2025-07-31 00:51:19 +02:00
Harley Acheson
276eee8f53 BLF: Correct the Showing of VFont Not Found Character
When VFont objects use a custom (non-default) font and reference a
character that is not contained in that font, our intention is to show
placeholder curves that represents "not found". Instead we are
currently showing the ".notdef" glyph if there is one defined inside
the font or blank space if not. This PR fixes that by altering
BLF_character_to_curves so that it returns a boolean success instead of
character advance. This way we can properly distinguish "not found"
from the return of other empty, non-advancing characters.

Pull Request: https://projects.blender.org/blender/blender/pulls/143484
2025-07-30 21:25:18 +02:00
Jacques Lucke
1260e90b4c Refactor: Geometry Nodes: simplify detection of syncable nodes
This moves most of the code to deal with syncable nodes (such as
Combine/Separate Bundle) to the nodes module. Over time it might be possible to
decentralize it more.

This also changes the caching mechanism from storing a flag on the node to
storing a map on the node editor runtime data. This simplifies the code quite
significantly and also removes the need to store any of this data in DNA.

The node tree update code now always clears this cache because before it was
missing many cases, e.g. when creating links that would connect a Combine to a
Separate Bundle node.

Pull Request: https://projects.blender.org/blender/blender/pulls/143661
2025-07-30 20:42:20 +02:00
Jacques Lucke
21ca4584b6 Geometry Nodes: show sync button on bundle and closure nodes if syncing is possible
This shows a sync button when Geometry Nodes has detected that
syncing is possible and might be necessary.

Pull Request: https://projects.blender.org/blender/blender/pulls/140967
2025-07-30 18:51:14 +02:00
Jacques Lucke
78c161585b Fix: Nodes: single value types sometimes shown as dynamic 2025-07-30 17:05:00 +02:00
Jacques Lucke
6cd1c5c031 Fix: missing main invariants update after append
This could result in a crash before when appending a data-block that was already linked before.

Pull Request: https://projects.blender.org/blender/blender/pulls/143606
2025-07-30 15:41:40 +02:00
Jacques Lucke
76a861ab41 Geometry Nodes: move more menu inputs to sockets
This is a continuation of #140705. It changes more menu node options to be input
sockets. It also changes the order of the input sockets in a few cases to make
the node look a bit better.

Forward and backward compatibility is preserved.

Pull Request: https://projects.blender.org/blender/blender/pulls/142220
2025-07-30 15:32:10 +02:00
Brecht Van Lommel
e82dab28b8 Fix #143148: Attribute shader node no longer finds custom property
This code was not meant to be changed to system ID properties, it was
explicitly looking for custom properties before resolving the RNA path.

There are tests for this functionality, but because the versioning copies
the ID properties to the system ID Properties, it worked for existing
properties but not newly created ones.

Pull Request: https://projects.blender.org/blender/blender/pulls/143574
2025-07-30 14:30:56 +02:00
Pratik Borhade
3bfd4c83f6 Core: Rename ID name and plural_name for annotations
This resolves a bug #143101 caused by 20383e4d82
`outliner_idcode_to_plural` fails to find correcty idtype with old
plural name. Fix this so it matches with `MainCollectionDef`.

Pull Request: https://projects.blender.org/blender/blender/pulls/143179
2025-07-30 11:41:44 +02:00
Campbell Barton
f281f5a500 Cleanup: header grouping
Group includes, this is mostly being done already but had become mixed
up in some areas.
2025-07-30 14:22:06 +10:00
Sean Kim
4858e8e1bc Cleanup: Use enum class for PlaneAABBIsect
Pull Request: https://projects.blender.org/blender/blender/pulls/143586
2025-07-30 00:03:23 +02:00
Sean Kim
0e19a40e3a Cleanup: Rename internal Paint BVH node_tree struct 2025-07-30 00:03:16 +02:00
Omar Emara
0a1d146389 Fix #143542: Missing Media Type when in saving operator
If the scene is currently set to a Video media type and the user uses
the Save Image As operator, the Media Type in the operator will be
empty. That's because the image saving format is initialized based on
the scene format, but image saving does not support videos, so the enum
is invalid in that context.

This issue already existed before the introduction of media types, but
it happened for the file format field directly.

To fix this, we default to an image type if the scene is set to a video.

Pull Request: https://projects.blender.org/blender/blender/pulls/143549
2025-07-29 16:21:50 +02:00
Lukas Tönne
e676146516 Fix: Deleting instances fails assert on index range
Resizing instances initializes new element attributes, but this is only
valid when the capacity grows. Shrinking produces an invalid index range.

Pull Request: https://projects.blender.org/blender/blender/pulls/143535
2025-07-29 16:00:16 +02:00
Christoph Lendenfeld
5dfbe1af21 Refactor: Replace PBONE_SELECTED macro with functions
This PR changes the uses of `PBONE_SELECTED` and all the
places where it *should* have been used
with a new function `bone_is_selected` or `...editbone`
and `...pose_bone` specializations.

No functional changes intended.

Do note that there are still places in the code
where this function should probably be called,
but this PR is very careful not to change any behavior,
even if the current behavior is probably wrong.

In preparation for storing pose bone selection state
on the `bPoseChannel`
Related to #138482

Pull Request: https://projects.blender.org/blender/blender/pulls/139496
2025-07-29 14:37:35 +02:00
Hans Goudey
1557d5c388 Fix: Potential null pointer dereference in attribute accessors
`AttributeIter::get()` could potentially use the `accessor` field
which wasn't set for curves or mesh vertex groups. "is_builtin"
can also be explicitly set for this case.
2025-07-28 17:59:01 -04:00
Jacques Lucke
5f132d3f07 Nodes: support storing internal data in Bundle
Currently, bundles can only store socket values of Geometry Nodes. However, it
can make sense to store other kinds of data too. Specifically, this patch adds
support for storing arbitrary internal data in a bundle. This is useful when
storing e.g. the physics world when implementing a proper physics solver for
Geometry Nodes (like in #143171).

One can still see that the data exists in Geometry Nodes in the tooltip, but one
can't extract it. Built-in nodes can still read that data.

Storing built-in data in bundles can also be done as an alternative to having a
new "internal data socket" as we talked in a workshop in the past:
https://code.blender.org/2024/11/geometry-nodes-workshop-october-2024/#internal-data-sockets

A bundle still has to be copyable. Internal data is expected to use implicit
sharing. That way copying it just requires increasing the user count of the
data.

Pull Request: https://projects.blender.org/blender/blender/pulls/143472
2025-07-28 19:05:18 +02:00
Hans Goudey
3936d7a93e Fix #142485: Shading artifacts with free custom normals and scale transform
When transforming a geometry, we often apply the transposed inverse
to normals / custom normal data. However, that matrix can still contain
scale from the original matrix. That scale has to be removed so we can
avoid also scaling the normals.

I used the opportunity to remove the duplication between mesh and curves
processing of the custom normals, and to formalize an optimization to
skip the final normalization of each vector if the transform is such
that it isn't necessary. The new functions don't fit beautifully into
their public headers, but I don't know of a better place for them.

Pull Request: https://projects.blender.org/blender/blender/pulls/142896
2025-07-28 17:25:34 +02:00
Sergey Sharybin
38f867814f Fix #143191: 10/12 bit videos import much too dark
Originally reported for ProRes codec, but it affects multiple
other codecs: any format which is read as >= 10bit had the issue.

A regression since 93be12fde0.

The cause of the issue is that movie clip and image data-blocks
did linearization on their side, which was quite hidden to find.
Now the color management is done on the movie reader level.

Additionally, added regression test to catch such issues early
on in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/143435
2025-07-28 15:14:23 +02:00
Bartosz Kosiorek
fe96b2a613 Fix #107679: Smoke simulation adaptive domain shrinks too much
* Take into account heat grid in addition to density and fuel, as this is used for
  displaying smoke in Blender.
* Lower adaptive domain threshold from 0.02 to 0.002, to fix visual issues with
  small smoke density that can still be visible.

Pull Request: https://projects.blender.org/blender/blender/pulls/139940
2025-07-28 14:15:07 +02:00
Habib Gahbiche
445eceb02a Nodes: Remove "Use Nodes" in Shader Editor for World
Part of https://projects.blender.org/blender/blender/pulls/141278

Blend files compatibility:
If a World exists and "Use Nodes" is disabled, we add new nodes to the
existing node tree (or create one if it doesn't) that emulates the
behavior of a world without a node tree. This ensures backward and
forward compatibility.

Python API compatibility:
- `world.use_nodes` was removed from Python API => **Breaking change**
- `world.color` is still being used by Workbench, so it stays there,
although it has no effect anymore when using Cycles or EEVEE.

Python API changes:
Creating a World using `bpy.data.worlds.new()` now creates a World with
 an empty (embedded) node tree. This was necessary to enable Python
scripts to add nodes without having to create a node tree (which is
currently not possible, because World node trees are embedded).

Pull Request: https://projects.blender.org/blender/blender/pulls/142342
2025-07-28 14:06:08 +02:00
Brecht Van Lommel
fa007002b1 Refactor: Logging: Move G.quiet to CLOG, replace some printfs
* Replace G.quiet by CLG_quiet_set/get
* CLOG_INFO_NOCHECK prints are now suppressed when quiet, these were
  typically inside a if (!G.quiet) conditional already.
* Change some prints for blend files, color management and rendering to
  use CLOG, that were previously using if (!G.quiet) printf().

Pull Request: https://projects.blender.org/blender/blender/pulls/143138
2025-07-28 13:36:13 +02:00
Bartosz Kosiorek
b1d5c35f3a Physics: Change default shape for Bubble and Foam particles, to increase visibility
Change default shape of Bubble and Foam, to be able to notice potential
artifacts in the Viewport. The shape for bubble was changed to circle, and
the shape for Foam was changed to cross.

It allows users to notice and fix artifacts in early stages for reports like:
#79995 #81011 #85533 #97063

Pull Request: https://projects.blender.org/blender/blender/pulls/138681
2025-07-28 13:33:04 +02:00
Bartosz Kosiorek
127d891f31 Fix #86512: Fire simulation without smoke not affected by force field
It was incorrectly skipping effectors in this case.

Fix #86512
Fix #129427

Pull Request: https://projects.blender.org/blender/blender/pulls/137679
2025-07-28 13:16:17 +02:00
Campbell Barton
f6af0aae7c Cleanup: use UTF8 string functions for tracking members
Use UTF8 aware functions unless raw bytes are expected.
2025-07-27 16:39:57 +10:00
Campbell Barton
e93e9db6b7 Cleanup: UTF8 string functions for color-space & imbuf strings
Use UTF8 aware functions unless raw bytes are expected.
2025-07-27 04:34:04 +00:00
Campbell Barton
71a19e04ff Cleanup: back-tick quote literal strings in code comments
Prevent doxygen attempting to interpret symbols withing the text.
The `make check_spelling_*` target also skips this text.
2025-07-27 12:49:02 +10:00
Campbell Barton
8c8c8d5014 Cleanup: replace *_max_length with _maxncpy for null inclusive size
The term "length" is too easily confused with the `strlen(..)`
length without the null byte. Most string functions that take a static
buffer size use the suffix `maxncpy` to avoid off by one errors.
2025-07-27 12:49:02 +10:00
Campbell Barton
649b89781e Cleanup: ensure UTF8 string copy for DNA & screen data
Use `BLI_strncpy_utf8` & `BLI_snprintf_utf8` for fixed size buffers in
DNA and screen data structures such as panels, menus & operators.

This could be considered a fix as copying a UTF8 string into a smaller
buffer without proper truncation can create an invalid UTF8 sequence.
However identifying which of these users are likely to run into would
be time consuming and not especially useful.
2025-07-26 12:33:15 +00:00
Campbell Barton
faed51f195 Cleanup: remove redundant calls to strlen 2025-07-26 12:08:15 +00:00
Campbell Barton
0531230a35 Fix: incorrect sizes of fixed size buffers, ensure valid UTF8
Correct code that was likely to truncate when copying strings and
correct the the size of fixed sized buffers.
2025-07-26 12:07:27 +00:00
Campbell Barton
24c965905e Fix: armature "Auto-Name by Axis" creating invalid UTF8 names
When auto-naming based on axis, the string concatenation didn't take
UTF8 encoding into account, adding the suffix could create names
which raised an exception when accessed from Python.

Resolve using UTF8 string truncation.

Also resolve a logical error reading past the buffer bounds if the name
passed in was longer than MAXBONENAME.
2025-07-26 11:58:39 +00:00
Hans Goudey
ed372380c5 Cleanup: Follow style guide & conventions in mesh_tangent.cc
- Order class variables before functions
- Use this-> to access non-private members
- Remove unnecessary BKE prefix
- Remove useless comments
- Use standard "uv_map" name for variable
- Use consistent order for mesh span variables
- Use C++ vector types instead of raw pointers
- Use Span instead of raw pointers
- Pass Span-like variables by value
2025-07-25 18:12:08 -04:00
Hans Goudey
855113ab06 Refactor: Mesh: Slightly simplify tangents API
The RNA `Mesh.calc_tangents()` function used a mesh tangents API wrapper
function that existed at a different abstraction level than the other
functions. That wrapper was only used in this single place, so just
inline its logic into the RNA code. Also give the base tangents API
function a name that makes its limitations clear.
2025-07-25 18:01:00 -04:00
Brecht Van Lommel
ae5152866e Fix #142724: Mesh used by boolean modifier missing subdivision in edit mode
The code path for non-editmesh has ensure subdivision in it, the editmesh one
was missing it.

Pull Request: https://projects.blender.org/blender/blender/pulls/143135
2025-07-25 15:03:45 +02:00
Pratik Borhade
832fc7af2a Fix #142982: Grease Pencil: Assert when overriding keyframes in dopesheet
Assert when overlapping keys are removed. This is due to drawing count
mismatch, more specifically when drawing is not removed/overwritten but
early check validation caused it. Remove `validate_drawing_user_counts`
from `remove_drawings_with_no_users`. If Drawing is actually removed
(`drawings_to_remove` non empty), validation function will be called at
the end.

Pull Request: https://projects.blender.org/blender/blender/pulls/143057
2025-07-25 12:47:19 +02:00
Omar Emara
92d5c2078e Render: Add Media Type option
This patch adds a new Media Type option to image format settings, which
is used in the Render Output panel, File Output node, and Image Saving
operation. The option does not provide any new functionality, but
improves the UX of selecting file types by categorizing the existing file
type option into:

- Image.
- Multi-Layer EXR.
- Video.

Each option would then list only the file types that fit that media
type. For Multi-Layer and Video, the file type option is no longer drawn
for now since only one option exist for now, OpenEXR Multi-Layer and
FFMPEG respectively. This also improves the experience by not listing
technical terms like FFMPEG in the UI, but rather use "Video" instead.

The original motivation for introducing this option is the recent
redesign of the File Output node. The problem is that the distinction
between images and multi-layers images is not at all clear, while the
behavior of the node changes quite a bit when multi-layer is chosen.
While now with the new option, the distinction is quite clear.

Implementation-wise, the new option is mostly a UI layer that controls
the available enum items for the file format and callbacks to set a
default format if the existing format doesn't match the media type.
However, core code is unaffected and still transparently reads the image
format only.

Pull Request: https://projects.blender.org/blender/blender/pulls/142955
2025-07-25 11:15:28 +02:00
YimingWu
2def8c8b67 Fix #120885: Ensure EXR view_format selection in stereo
When stereoscopy is enabled, OpenEXR and OpenEXR Multilayer supports
different stereoscopy view format, ensure the view format selection
when selecting the output file format, so the value is always valid
when saving the image.

Pull Request: https://projects.blender.org/blender/blender/pulls/120904
2025-07-25 08:26:31 +02:00
Aras Pranckevicius
bedf19f1ca Cleanup: No longer require VSE Strip struct memory layout to never change
Previously code that was reading Strip data assumed that seqbasep
and channels members would stay at fixed offsets within a struct,
forever into the future. Fix this by inferring their offsets from
the file SDNA data where needed.

Actual Strip DNA layout is not changed in this commit yet.

Co-authored-by: Sergey Sharybin <sergey@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/142940
2025-07-24 20:37:16 +02:00
Hans Goudey
4f372d64d4 Geometry Nodes: Initial very basic list support
This includes a new list structure type and socket shape, a node
to create lists, a node to retrieve values from lists, and a node to
retrieve the length of lists. It also implements multi-function support
so that function nodes work on lists.

There are three nodes included in this PR.
- **List** Creates a list of elements with a given size. The values
  are computed with a field that can use the index as an input.
- **Get List Item** A field node that retrieves an element from a
  a list at a given index. The index input is dynamic, so if the input
  is a list, the output will be a list too.
- **List Length** Just gives the length of a list.

When a function node is used with multiple list inputs, the shorter
lists are repeated to extend it to the length of the longest.

The list nodes and structure type are hidden behind an experimental
feature until we can be sure they're useful for an actual use case.

Pull Request: https://projects.blender.org/blender/blender/pulls/140679
2025-07-24 16:16:40 +02:00
Hans Goudey
9c9695b103 Refactor: Move ReportList definition from DNA to blenkernel
Ever since [0], ReportList is not actually used in any DNA structs.
That makes sense, since reports are conceptually only necessary
at runtime. Move the definition of the struct to BKE_report.hh, and
fix a bunch of include errors where types were previously available
transitively. Besides adding some clarity, theoretically this change
could reduce compile times because of less header parsing.

[0]: 1bf6d8b0b9

Pull Request: https://projects.blender.org/blender/blender/pulls/138872
2025-07-24 15:59:52 +02:00
Campbell Barton
9b05a00b50 Cleanup: use UTF8 string copy for bActionGroup::name
Avoid potential incomplete UTF8 byte sequences.
2025-07-24 22:18:15 +10:00