Commit Graph

28134 Commits

Author SHA1 Message Date
Hans Goudey
c560cdc8cc Cleanup: Use StringRef for layout panel API functions 2025-03-04 14:29:15 -05:00
Hans Goudey
a48d155c87 Geometry Nodes: Add "Face" option to Mesh to Curve node
Adds a mode option to the node to choose between the existing
behavior and new behavior that converts each face to a cyclic curve.
Generally this is much faster than the existing mode because it's
easy to parallelize and because curve offsets and face and corner
attributes can be implicitly shared to avoid copies.
Resolves #134671.

Pull Request: https://projects.blender.org/blender/blender/pulls/134773
2025-03-04 19:16:36 +01:00
Hans Goudey
a2386789da Cleanup: Sculpt: Simplify enabling BVH build debug time prints 2025-03-04 12:04:38 -05:00
Sean Kim
d6f885c408 Cleanup: Remove #ifdef blocks for Dyntopo edge code
At this point, it is unlikely that we will revert the changes made over
a decade ago to the Dyntopo edge splitting code. The old code will still
exist in the git history, but to improve readability, this commit
flattens out the blocks and removes the `#define` statements.

Pull Request: https://projects.blender.org/blender/blender/pulls/135410
2025-03-04 17:30:16 +01:00
Sean Kim
0dec2b829f Cleanup: Update LayerTypeInfo#free docstring
Pull Request: https://projects.blender.org/blender/blender/pulls/135419
2025-03-04 17:29:28 +01:00
Omar Emara
b06ed9d406 Compositor: Track update count for cache invalidation
This patch refactors static cache invalidation of images by tracking an
update count. Images now store a runtime update count that is updated
every time the image is tagged for update. Cached images store a copy of
the update count at the moment they were cached, and are invalidated if
if it changed.

Compared to #134878, this is simpler and more robust, since update IDs
are isolated to images only and not to the DEG update count. Though this
only supports images specifically because they are not covered by the
copy-on-evaluation system, which means #134878 will cause multiple
depsgraph to fight over images.

Pull Request: https://projects.blender.org/blender/blender/pulls/134905
2025-03-04 12:04:38 +01:00
Jacques Lucke
f291b116be Cleanup: extract function to capture field on geometry components 2025-03-04 11:00:31 +01:00
Christoph Lendenfeld
fae6f748a5 Merge branch 'blender-v4.4-release' 2025-03-04 10:57:10 +01:00
Christoph Lendenfeld
39fdbded9a Fix #135122: Crash when using pose assets created without slots.
The issue was that the versioning code didn't run when loading the action.
Thus it had no slots and so was crashing trying to get the first slot.

This PR fixes that in 2 ways:
* Check the slot count of the loaded action, and return/notify the user
* Actually make sure the actions are versioned

Point 1 is important anyway because actions can have no slots (though unlikely).
Point 2 ensures that old pose assets can actually be used

Pull Request: https://projects.blender.org/blender/blender/pulls/135232
2025-03-04 10:56:23 +01:00
Omar Emara
85a78774da Merge branch 'blender-v4.4-release' 2025-03-04 09:34:41 +02:00
Omar Emara
a50144e55c Fix #134914: Backdrop remain after loading new file
The compositor backdrop is still visible even after a new completely
different file is loaded. This is because compositor contexts cache
things like the backdrop, and contexts are stored on interactive
compositor renders, which are not freed until Blender is closed. To fix
this, we cleanup the interactive compositor renders that were created
upon file load.

Pull Request: https://projects.blender.org/blender/blender/pulls/135390
2025-03-04 08:33:17 +01:00
Hans Goudey
6a379f218f Cleanup: Correct comment in customdata.cc 2025-03-03 22:38:47 -05:00
Hans Goudey
935868acbb Cleanup: Simplify curve handles comment 2025-03-03 11:11:56 -05:00
Aras Pranckevicius
cc2c6692c0 Cleanup: Name more IMB things as "byte" or "float" instead of "rect" and "rectFloat"
- IB_rect -> IB_byte_data
- IB_rectfloat -> IB_float_data
- Rename some functions:
	- IMB_get_rect_len -> IMB_get_pixel_count
	- IMB_rect_from_float -> IMB_byte_from_float
	- IMB_float_from_rect_ex -> IMB_float_from_byte_ex
	- IMB_float_from_rect -> IMB_float_from_byte
	- imb_addrectImBuf -> IMB_alloc_byte_pixels
	- imb_freerectImBuf -> IMB_free_byte_pixels
	- imb_addrectfloatImBuf -> IMB_alloc_float_pixels
	- imb_freerectfloatImBuf -> IMB_free_float_pixels
	- imb_freemipmapImBuf -> IMB_free_mipmaps
	- imb_freerectImbuf_all -> IMB_free_all_data
