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
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.
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
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
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
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
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
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
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
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
`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.
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
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
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
* 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
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
* 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
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
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.
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.
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.
- 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
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.
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
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
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
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
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
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