Commit Graph

27292 Commits

Author SHA1 Message Date
Bastien Montagne
f2038b6664 Fix (unreported) bug in prehistoric IPO conversion code.
One of the multiple code paths converting deprecated IPOs to modern
Actions/FCurves was for some reason not ensuring that the ID had a valid
AnimationData...
2024-09-23 18:18:52 +02:00
Hans Goudey
576843aa92 Refactor: Sculpt: Simplify fake neighbors API
Remove the unnecessary "enabled/disabled" toggle in the struct.
That's unnecessary because they're practically always recalculated
anyway. Also remove outdated comments and move documentation
to the header.
2024-09-23 11:27:12 -04:00
dupoxy
e98e6eda5d Fix #127736: Create new scene with AgX Color Management View Transform
Create new scene with AgX Color Management View Transform to be consistent with the default scene.

Pull Request: https://projects.blender.org/blender/blender/pulls/127750
2024-09-23 16:38:43 +02:00
Sybren A. Stüvel
6115132998 Anim: migrate Action assignments to the new API
Instead of assigning Actions by direct pointer manipulation (and the
corresponding juggling of user counts), call `animrig::assign_action()`
and `animrig::unassign_action()`.

These functions not only correctly handle user counts, but also ensure
that slot assignments & user tracking works. The former always happens,
the latter only when building with experimental features enabled.

Because (un)assigning slotted Actions need the animated ID (instead of
just the `AnimData *`), more functions now require an `OwnedAnimData`.

Note that there is still some user count juggling. This is caused by
`BKE_id_new()`, and by extension `BKE_action_add`, returning an ID with
user count = 1, even though that ID is not yet used. A todo task #128017
has been made to change `BKE_action_add()` so that the Action it returns
can be directly fed into `animrig::assign_action()`.

This PR updates the following areas:

- Creating a node group by grouping animated nodes, as this has to move
  the animation data. This PR just handles the assignment of a new
  Action.
- Temporary Action creation for ungrouping node groups.
- Versioning of pre-2.5 animation data.

No functional changes.

Ref: #123424

Pull Request: https://projects.blender.org/blender/blender/pulls/128026
2024-09-23 15:53:32 +02:00
Sybren A. Stüvel
ee2d8ec8db Anim: add slotted Action support to animdata_copy_id_action
Instead of simply reassigning the `adt->action` and `adt->tmpact` pointers,
the code now uses the `animrig::assign_action()` and `assign_tmpaction()`.
This way the slot user maps should be properly updated.

Pull Request: https://projects.blender.org/blender/blender/pulls/128030
2024-09-23 15:48:42 +02:00
Sybren A. Stüvel
0dc71a653d Refactor: BKE_animdata_action_ensure_idroot compat with layered Actions
Make `BKE_animdata_action_ensure_idroot()` do the right thing when a
layered Action is passed in.

Pull Request: https://projects.blender.org/blender/blender/pulls/128030
2024-09-23 15:48:40 +02:00
Julian Eisel
a91ec1ddb0 Cleanup: Use enum type for brush type switch
This way we'll get a compiler warning when a new brush type is added,
and not handled in the switch. Plus a runtime warning when an invalid
value is cast to the enum. Both can help catching errors.
2024-09-23 15:46:14 +02:00
Aras Pranckevicius
ecce5f45ac Cleanup: rename MAXSEQ -> SEQ_MAX_CHANNELS and make it C++ constexpr
When I was learning VSE code, MAXSEQ constant (a preprocessor define!) was
confusing. It makes it sound like it is "max sequences", but it is actually
"max channels". So rename it to SEQ_MAX_CHANNELS and make it C++ constexpr int
instead of preprocessor macro.

Pull Request: https://projects.blender.org/blender/blender/pulls/128024
2024-09-23 15:43:45 +02:00
Charlie Jolly
bf04513dec Geometry Nodes: new Integer Math node
Provide building block support for integer operations.

Manipulation of integer based data should not be limited to using float math nodes.
Using float math comes with accuracy issues for larger integers and requires unnecessary
type conversions.

The node also adds some integer specific operations like GCM and LCD.

Pull Request: https://projects.blender.org/blender/blender/pulls/110735
2024-09-23 15:01:31 +02:00
Iliya Katueshenock
c40dc9aa03 Nodes: use node storage to store type of reroute node
The reroute node used to be a bit special in the sense that its data type was
only stored in the sockets. However, typically, the ground truth data should be
stored in the node storage and then the socket types are derived from that.

For users, there should not be a noticable difference. However, from Python
it's not possible to modify the socket type directly on the socket anymore.
This is forbidden for other built-in nodes already too.

Instead, one can use the new `reroute_node.socket_idname` property to change
the type of a node. This internally also recreates the sockets with the correct
type.

