Commit Graph

26835 Commits

Author SHA1 Message Date
Jacques Lucke
b76a1db907 Merge branch 'blender-v4.2-release' 2024-07-12 10:18:47 +02:00
Jacques Lucke
4c7456677d Fix: correct potentially wrongly initialized curve attributes
The `resolution` and `nurbs_order` attributes of curves are expected to be `>=
1`. Due to a bug, it was possible that they are initialized to zero: #124534.
This fix adds versioning code to fix the curves that have been written
incorrectly.

Pull Request: https://projects.blender.org/blender/blender/pulls/124539
2024-07-12 10:16:45 +02:00
Jacques Lucke
0c57e95f09 Fix: initialize built-in attributes with proper default value
Previously, it was fairly easy to create built-in attributes which have invalid
values, because attributes were generally zero-initialized. This was especially
problematic for attributes that had certain invariants that Blender relies on
and that should never be zero. For example, the curve resolution should always
be at least 1.

To reproduce the issue, add the `resolution` attribute from the attributes panel
to curves. They had a value of 0 by default. I found this while investigating
#124416.

Pull Request: https://projects.blender.org/blender/blender/pulls/124534
2024-07-12 10:12:03 +02:00
Lukas Stockner
ca39a60863 Fix: Reduce AnimData versioning overhead for node socket changes
Since the code only does anything if both substrings are found, implement
an early-out if either of them isn't found.

This seems like a micro-optimization at first, but since the current node
socket versioning requires looping over all AnimData in the file, this adds
up to e.g. 1.9sec saved when loading the Spring benchmark file.
2024-07-12 03:43:04 +02:00
Harley Acheson
82ca220ad4 Cleanup: Const Arguments for ScrArea name_get Functions
Const arguments for ED_area_name, and space_name_get callbacks.

Pull Request: https://projects.blender.org/blender/blender/pulls/124560
2024-07-12 01:13:44 +02:00
Harley Acheson
a82954cb63 UI: Improved Area Icon Using a SpaceType Callback
Centralized method to obtain ScrArea icons. Areas can add an optional
space_icon_get callback to provide an icon that differs by subtype. If
not defined then ED_area_icon will return RNA UI icon, which is correct
in cases without area subtypes.

Pull Request: https://projects.blender.org/blender/blender/pulls/124556
2024-07-12 00:08:19 +02:00
Harley Acheson
1f3d1048d4 Fix #124070: Improved Area Names Using a SpaceType Callback
Centralized method to obtain ScrArea names. Areas can add an optional
space_name_get callback to provide a name that differs by subtype. If
not defined then ED_area_name will return RNA UI name, which is correct
in cases without area subtypes. This eliminates the current use of
RNA_property_enum_name_gettexted using a temporary context, which
results in the reported (hard to duplicate) error.

Pull Request: https://projects.blender.org/blender/blender/pulls/124488
2024-07-11 20:40:06 +02:00
Jacques Lucke
83373002d2 Cleanup: use more C++ containers in BlendfileLinkAppendContext
This replaces two members of `BlendfileLinkAppendContext`:
* `LinkNodePair libraries` -> `Vector<BlendfileLinkAppendContextLibrary *>`
* `LinkNodePair items` -> `std::list<BlendfileLinkAppendContextItem *>`

This simplifies the code quite a bit.

Making `libraries` a `Vector` works because afaik we never iterate over the
libraries while also adding new ones (which would invalidate iterators). It's
also nice, necause we use random access in some cases.
`items` can't become a vector, because afaik more items may be added while
iterating over it. So it's still a linked list now, but with a better type that reduces
boilerplate a lot.

Pull Request: https://projects.blender.org/blender/blender/pulls/124524
2024-07-11 18:44:38 +02:00
Jacques Lucke
f56a74287c Cleanup: use Map for linked_ids_to_local_liboverrides
Pull Request: https://projects.blender.org/blender/blender/pulls/124520
2024-07-11 18:44:20 +02:00
Jacques Lucke
436f4570c2 Cleanup: move weak reference map to C++
This replaces a `GHash` with `Map<LibWeakRefKey, ID *>` which simplifies the code.