- Remove IB_multiview (not used at all)
- Remove obsolete "module" comments in public IMB headers

Pull Request: https://projects.blender.org/blender/blender/pulls/135348
2025-03-03 17:11:45 +01:00
Sebastian Parborg
cb7d80238b Merge branch 'blender-v4.4-release' 2025-03-03 15:23:55 +01:00
Sybren A. Stüvel
6f80d722c6 Fix #135163: Grease Pencil layer visibility animation doesn't work in NLA
Add a new function `bke::animdata::prop_is_animated()` that returns
whether an RNA path + array index is animated by anything. This covers
the assigned Action, NLA Action strips, and drivers.

This function is now used in the determination whether the visibility
of a GreasePencil layer is animated.

The easiest way to implement this with the existing F-Curve-visiting
logic was to call `adt_apply_all_fcurves_cb()`. However, that function
did not allow the callback function to signal "stop looping, I found
what was I was looking for", so I extended it to do just that. I don't
expect the extra conditions to significantly slow down the other uses,
as the branch predictor will very likely optimise for the "returning
true" case for those calls that simply visit everything.

Pull Request: https://projects.blender.org/blender/blender/pulls/135317
2025-03-03 14:24:07 +01:00
Falk David
c24b540400 Fix #135313: Grease Pencil: Layer adjustments get applied repeatedly during playback
The issue was that during playback, the evaluated Grease Pencil ID
is not being copied again for re-evaluation. This meant that the
adjustments get re-applied over and over again.

Ideally, we would restore the drawing pointers before modifiying them
again, but this is a bit trickier to implement.

To fix this issue for now, we do the layer adjustments during object
data evaluation. Using the geometry set for modifier evaluation
means that we copy the data and apply the adjustments for every
object.

In the future this can be optimized to only happen once per
Grease Pencil ID (in `BKE_grease_pencil_eval_geometry`).

Pull Request: https://projects.blender.org/blender/blender/pulls/135387
2025-03-03 14:09:06 +01:00
Hans Goudey
9cade06f5f Refactor: Nodes: Use Map instead of GHash for compositor previews
Replace `bNodeInstanceHash` with a `Map`. Move it to the node tree
runtime data. Simplify some code by removing the tag from the hash
value and collecting unused previews directly. Then just remove a
bunch of code that's now unused.

Note that texture node previews haven't been working for a while
anyway, and the experimental shader node previews seem to use
a different system (this one is a remnant of Blender Internal).

Pull Request: https://projects.blender.org/blender/blender/pulls/135310
2025-03-03 14:04:20 +01:00
Bastien Montagne
666267ef40 Fix assert in BKE_main_namemap when reusing brush assets on fileload.
Code in readfile that copies over brush assets (and related data) from
the old Main to the new one cannot use the namemap reliably, due to how
the linked IDs of the library get temporarily spread between both Mains.

Since in theory there should be no need for name uniqueness processing
in this case anyway, for now disable the relevant code when the library
is re-used.

NOTE: Issue reported in #135315, revealed by recent refactor in
00f406c34c and 16e552298c.

NOTE: This fix is a bit hackish, but seems to be the simplest most
straight-forward way to address the problem. More invasive solution can
be investigated if this proves to still be problematic.

NOTE: While 4.4 also has the same invalid handling, this PR should
likely not be ported to it, as previous BKE_main_namemap code was more
permissive with such invalid behaviors, and there is no known bad
consequences in practice.

Pull Request: https://projects.blender.org/blender/blender/pulls/135362
2025-03-03 11:34:48 +01:00
Hans Goudey
0d28c93f08 Cleanup: Sculpt: Use Map instead of GHash for dyntopo edge collapse 2025-03-01 18:11:44 -05:00
Hans Goudey
8b297ab168 Cleanup: Use bNodeTree all_nodes() accessor method
This is always built at runtime.

Pull Request: https://projects.blender.org/blender/blender/pulls/135321
2025-02-28 22:12:34 +01:00
Falk David
2822777f13 Nodes: support boolean inputs as toggles in panel headers
Adds the option to create a boolean socket that can be used as a panel toggle.
This allows creating simpler and more compact node group UIs when a panel
can be "disabled".