Pull Request: https://projects.blender.org/blender/blender/pulls/121146
2024-09-23 14:47:05 +02:00
Falk David
3c8d4becc8 Cleanup: GPv3: Return reference from GreasePencil::layer() functions
Since we only assert and never return `nullptr`, it's better to just return a reference.
The access into the span already asserts anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/128025
2024-09-23 13:54:02 +02:00
Falk David
332f7517da GPv3: Add function to insert a keyframe into multiple layers
This function adds a key into multiple layers. This is more efficient than
inserting a single key multiple times in a loop, because the drawing
array has to be resized one-by-one.
In this function, the resizing happens at once.

Pull Request: https://projects.blender.org/blender/blender/pulls/127930
2024-09-23 12:12:59 +02:00
Campbell Barton
57eae31ce9 Fix #127952: Crash on load after id_properties_ui type change
Resolve regression in [0] which keeps UI data when ID property types
change.

[0]: 91466f71f1
2024-09-23 16:18:39 +10:00
Campbell Barton
7feccafbb0 Cleanup: various non functional changes
- Use const arguments.
- Quiet unused assignment warnings.
- Use explicit cast to suppress CPPCHECK's truncLongCastReturn warning.
2024-09-23 11:20:14 +10:00
Campbell Barton
2b2a176d8d Cleanup: remove dead code from system path lookup
Commit [0] missed removing this.

[0]: 53dc251fd3
2024-09-22 22:45:11 +10:00
Campbell Barton
b302f37952 Cleanup: remove/comment unused struct members & variables 2024-09-22 18:25:40 +10:00
Sean Kim
e908a9d39e Cleanup: Rename bmesh detail size raycast function
Pull Request: https://projects.blender.org/blender/blender/pulls/127954
2024-09-21 22:20:00 +02:00
Sean Kim
fc8a163892 Refactor: Sculpt: Remove usage of PBVHVertRef in raycast methods
Part of #118145.

This commit removes the `PBVHVertRef` abstraction and changes the last
remaining usage of it. The `raycast_node` API has been turned into a
static function and the corresponding typed APIs exposed for direct
usage.

Pull Request: https://projects.blender.org/blender/blender/pulls/127933
2024-09-21 20:17:18 +02:00
Campbell Barton
0d8149d4ff Cleanup: various non-functional changes
- Use const pointers.
- Avoid shadowing variables.
- Remove redundant check.
2024-09-21 23:01:59 +10:00
Campbell Barton
5c784edf96 Cleanup: remove unused headers from bpath.cc 2024-09-21 19:56:20 +10:00
Campbell Barton
427be373f7 Cleanup: sort cmake file lists 2024-09-21 16:26:43 +10:00
Campbell Barton
f030e6f0b2 Cleanup: spelling in comments 2024-09-21 16:22:52 +10:00
Jacques Lucke
4aa99f5647 Fix: add missing virtual destructor 2024-09-20 19:24:37 +02:00
Julian Eisel
a38c96b92c Sculpt/Paint: Bring back support for multiple brush based tools
Design: https://projects.blender.org/blender/blender/issues/126032

The brush assets project merged all brush based tools into a single, "Brush"
tool. After feedback, we want to bring back some of the previous brush based
tools. For example in grease pencil draw mode, not having an eraser or fill tool
available, and having to go through all the brush assets instead made the
workflow more cumbersome, and features less discoverable (an eraser tool in the
toolbar is quite easy to find, a brush deep down in the asset library may not
be).

With this commit we can add back some tools for specific brush types in sculpt &
paint modes. The follow up commit will start with the eraser and fill tools for
grease pencil draw mode, but more tools in other modes are expected to follow.

For every brush type that has a tool in the toolbar, the last used brush is
remembered. This is the biggest part of the changes here.

Brush asset popups will only show the brushes supported by the active tool for
now. The permanent asset shelf region displays all brushes. Activating a brush
that isn't compatible with the current tool will also activate the general
"Brush" tool, but while the brush tool is active we never switch to another one
(e.g. activating an eraser brush will keep the "Brush" tool active). All this
might change after further feedback.

Pull Request: https://projects.blender.org/blender/blender/pulls/125449
2024-09-20 18:09:31 +02:00
Jacques Lucke
3ccfa65245 Geometry Nodes: support packing bakes into .blend files
Previously, it was only possible to bake to disk with geometry nodes. This patch
adds support for storing the baked data directly in the .blend file.

By default, new bakes are stored in the .blend file now. Whether a new bake
should be packed or stored on disk can be configured in two places: in the
properties of the bake node and in the bake panel of the modifier. These
settings don't affect existing bakes, only the next bake.

To unpack or pack an individual bake, there is a new operator button next to the
bake button. The icon and the label below indicate where the bake is currently
stored. The label now also contains the size of the bake.