Pull Request: https://projects.blender.org/blender/blender/pulls/124519
2024-07-11 18:43:35 +02:00
Jacques Lucke
a473107489 Cleanup: start using Map instead of GHash in BlendfileLinkAppendContext
This changes the type of `new_id_to_item` from `GHash` to
`Map<ID *, BlendfileLinkAppendContextItem *>` which simplifies code. For this to work
nicely, `BlendfileLinkAppendContext` had to become a non-trivial type. Since it
was allocated with `calloc` before, I gave all members
zero-default-initializers.

This also changes `BKE_blendfile_link_append_context_new` so that it uses
`MEM_new` instead of allocating the `BlendfileLinkAppendContext` as part of the
memory arena, because that's the more common way to do it, and it does not seem
like saving this one allocation here makes a difference considering how this is
used.

Pull Request: https://projects.blender.org/blender/blender/pulls/124516
2024-07-11 13:54:57 +02:00
Bastien Montagne
01484ce5d2 Fix (unreported) memoryleak in tests in some cases.
The call to `GHOST_DisposeSystemPaths` was done in `WM_exit_ex` and
_some_ of the tests' 'teardown'. But some more where missing. Issue was
only reproducible when defining `WITH_CXX_GUARDEDALLOC` cmake option.

There are several layers of issues here, this commit addresses the
first, simplest one: since `BKE_appdir` API will indirectly create the
GHOST SystemPaths data, it is simpler and more logical to move the
deletion of this SystemPaths data in `BKE_appdir_exit()`. This avoids
exposing a fairly low-level implementation detail all over our codebase.

Further more, `WM_init` also does not need to explicitely call
`GHOST_CreateSystemPaths`, since it will be created automatically when
required.
2024-07-11 12:06:14 +02:00
Sergey Sharybin
2a71c345d0 Merge branch 'blender-v4.2-release' 2024-07-11 11:08:12 +02:00
Sergey Sharybin
69e00c865d Fix #124217: Crashes with certain multi-layer/multi-part EXRs
Caused by a060e96103

This change restores the old behavior of pass name detection from
channel name prior to the offending commit.

The fix includes regression test based on the files from related
reports, to help catching possible issues in the future.

Being so close to the release this commit restored behavior prior
to the previous fix. Potentially this makes some files to detect
wrong pass name for some specific files, although it is not really
clear if such files exists in the wild.

Pull Request: https://projects.blender.org/blender/blender/pulls/124458
2024-07-11 11:04:08 +02:00
Sybren A. Stüvel
e5ef601cd9 Anim: give the dependencies_id_types for Actions a value dynamically
Instead of hard-coding `IDType_ID_AC.dependencies_id_types =
FILTER_ID_ALL`, which is overly broad, determine its value dynamically
in `id_type_init()` so that it's purely based on which `IDType`s
identify as 'animatable'.

This should make things like ID remapping a bit more efficient, as the
remapping code knows that an Action will only reference animatable
data-blocks.

Note that the initial value for the filter is still `FILTER_ID_ALL`,
so that in cases where (by accident) the call to `BKE_idtype_init()`
is omitted, semantically the situation is still correct. Not calling
this function is an easy to make oversight when writing unit tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/124357
2024-07-11 10:49:49 +02:00
Sean Kim
7a6a2519c5 Refactor: SubdivCCG: Extract utility method for boundary calculation
Pull Request: https://projects.blender.org/blender/blender/pulls/124476
2024-07-10 19:48:00 +02:00
Hans Goudey
410f7cab78 Cleanup: Mesh: Corner naming in mesh normals code 2024-07-10 12:30:00 -04:00
Sean Kim
d0ebd8e1a7 Cleanup: SubdivCCG: Prevent copying of SubdivCCG
We generally do not want this struct to be copied due to its size. To
assist in finding development errors earlier, disable the copy
constructor entirely, as the destructor puts its resources into an
invalid state.

Pull Request: https://projects.blender.org/blender/blender/pulls/124439
2024-07-10 17:06:55 +02:00
Jacques Lucke
24dc9a21b1 Geometry Nodes: support attaching gizmos to input values
This adds support for attaching gizmos for input values. The goal is to make it
easier for users to set input values intuitively in the 3D viewport.