The toggle input is a normal input socket that is just drawn a bit differently in
the UI. Whether a boolean is a toggle input or not does not affect evaluation.

Also see #133936 for guides on how to add and remove panel toggles.

Pull Request: https://projects.blender.org/blender/blender/pulls/133936
2025-02-28 19:07:02 +01:00
Bastien Montagne
16e552298c Refactor: Core: ID's 'namemap' used to generate unique ID names.
Note: This commit is essentially non-behavioral change, expect in some
fairly rare edge cases.

This commit does a few things:
* Move the whole BKE_main_namemap code to modern C++.
* Split API calls to work with the global namemap, or the local ones.
* Simplify and make the code easier to follow and understand.
* Reduce 'default' memory usage by using growing BitVector for numeric
  suffix management, instead of a fixed 1K items.
* Fix inconsistent handling of 'same base name and numeric suffix,
  different name' issues (e.g. 'Foo.1' and 'Foo.001'), see
  `re_create_equivalent_numeric_suffixes` new unittest.
* Fix completely broken handling of `global` namemaps. This was
  (probably!) OK so far because of their currently very limited
  use-cases.

It also adds a few minor improvements to existing behavior (essentially
in exotic rare edge cases):
* Names that get too long are now only shortened by one char at a time,
  trying to modify the requested base name as little as possible.
* Names that are short, but for which all the manageable numeric suffixes
  are already in use, are extended with an (increasing)  number, instead
  of being shortened.

This work also allowed to detect a few (apparently harmless?) bugs in
existing code, which have been fixed already in 4.4 and main, or in this
commit as well when they depend on changes in namemap code itself.

About performances: This commit introduces a minor slow-down. Some tests
heavily relying on this code (like `bl_id_management` and `blendkernel`
e.g.) get slightly slower (resp. about 1% and 5%). This seems to come
mostly from the added complexity to handle correctly multiple different
names with the same base and numeric suffix value ('Foo.1' and
'Foo.001', but also in the global namemap context where IDs from
different libraries can have the same name).