To unpack or pack all bakes, the `File > External Data > Pack Resources / Unpack
Resources` operators can be used. The unpack operator also has a new title that
mentions the number if individual files separate from the number of bakes. This
works better than just listing a number of files because a bake can consist of
many files.

Pull Request: https://projects.blender.org/blender/blender/pulls/124230
2024-09-20 16:18:12 +02:00
Bastien Montagne
b2e50d5886 Revert "Cleanup: add missing struct qualifier"
`struct` keyword for members and parameters is not necessary in C++
headers, as long as the struct has been declared previously.

This reverts commit 09e459589f.
2024-09-20 13:42:13 +02:00
Bastien Montagne
3e03576b09 Add more control over ID renaming behavior.
This commit adds low-level logic in BKE to support three behaviors in
case of name conflict when renaming an ID:
1. Always tweak new name of the renamed ID (never modify the other ID
  name).
2. Always set requested name in renamed ID, modifying as needed the
  other ID name.
3. Only modify the other ID name if it shares the same root name with the
  current renamed ID's name.

It also adds quite some changes to IDTemplate, Outliner code, and
RNA-defined UILayout code, and the lower-level UI button API, to allow
for the new behavior defined in the design (i.e. option three from above list).

When renaming from the UI either 'fails' (falls back to adjusted name) or forces
renaming another ID, an INFO report is displayed.

This commit also fixes several issues in existing code, especially
regarding undo handling in rename operations (which could lead to saving
the wrong name in undo step, and/or over-generating undo steps).

API wise, the bahavior when directly assigning a name to the `ID.name`
property remains unchanged (option one from the list above). But a new
API call `ID.rename` has been added, which offers all three behaviors.

Unittests were added to cover the new implemented behaviors (both at
BKE level, and the RNA/Py API).

This commit implements #119139 design.

Pull Request: https://projects.blender.org/blender/blender/pulls/126996
2024-09-20 13:36:50 +02:00
Campbell Barton
09e459589f Cleanup: add missing struct qualifier 2024-09-20 19:52:01 +10:00
Bastien Montagne
60013228e1 Fix #126205: Do not rebuild collection caches on any ID deletion.
Deleting ID would systematically call `BKE_main_collection_sync_remap`,
which would invalidate all collection caches. This should only be needed
when deleting a Scene, Collection or Object ID.

Pull Request: https://projects.blender.org/blender/blender/pulls/127866
2024-09-20 11:14:22 +02:00
Sybren A. Stüvel
615cb46412 Anim: add Action Slot selector to Action Constraint
Add slotted Actions support to Action constraints.

The user interface can be improved once #127751 lands.

Ref: #120406
Pull Request: https://projects.blender.org/blender/blender/pulls/127749
2024-09-20 08:07:15 +02:00
Sean Kim
e37f5616f5 Cleanup: Make depth naming variables consistent
Follow up to 5d40992fe8.

In the PBVH API, some contexts that take a `float *` parameter named
`depth` use it purely as a return value, other places, however, read
from and write to this parameter.

In the former case, this commit either adds or keeps the `r_` prefix, in
the latter, this commit ensures the parameter has no prefix to avoid
misleading future readers.

Pull Request: https://projects.blender.org/blender/blender/pulls/127886
2024-09-20 06:50:54 +02:00
Hans Goudey
9d225f7116 Sculpt: Avoid face corners counting overhead in drawing code
Currently the `sum_group_sizes` call used to count the number
of elements in GPU vertex buffers for each PBVH node stands out
in profiles, taking a few percent of the total time when building
PBVH GPU data. Since the number of corners in a node doesn't
change, it's simpler to just store it in the node. We could
eventually cache it somewhere else too, if there was a benefit
to not storing it in the node itself.
2024-09-19 22:31:55 -04:00
Sean Kim
4dc51e56b2 Cleanup: Silence clang defaulted-function-deleted warning
Because the pbvh::Tree has a unique_ptr, the copy assignment constructor
is implicitly deleted. This change makes that fact explicit by declaring
the entire object's copy assignment constructor as deleted.

Pull Request: https://projects.blender.org/blender/blender/pulls/127884
2024-09-20 03:02:52 +02:00
Sean Kim
5d40992fe8 Cleanup: Various non-functional PBVH raycast changes
A set of general tidying steps prior to making some PBVHVertRef changes

* Add const where possible
* Add r_ prefix for return parameters
* Use pass-by-reference instead of pointer for some return parameters
* Use std::array's .size() operator for some iteration bounds
* Use float3 for some variables