We went through multiple different possible designs until we settled on the one
implemented here. We picked it for it's flexibility and ease of use when using
geometry node assets. The core principle in the design is that **gizmos are
attached to existing input values instead of being the input value themselves**.
This actually fits the existing concept of gizmos in Blender well, but may be a
bit unintutitive in a node setup at first. The attachment is done using links in
the node editor.

The most basic usage of the node is to link a Value node to the new Linear Gizmo
node. This attaches the gizmo to the input value and allows you to change it
from the 3D view. The attachment is indicated by the gizmo icon in the sockets
which are controlled by a gizmo as well as the back-link (notice the double
link) when the gizmo is active.

The core principle makes it straight forward to control the same node setup from
the 3D view with gizmos, or by manually changing input values, or by driving the
input values procedurally.

If the input value is controlled indirectly by other inputs, it's often possible
to **automatically propagate** the gizmo to the actual input.

Backpropagation does not work for all nodes, although more nodes can be
supported over time.

This patch adds the first three gizmo nodes which cover common use cases:
* **Linear Gizmo**: Creates a gizmo that controls a float or integer value using
  a linear movement of e.g. an arrow in the 3D viewport.
* **Dial Gizmo**: Creates a circular gizmo in the 3D viewport that can be
  rotated to change the attached angle input.
* **Transform Gizmo**: Creates a simple gizmo for location, rotation and scale.

In the future, more built-in gizmos and potentially the ability for custom
gizmos could be added.

All gizmo nodes have a **Transform** geometry output. Using it is optional but
it is recommended when the gizmo is used to control inputs that affect a
geometry. When it is used, Blender will automatically transform the gizmos
together with the geometry that they control. To achieve this, the output should
be merged with the generated geometry using the *Join Geometry* node. The data
contained in *Transform* output is not visible geometry, but just internal
information that helps Blender to give a better user experience when using
gizmos.

The gizmo nodes have a multi-input socket. This allows **controlling multiple
values** with the same gizmo.

Only a small set of **gizmo shapes** is supported initially. It might be
extended in the future but one goal is to give the gizmos used by different node
group assets a familiar look and feel. A similar constraint exists for
**colors**. Currently, one can choose from a fixed set of colors which can be
modified in the theme settings.

The set of **visible gizmos** is determined by a multiple factors because it's
not really feasible to show all possible gizmos at all times. To see any of the
geometry nodes gizmos, the "Active Modifier" option has to be enabled in the
"Viewport Gizmos" popover. Then all gizmos are drawn for which at least one of
the following is true:
* The gizmo controls an input of the active modifier of the active object.
* The gizmo controls a value in a selected node in an open node editor.
* The gizmo controls a pinned value in an open node editor. Pinning works by
  clicking the gizmo icon next to the value.

Pull Request: https://projects.blender.org/blender/blender/pulls/112677
2024-07-10 16:18:47 +02:00
Thomas Dinges
e02c6fd130 Release: Bump 4.2 to rc 2024-07-10 16:13:17 +02:00
Hans Goudey
28c3332e32 Cleanup: Sculpt: Remove now-unused proxy system
Part of #118145.

The proxy system was used to store the accumulated translation from
the deformation of multiple symmetry passes. After a brush/tool update
step, all PBVH nodes with proxies were gathered, the proxies from
each symmetry passes were accumulated, and the deformation was applied
to the evaluated mesh, then the base mesh and shape keys.

In the recently refactored brushes, the translations are immediately
applied to the base mesh and shape keys instead. That avoids the need
for storing a float vector for every affected vertex during the
deformation. Reducing memory usage and affecting the memory that is
already hot in the cache has significant performance benefits too.
Also, brushes are now more conceptually independent-- they don't
rely on a separate pass to actually apply deformations.