Pull Request: https://projects.blender.org/blender/blender/pulls/135199
2025-02-28 17:58:58 +01:00
Philipp Oeser
b0d63ff8e1 Merge branch 'blender-v4.4-release' 2025-02-28 17:14:34 +01:00
Philipp Oeser
412cefe9bb Fix: Broken "File -> External Data -> Pack Linked Libraries"
The operator refused to pack libraries with absolute paths (wasnt the
case in its original implementation 16411da41e, but was added in
129fb516f4 -- for the reason of preventing "bad things happen on
unpacking" without an explanation of what these exactly are). It did so
by cancelling as soon as **one** library with ab absolute path was
found.

Now with the introduction of essential assets, we have those absolute
path linkages more or less "by default"  as soon as e.g. a brush is
used, so the operator is more or less unusable now. NOTE: these absolute
essential asset library paths seem to be converted to relative on save?
Upon reload, these are then gone... (might be another hint for an
alternative fix, see below)

By "bad things happen on unpacking" I would assume the scenario of
folders being created in unwanted locations (e.g. when moving from one
OS to another), but the same thing is also true for packing **files**
instead of libraries (there, absolute paths are allowed, and unpacking
in original locations can equally fail or create folder structures that
are "unexpected"). NOTE: for files though we have the choice of
unpacking to a relative folder (which wouldnt really be possible since
libraries can be nested and we would have to correct paths all over the
place). NOTE: the chance of creating "unwanted" folder structures with
relative paths might be slimmer, but if you have a lot of "upwards"
parent folders, relative can easily "break" as well.

Possible ways to resolve this:

### [1] skip libraries identified as essentials assets (still cancel on all other absolute paths)
Can check a library path to be contained in `EssentialsAssetLibrary`
`essentials_directory_path`. This would be the safest imo since it is a no-behavior change.

### [2] lift the limitation of absolute paths alltogether
Like mentioned above, things could break with "relative" almost as
easily as with "absolute", there might even be scenarios where
"absolute" is wanted. It is a more behavior-changing fix that we might
explore more after 4.4 is out.

### [3] skip absolute libraries (but continue with non-absolute libraries)
This does change behavior as well (it does not cancel as soon as **one**
library with ab absolute path was found anymore, but the worst case
scenario is that you end up with an "incomplete" file if you really
mixed absolute and realtive lib linking).

This PR implements [1] for now, [2] or [3] can follow for 4.5.

Fixes #134665

Pull Request: https://projects.blender.org/blender/blender/pulls/134839
2025-02-28 17:14:14 +01:00
Sybren A. Stüvel
559d7575a6 Cleanup: remove mention of once-planned 'Animation' data-block
Remove the mention of the 'Animation' data-block in a comment, as that
never was actually implemented.

No functional changes.
2025-02-28 17:12:39 +01:00
Aras Pranckevicius
5f667fa2bc Cleanup: Replace IMB_processor_apply_threaded_scanlines with parallel loops
Code can become quite a bit smaller without intermediate structs

Pull Request: https://projects.blender.org/blender/blender/pulls/135299
2025-02-28 14:43:05 +01:00
Lukas Tönne
d6e8323190 Merge branch 'blender-v4.4-release' 2025-02-28 09:06:23 +01:00
Lukas Tönne
4437782e00 Fix #135126: Mantaflow crashes when resizing a liquid domain
The `with_smoke` case is handled correctly and checks for reallocation,
but the liquid case was ignored for unknown reasons.

The `with_smoke` distinction was added years ago (c7596cd820)
but for some reason the `with_liquid` case was ignored for reallocation.

Pull Request: https://projects.blender.org/blender/blender/pulls/135247
2025-02-28 09:03:29 +01:00
Hans Goudey
582cdc0cf2 Cleanup: Use Array for FieldInferencingInterface
There is no need for amortized growth for the field interface.
Array seems slightly better than Vector because it's smaller and
doesn't give the impression that the size might change.

Pull Request: https://projects.blender.org/blender/blender/pulls/135257
2025-02-27 17:32:51 +01:00
Jeroen Bakker
11325aaff0 Cleanup: Fix typo in subdiv_eval.cc
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/135254
2025-02-27 16:47:06 +01:00
Hans Goudey
a701e01e5d Cleanup: Use auto after static_cast to avoid repetition 2025-02-27 09:58:03 -05:00
Hans Goudey
4b0cb31d3f Cleanup: Remove "e" prefix for field status enum name 2025-02-27 09:58:03 -05:00
Hans Goudey
aa6eb93015 Cleanup: Typo in comment, argument name consistency 2025-02-27 09:58:03 -05:00
Lukas Tönne
dfc7140655 Merge branch 'blender-v4.4-release' 2025-02-27 12:32:37 +01:00
Lukas Tönne
b34c116398 Fix: Geometry Nodes menu socket can leak memory
The enum items propagation mechanism for Menu sockets makes a local copy of item
pointers to propagate between node group inputs and interface definitions.
In case these items are not used (e.g. because they are already shared with the
socket) the local copy must still be released to avoid leaking the memory.

This only happens with more than 4 enum items, because of the internal default
buffer for `Vector`.

Pull Request: https://projects.blender.org/blender/blender/pulls/135226
2025-02-27 12:31:31 +01:00
Jacques Lucke
63e6f53ba0 Modifiers: new Visual Geometry to Objects operator
This adds a new `Visual Geometry to Objects` operator which is added to the
`Apply` menu.

It creates new objects from the evaluated geometry of the active object. Other
than e.g. applying modifiers, this operator does keep all generated data and
creates new objects and collections for instances. It does have some
similarities to `Make Instances Real` with the main difference that it doesn't
actually realize instances, i.e. instanced geometry is still shared between all
objects using it.

It does intentionally not replace the original object, because the semantics of
that aren't all that obvious. It's especially tricky when the object was
referenced by other objects. Instance attributes are not preserved currently.

Pull Request: https://projects.blender.org/blender/blender/pulls/134119
2025-02-26 17:48:54 +01:00
Philipp Oeser
a5d652e5c0 Merge branch 'blender-v4.4-release' 2025-02-26 15:56:25 +01:00
Philipp Oeser
a636b101d7 Fix #121609: Shrinkwrap invert vertex group (no group specified) wrong
Same was true for SimpleDeform.

Invert vertex group influence should only have an effect if there is a
group specified.
Shrinkwrap always uses a weight (gets weights via
`BKE_defvert_array_find_weight_safe` -- which gets full weight for no
group specified, rightfully so), if this gets inverted, we get no
influence at all.

Now move the inverting of the weights to `BKE_defvert_array_find_weight_safe`,
adjust the other callers accordingly (Bevel also does not need to check for a valid
vertexgroup beforehand).

Pull Request: https://projects.blender.org/blender/blender/pulls/121625
2025-02-26 15:56:08 +01:00
Pratik Borhade
3a1e7ffebe Fix #134737: Node: Panel deleted when Parented with children
Skip `move_to_parent()` operation when new_parent is already
children of "item" to avoid running into this situation.

Pull Request: https://projects.blender.org/blender/blender/pulls/135148
2025-02-26 14:13:33 +01:00
Aras Pranckevicius
148aa54398 ImBuf: unify color space transform threaded/non-threaded functions
There's no point in having non-threaded image color space conversion functions.
So merge the threaded and non-threaded functions and clarify names while at it:

- IMB_colormanagement_transform & IMB_colormanagement_transform_threaded
    -> IMB_colormanagement_transform_float
- IMB_colormanagement_transform_byte & IMB_colormanagement_transform_byte_threaded
    -> IMB_colormanagement_transform_byte
- IMB_colormanagement_transform_from_byte & IMB_colormanagement_transform_from_byte_threaded
    -> IMB_colormanagement_transform_byte_to_float

These places were doing single-threaded colorspace conversion previously, and
thus now are potentially faster:
- IMB_rect_from_float (used in many places)
- EXR image "save as render" saving (image_exr_from_scene_linear_to_output)
- Object baking (write_internal_bake_pixels, write_external_bake_pixels)
- General image saving, clipboard copy, movie preparation
  (IMB_colormanagement_imbuf_for_write)
- Linear conversion when reading HDR images/movies
  (colormanage_imbuf_make_linear)
- EXR multi-layer conversion (render_result_new_from_exr)

For one case I benchmarked, which is to render out a 2D stabilized 10 bit input
movie clip out of VSE, the total render time went from 49sec down to 44sec
(Ryzen 5950X), one of the single-threaded parts was the colorspace conversion
in the movieclip code.

Pull Request: https://projects.blender.org/blender/blender/pulls/135155
2025-02-26 12:11:47 +01:00
Pratik Borhade
66a3500324 Fix #134737: Node: Panel deleted when Parented with children
Skip `move_to_parent()` operation when new_parent is already
children of "item" to avoid running into this situation.

Pull Request: https://projects.blender.org/blender/blender/pulls/135148
2025-02-26 11:10:40 +01:00
Bastien Montagne
f0233665de Merge branch 'blender-v4.4-release' 2025-02-25 20:55:42 +01:00
Bastien Montagne
6b6e6a2cd1 Fix (unreported) invalid crash in debug, disabled-by-default code.
Code printing memory usage of Main ID namemaps could try to run on
nullptr.
2025-02-25 20:53:42 +01:00
Christoph Lendenfeld
6e4413d50f Merge branch 'blender-v4.4-release' 2025-02-25 12:14:52 +01:00
Christoph Lendenfeld
5100a80f7f Fix #110650: Drivers not removed if removing their container
This applies to modifiers, constraints and shape keys.
Any driver on such data was not removed with it,
leaving invalid drivers on objects.

With this patch, the drivers are removed, but animation is left untouched.
This is because animation might be reused somewhere else and we don't
want to introduce potential side effects there.

This also adds unit tests for the fixed cases

Pull Request: https://projects.blender.org/blender/blender/pulls/134511
2025-02-25 12:11:15 +01:00
Sybren A. Stüvel
196df97213 Merge remote-tracking branch 'origin/blender-v4.4-release' 2025-02-25 11:38:15 +01:00
Pratik Borhade
d961f8f9ec Grease Pencil: Remove legacy object type references
Remove GP legacy obtype and unused functions
Few hidden bugs are fixed with that:
- Outliner drag-drop for GP material/effect elements now works
- Correct stats are shown in status bar.

Pull Request: https://projects.blender.org/blender/blender/pulls/133957
2025-02-25 10:46:27 +01:00
Sybren A. Stüvel
ba149680a2 Fix #134810: animating Grease Pencil layer "hide" option doesn't un-hide
Only remove a grease pencil layer from the evaluated copy when its
visibility is not animated.

Animation evaluation does not recreate the evaluated copy from scratch,
and thus once a layer is removed due to it being invisible, it never got
back.

The animatedness of the `.hide` property is determined once, when the
evaluated copy is created. This is subsequently used during evaluation
to determine whether the layer can be removed or not.

Pull Request: https://projects.blender.org/blender/blender/pulls/135057
2025-02-25 10:43:33 +01:00
Jacques Lucke
589dce871d Merge branch 'blender-v4.4-release' 2025-02-24 17:50:11 +01:00