Pull Request: https://projects.blender.org/blender/blender/pulls/127832
2024-09-19 21:27:41 +02:00
Hans Goudey
43e4f93ca3 Cleanup: Use index mask utility function for setting bits 2024-09-19 15:16:58 -04:00
Hans Goudey
c2dd238ba1 Refactor: Sculpt: Use static constructors for PBVH build 2024-09-19 15:14:35 -04:00
Hans Goudey
c8ed2b695a Cleanup: Formatting 2024-09-19 14:54:25 -04:00
Hans Goudey
598c2a1032 Mesh: Add version of set custom normals functions for normalized values
Followup to 1939eb03a7.
The values are expected to already be normalized in these cases.
2024-09-19 14:18:08 -04:00
notrudyyy
1939eb03a7 Refactor: Mesh: Normalize input normals in set custom normals
To reduce code duplication in importers, modifies the C++
set_custom_normals API functions to normalize the input normals.

Reverts !124336, !124267, and !124261 as the normalization now
occurs in the API call.

Resolves #124358.

Pull Request: https://projects.blender.org/blender/blender/pulls/127814
2024-09-19 20:12:40 +02:00
Jacques Lucke
08b29ac143 Refactor: Core: add getter functions for data-block name
This adds a new `BKE_id_name` function. It should be used in places where we
currently do something like `id.name + 2`.

This patch just adds the function and uses them in a small subset of possible
cases. Given that there are >700 cases that need to be replaced, I'd rather to
that in chunks instead of all at once.

Pull Request: https://projects.blender.org/blender/blender/pulls/127410
2024-09-19 18:13:47 +02:00
Sybren A. Stüvel
fe68190923 Anim: fix group name check in Action constraint
Action constraints on an Object will pass a `nullptr` as group name to
another function, which didn't handle this properly.

Pull Request: https://projects.blender.org/blender/blender/pulls/127865
2024-09-19 17:25:52 +02:00
Sybren A. Stüvel
6ebe7a3985 Anim: don't evaluate the Action constraint if it has no Action
Skip the evaluation of the Action constraint when no Action is set.

Before, the constraint would run an entire animation data evaluation
cycle on a fake object, with the given (but NULL) Action. Now it's just
skipped.
2024-09-19 17:25:51 +02:00
casey bianco-davis
421d6c55ae GPv3: Implement the set_origin operator.
Add support the "Set Origin" operator for Grease Pencil objects.
Unlike GPv2, this will update radius properly.

Pull Request: https://projects.blender.org/blender/blender/pulls/127543
2024-09-19 15:27:29 +02:00
Hans Goudey
f82af7fa19 Cleanup: Sculpt: Remove unused PBVHVertRef function
Part of #118145.
2024-09-19 09:09:42 -04:00
Sybren A. Stüvel
823ee1ac92 Anim: add F-Curve getter functions that work with legacy & layered Actions
Add some F-Curve getter functions that work in all these situations:

- Built without experimental features.
- Built with experimental features, and called with legacy Action.
- Built with experimental features, and called with layered Action.

No functional changes, just useful tools for migrating to the new
Actions API.

Ref: #120406

Pull Request: https://projects.blender.org/blender/blender/pulls/127841
2024-09-19 14:46:25 +02:00
Sybren A. Stüvel
38e15412dd Fix #127755: 4.3 regression: Some rigged meshes do not load properly
Revert part of 9530852347 as that did not
take into account that the `max` property may actually be smaller than
the `min` property.

I've also taken the liberty to document this fact in some comments.

The fix for the crash when `min == max` is still in place.
2024-09-19 13:57:30 +02:00
Lukas Tönne
3a1ab067f2 Fix #127342: Support Curve domain when selecting by vertex group
This requires writing selection attributes to a different domain than
the Point domain.

Note that for assigning/removing from vgroups the `adapt_domain`
function is used implicitly by always looking up attributes from the
Point domain: ".selection" may be stored on Curves and will
automatically be adapted to points. For select-by-vgroup `adapt_domain`
cannot be used because the selection has to be "greedy" (one point
selects the whole curve).

Pull Request: https://projects.blender.org/blender/blender/pulls/127799
2024-09-19 10:59:55 +02:00
Campbell Barton
3a555b60f7 Fix crash making objects single user
Add BKE_view_layer_synced_ensure to the FOREACH_OBJECT_FLAG_BEGIN
macro. This macro was only used by the single-user operator.
2024-09-19 17:22:07 +10:00
Campbell Barton
67638a72e3 Logging: suppress BKE_bpath summary reports for non-operator callers
Saving for the first time or using save-as printed a summary, e.g.

`Total files 0 | Changed 0 | Failed 0`

When path operations were added it was only accessed from the UI,
where reporting a summary makes sense. Having the summary reported when
path manipulation is done as part of another action isn't useful.
It's also not clear what the summary relates to.

Now the summary is only shown in operator reports.
2024-09-19 14:49:03 +10:00
Campbell Barton
b63aa7f713 Cleanup: use bool return value for image write functions 2024-09-19 13:08:14 +10:00