Finally removing the proxy system reduces the size of PBVH nodes from
728 to 416 bytes. That's helpful as part of the effort to reduce per-
node overhead in order to make nodes smaller, and helps to reduce the
responsibilities of the PBVH, to focus it on being a BVH tree instead
of "bag for storing arbitrary user-interaction data."
2024-07-09 23:56:07 -04:00
Hans Goudey
248910be1f Fix: Build error on Windows after recent fix
`PreviewImage` is a non-trivial type on MSVC and can't
be allocated with `MEM_cnew`.
2024-07-09 16:16:56 -04:00
Julian Eisel
46c0d3e644 Fix: Broken active highlighting of assets in the asset shelf
Suspecting a mismatch when asset weak references stored using Unix style
paths with ones generated at runtime with Windows sytle paths.

Pull Request: https://projects.blender.org/blender/blender/pulls/124415
2024-07-09 19:07:18 +02:00
Jacques Lucke
57f1d959d4 Cleanup: use StringRefNull instead of std::string for instance reference name 2024-07-09 18:56:09 +02:00
Jacques Lucke
39d509f91f Fix: incorrect preview image shallow copy 2024-07-09 18:53:50 +02:00
Jacques Lucke
a57d1ae35e Cleanup: fix compilation
For some reason, `MTex` is trivial on some platforms and not on others.
2024-07-09 18:20:11 +02:00
Jacques Lucke
dc8e9678e1 Geometry Nodes: allow naming geometry sets
This adds a new `name` member to the `GeometrySet` class. This name can be set
with the new `Set Geometry Name` node. Currently, the name is only used in the
spreadsheet when displaying instances.

The main purpose of this name is to help debugging in instance trees. However, in the
future it may also be used when exporting instance trees or when creating separate
objects from them.

Note, the name is not expected to be unique, it is fully in user control.

Naming geometries is necessary to make the spreadsheet more useful for instances,
because currently the user has no information for which geometry is used by each instance.

We also want to use this name to improve the integration with grease pencil where
sometimes layers become instances with the same name.

Pull Request: https://projects.blender.org/blender/blender/pulls/114910
2024-07-09 17:03:54 +02:00
Jacques Lucke
056ac7f407 Fix: new/free mismatch in a few cases
Also see 06be295946.
These aren't all cases, but a few that I found by addding a static
assert in `MEM_new` so that it fails for trivially constructible types.
2024-07-09 16:22:04 +02:00
Bastien Montagne
17af2bb83c Cleanup: BKE Workspace: Remove unused BKE_blendfile_workspace_config_write. 2024-07-09 15:23:44 +02:00
Falk David
6a69b1789e Fix: GPv3: Crash caused by invalid curve plane normal
In some cases, the plane normal would not be normalized
correctly. This fixes the normalization and ensures the normal
has a length of 1.
2024-07-09 15:11:39 +02:00
Julian Eisel
280a8afa76 Fix "Reset to Default" using wrong value for asset shelf preview size
Use RNA callback to get the actual default value (which asset shelf
types may define using `AssetShelf.bl_default_preview_size`.
2024-07-09 13:37:57 +02:00
Julian Eisel
d4ae97fc3d Fix new/free mismatch for context copying
Would crash when displaying the Current File asset library in the asset
browser.
2024-07-09 10:58:39 +02:00
Christoph Lendenfeld
d859b2d45d Merge branch 'blender-v4.2-release' 2024-07-09 09:31:00 +02:00
Christoph Lendenfeld
0e8f36e63d Fix #106946: NLA sync length stops keys from being inserted
The option on NLA strips "Sync Length" (in the Action Clip dropdown of the N panel)
stops keys from being inserted if it is disabled.
This is due to the evaluation mode of the strip, which is set
to "Hold" internally but ONLY IF "Sync Length" is enabled.
Removing that condition allows to key in tweak mode regardless of that setting.

## History
This has been put in place by 89ee260ef2
Judging by the commit description, this was put in place to allow keyframing
in tweak mode. However, no explanation is given why this is only allowed
with "Sync Length" enabled. Potentially because there was no special
handling of tweak strips for keying evaluation, which has been put in
place later. (09709a7e64)

Pull Request: https://projects.blender.org/blender/blender/pulls/123902
2024-07-09 09:16:50 +02:00
Hans Goudey
e474eef5d1 Cleanup: Formatting 2024-07-08 18:17:19 -04:00
Hans Goudey
28d3f7f638 Cleanup: Sculpt: Remove unused PBVH variables 2024-07-08 17:56:41 -04:00
Hans Goudey
4817ff1d72 Refactor: Sculpt: Remove PBVH CCGKey storage
Part of #118145.
2024-07-08 17:56:31 -04:00
Hans Goudey
68d6bf56e5 Sculpt: Refactor position and mask smoothing for BMesh and multires
Similar to:
- c93767a8b4
- 851505752f

Those commits didn't apply to the smoothing brushes. Now all refactored
brushes use the new code structure. This commit includes utilities for averaging
neighboring mask and position values which will be used by the mask and mesh
filters in future commits.

Pull Request: https://projects.blender.org/blender/blender/pulls/124371
2024-07-08 23:04:06 +02:00
Sean Kim
67dc0245e4 Merge branch 'blender-v4.2-release' 2024-07-08 12:38:10 -07:00
Sean Kim
d527e3a6bd Fix #122947: Curve stroke on duplicate object doesn't update normals
When a mesh is shared between multiple objects, sculpting with a brush
with the Curve stroke type doesnt update normal values for the affected
nodes when using PBVH drawing. This is because when reevaluating the
depsgraph for the objects, the shared PBVH is destroyed and the nodes
are recalculated, losing the existing node flag updates.

This only occurs for the Curve stroke type because all of its stroke
steps are performed within a single call to the overall operator when
the user presses enter, unlike other brush strokes which apply on each
mouse movement.

To fix this, we simply force update the normals before destroying the
PBVH at the end of the stroke step.

Pull Request: https://projects.blender.org/blender/blender/pulls/124268
2024-07-08 21:36:28 +02:00
Hans Goudey
792efafa2c Cleanup: Miscellaneous changes to OBJ/import nodes
- Sort add menu alphabetically
- Use forward declaration for GeometrySet again
- Use `this->` to access class methods
- Use `MEM_cnew`
- Fix typo
- Pass Span by value
- Pass MutableSpan instead of Vector &
- Remove unnecessary whitespace
- Use `BLI_SCOPED_DEFER` for freeing non-RAII objects
- Use `is_empty()` instead of `size() == 0`
- Use `GeometrySet::from_mesh` ability to handle null argument
2024-07-08 15:12:42 -04:00
Devashish Lal
4b884f737c Geometry Nodes: OBJ Import Node
Add a node similar to the STL import node (d1455c4138) that
imports OBJ files, including both meshes and curves. The output consists
of a geometry instance for each mesh/curve in the file.

There are a few improvements to address in the future: Currently the node
has no inputs besides the file path. Options may be exposed in the future.
Materials are also not imported yet, because creating material data-blocks
during evaluation may not be trivial.

This is part of a GSoC project:
https://devtalk.blender.org/t/gsoc-2024-geometry-nodes-file-import-nodes/34482

Pull Request: https://projects.blender.org/blender/blender/pulls/123967
2024-07-08 20:20:38 +02:00
Jacques Lucke
eeb1e14531 GPv3: simplify adding multiple layers with empty drawings
This is often required when generating grease pencil procedurally, e.g. in #124279.
2024-07-08 18:09:36 +02:00
Jacques Lucke
346110a415 GPv3: add method to set local layer transform
Used by e.g. #124279.
2024-07-08 18:09:36 +02:00
Julian Eisel
7b0ea0f1b4 Sculpt/Paint: New asset based brush management workflow
This is the main merge commit of the brush assets project. The previous
commits did some preparing changes, more tweaks are in the following commits.
Also, a lot of the more general work was already merged into the main branch
over the last two years.

With the new design, quite some things can be removed/replaced:
- There's a unified "Brush" tool now, brush based tools and all special
  handling is removed.
- Old tool and brush icons are unsed now, and their initialization code
  removed here. That means they draw as blank now, and the icon files can be
  removed in a follow up.
- Creation of default brushes is unnecessary since brushes are now bundled in
  the Essentials asset library. Icons/previews are handled as standard asset
  previews.
- Grease pencil eraser options are replaced by a general default eraser brush
  that can be set by the user.

More changes are planned still, see task list issue below.

Main Authors: Bastien Montagne, Brecht Van Lommel, Hans Goudey, Julian Eisel
Additionally involved on the design: Dalai Felinto, Julien Kaspar

Blog Post: https://code.blender.org/2024/07/brush-assets-is-out/

Tasks:
https://projects.blender.org/blender/blender/issues/116337

Reviewed incrementally as part of the brush assets project, see:
https://projects.blender.org/blender/blender/pulls/106303
2024-07-08 17:50:25 +02:00
Julian Eisel
721dbfccfd UI: Turn asset shelf popup into a popover, add operator to call from shortcut
Turns the asset shelf into a popover which reduces some of the special
handling. An operator `WM_OT_call_asset_shelf_popover()` (similar to
`WM_OT_call_panel()`) is added to be able to call the popover from shortcuts.
Exactly this was an important aspect for the brush assets project, to allow
quick searching for brushes from the popup.

A custom shortcut can be added to asset shelf popovers using "Assign Shortcut"
in the context menu of buttons invoking it.

The popover is spawned with the mouse hovering the first asset and the search
button active using "semi modal" handling. That means while the popover is
open, any text input is captured by the search button, while the rest of the
popover stays interactive. So for example navigating through asset catalogs is
possible, a single click activates an asset and closes the popover.

Reviewed as part of the asset shelf project, see:
- https://projects.blender.org/blender/blender/issues/116337
- https://projects.blender.org/blender/blender/pulls/106303
2024-07-08 17:50:24 +02:00
Brecht Van Lommel
5190b1d846 Assets: Add API for editing assets stored externally in .asset.blend files
Adds the API for editing assets without opening the blend-file containing them,
using special asset system files (using an .asset.blend extension) introduced
in the previous commit.

Refer to the technical documentation for more information:
https://developer.blender.org/docs/features/asset_system/asset_editing/

Part of the brush assets project (see #116337), only brush assets will use this
for now.

Main Authors: Bastien Montagne, Brecht Van Lommel

Reviewed incrementally as part of the brush assets project, see:
- https://projects.blender.org/blender/blender/issues/116337
- https://projects.blender.org/blender/blender/pulls/106303
2024-07-08 17:50:24 +02:00
Julian Eisel
c5180e0988 Assets: Special .asset.blend files, for storing externally editable assets
Introduces a new kind of blend file that store assets that can savely be edited
from the Blender UI, without having to open the blend-file storing the asset
itself (asset "pushing" workflow).

Only brush assets will use this for now.

Technical Documentation:
https://developer.blender.org/docs/features/asset_system/asset_editing/

User Documentation:
https://docs.blender.org/manual/en/latest/files/asset_libraries/introduction.html#asset-system-files-asset-blend-extention

The API to manage assets by generating these files is added in the following
commit.

Main authors: Bastien Montagne, Brecht Van Lommel, Julian Eisel

Pull Request for the latest design iteration:
https://projects.blender.org/blender/blender/pulls/124246

Part of the brush assets project, see:
- https://projects.blender.org/blender/blender/issues/116337
- https://projects.blender.org/blender/blender/pulls/106303
2024-07-08 17:50:24 +02:00
Lukas Tönne
d51cab60df Fix #124181: Add depsgraph relation to clear cache from modifiers
Point caches can be part of modifiers, in which case changes to the
input geometry should reset the cache. This worked when the input data
is the initial object data, but does not take the modifier stack into
account. A preceding modifier could update based on some dependency
and the point cache would be none the wiser.

The `POINT_CACHE_RESET` depsgraph node now gets additional dependencies
if it's in a modifier with a predecessor.

Caveat: all caches are represented by a single node currently. That
means an indirect change to a modifier will reset all caches of that
object.

Fixes #74523

Pull Request: https://projects.blender.org/blender/blender/pulls/124247
2024-07-08 17:16:19 +02:00
Jacques Lucke
d02ffdf1fe Fix: GPv3: use curve plane normal as projection direction for triangulation
The projection direction was hardcoded previously. This leads to bad results
if the curves happen to be orthogonal to the projection direction, e.g. when
they were on the XY plane.
2024-07-08 16:55:34 +02:00