Commit Graph

24895 Commits

Author SHA1 Message Date
Jacques Lucke
7d2c854261 Geometry Nodes: generalize modifier simulation cache storage names
The main goal here is to rename things in a way that makes sense for
simulation baking, but also for the upcoming bake node.

This also removes some versioning code from 3.6 which initialized the
default bake path. Baked data from back then can't be loaded anymore
anyway, and the way the default path is generated is different now as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/111845
2023-09-03 16:14:11 +02:00
Jacques Lucke
7f00cfeab4 Cleanup: move bake items code to separate namespace 2023-09-03 13:37:50 +02:00
Campbell Barton
e8c812a307 Cleanup: spelling in comments, update dictionary 2023-09-03 21:35:07 +10:00
Jacques Lucke
d1c2b45836 Geometry Nodes: rename bdata to blob
Blob stands for "binary large object" and is a known term. I used to use the term `bdata`
to mean "binary data", mainly because I didn't think of a better name. Blob is a much
better name as it captures the intend of those files much better.

This change breaks existing bakes, because I rename the folder from `bdata` to `blobs`.
I think that is ok, because I also just broke bakes two days ago in a larger refactor
(e92c59bc9b).

Pull Request: https://projects.blender.org/blender/blender/pulls/111822
2023-09-03 12:33:59 +02:00
Campbell Barton
3082037743 Cleanup: spelling in comments 2023-09-03 16:15:01 +10:00
Lukas Tönne
79a6a6977a Fix #111721: Node interface root panel flag missing
The file in question does not have the default (internal) root panel
flag for allowing child panels. This was probably saved before the flag
was added. A simple versioning snippet takes care of this case.

Pull Request: https://projects.blender.org/blender/blender/pulls/111828
2023-09-02 15:58:19 +02:00
Lukas Tönne
7ddf1820ff Fix #111763: Incorrect string copy function for default_attribute_name
`default_attribute_name` is an allocated string, unlike most other strings in `bNodeSocket`.

Pull Request: https://projects.blender.org/blender/blender/pulls/111823
2023-09-02 14:07:54 +02:00
Iliya Katueshenock
4b899588eb Fix: Vert to corner topology map assert for mesh with no faces
Fix of mistake from 226359ec48. `reverse_indices_in_groups` is
used in other one function (`build_vert_to_corner_indices`), so handling of
empty corners array should be moved into itself.

Pull Request: https://projects.blender.org/blender/blender/pulls/111815
2023-09-02 03:55:42 +02:00
Hans Goudey
fa34992def Cleanup: Remove unnecessary includes from C++ data structure headers
The hash tables and vector blenlib headers were pulling many more
headers than they actually need, including the C base math header,
our C string API header, and the StringRef header. All of this
potentially slows down compilation and polutes autocomplete
with unrelated information.

Also remove the `ListBase` constructor for `Vector`. It wasn't used
much, and making it easy to use `ListBase` isn't worth it for the
same reasons mentioned above.

It turns out a lot of files depended on indirect includes of
`BLI_string.h` and `BLI_listbase.h`, so those are fixed here.

Pull Request: https://projects.blender.org/blender/blender/pulls/111801
2023-09-01 21:37:11 +02:00
Hans Goudey
9fd4091f5b Fix: Incorrect assert in node tree interface copy
Panels could have parents if the parent was the root panel.
Anyway, the assert isn't really helpful here, better to keep that
just for higher level editing functions.
2023-09-01 15:30:19 -04:00
Hans Goudey
32ca4caaac Fix: Various crashes and issues dragging node group interface
Mostly the issues were because drag and drop moving to a different
index in the parent didn't take into account the root panel. Also add
a null check for safety similar to b36367e663.
2023-09-01 15:30:19 -04:00
Hans Goudey
3766084bf9 Cleanup: Remove unused BMesh include 2023-09-01 11:59:49 -04:00
Hans Goudey
2a28112bb8 Fix #111698: Sculpt draws unchanged normals on first stroke
When entering sculpt mode, the normals cache is shared with the
evaluated mesh. `SharedCache::ensure()` un-shares the cache in order
to update it, so the pointers in the pbvh must be reset.
2023-09-01 11:29:19 -04:00
Nathan Vegdahl
ceb5981bff Versioning: move bone collection/color versioning to bumped subversion
Also bump the recorded minimum 3.6 subversion for opening files, to
correspond to a fix in the 3.6 branch that prevents bones from seemingly
disappearing when opening files with 4.x bone collections.
2023-09-01 16:11:28 +02:00
Lukas Tönne
cf12d11de6 Fix #111713: Nodes crash when library overriding
Library overrides crashed with on trying to access the interface root
panel. The root panel should not be exposed through RNA, but also
accessing its position property should be allowed.

Several fixes here:
- Fix position property getter when the item has no parent panel
  (i.e. the root panel).
- Avoid infinite loops in the greedy override comparison: exclude the
  loopback parent property.
- Don't return the root panel via the parent property in the first
  place, just return nullptr.

Second attempt at fix, first one in #111755 broke the
bl_node_group_interface test due to incorrect handling of the nullptr
parent case (reverted by 68440742)

Pull Request: https://projects.blender.org/blender/blender/pulls/111782
2023-09-01 12:39:51 +02:00
Jacques Lucke
3ac5b64b20 Cleanup: remove unnecessary functions from public bake api 2023-09-01 11:50:13 +02:00
Jacques Lucke
7df19cfa67 Cleanup: remove unnecessary file
`BKE_simulation_state_serialize.hh` is not necessary anymore,
because the serialization is done at a lower level.
The functionality that lived there in the past is now part of
`BKE_bake_items_serialize.hh`.
2023-09-01 11:47:23 +02:00
Jacques Lucke
67bb0bd1a5 Cleanup: remove unused code 2023-09-01 11:47:23 +02:00
Jacques Lucke
da8ad3c2b6 Geometry Nodes: simplify bake state api
This introduces `BakeState` and `BakeStateRef` to replace
the use of `Map<int, BakeItem pointer>` in various places.
2023-09-01 11:25:36 +02:00
Jacques Lucke
f3a5d28e7e Cleanup: centralize bake file saving/loading 2023-09-01 11:25:36 +02:00
Campbell Barton
2a7b2e477f Fix potential non utf8 strings caused by truncation 2023-09-01 11:36:51 +10:00
Campbell Barton
23e8ffd72d Cleanup: various non-functional C++ changes, format 2023-09-01 11:19:44 +10:00
Hans Goudey
bb181fb8f1 Cleanup: Remove redundant asserts about dirty normals
These asserts basically just reiterated the way things work-- there's no
no way for them to trigger with the current code. And even if they did,
that sort of change wouldn't happen by mistake, so it's not worth
an assert.
2023-08-31 14:22:22 -04:00
Hans Goudey
b81a257059 Fix: Build error after previous commit
Somehow variable rename went missing in these two places.
2023-08-31 14:05:37 -04:00
Hans Goudey
2228006d5b Subdiv: Use index instead of pointer for grid to face map
Switch from face pointers to indices, with the following benefits:
- Halve memory usage required for array (saves 16 MB with 1 million quads).
- Allow better code reuse with index-based utilities.
- Ease future replacement of `SubdivCCGFace` with mesh's face offsets.
- Allow future replacement of array with `Mesh::corner_to_face_map()`
- Potentially lower memory bandwidth required during multires evaluation
- Simplify retrieval of index in `BKE_subdiv_ccg_grid_to_face_index`.

For clarity, `gridfaces` was renamed to `grid_to_face_map`.

Pull Request: https://projects.blender.org/blender/blender/pulls/111078
2023-08-31 19:40:39 +02:00
Jacques Lucke
41bf578182 UI: support context dependent menus (aka assets) in menu search
The node add menu contains assets. The position of an asset in the menu
is determined by the catalog it's in. Submenus are generated automatically.
This works by having a context dependent menu (`NODE_MT_node_add_catalog_assets`).
The current catalog path is passed in as context. If the menu has submenus,
the sub-catalog paths are passed as context into those.

This generally works fine when using the menu. However, menu-search (F3)
does not support context dependent menus yet, so those menu entries are
just skipped. With this patch, the previously skipped context dependent menu
entries are also taken into account.

Note, when opening the search directly after opening Blender, the assets might
still be loading and therefor don't show up in the search.

Pull Request: https://projects.blender.org/blender/blender/pulls/111752
2023-08-31 18:56:57 +02:00
Hans Goudey
ceb3d75c18 Cleanup: Use const for context store variables
Generally the context store is owned by `uiBlock`. Other pointers
to the store (in `bContext` and other operator data) shouldn't change
it, so those variables are now const. One exception is the pointer in
`uiLayout`, but that has a clearly short lifetime, so that's okay.
2023-08-31 12:00:04 -04:00
Hans Goudey
feb14a4d38 Cleanup: Simplify bContextStore API with C++ concepts
Remove the need for `CTX_store_copy` and `CTX_store_free` by using
C++ copy constructors, unique pointers, and `std::optional`. A few types
are made non-trivial to support this.
2023-08-31 12:00:04 -04:00
Hans Goudey
1763a46cbf Cleanup: UI: Store uiBlock context stores in vector instead of list
Also fix an issue where contest stores were copied with the "used"
flag set after 7d7e90ca68.
2023-08-31 12:00:04 -04:00
Bastien Montagne
d6ae841806 LibOVerride: Add resync callback to RNA (python) API of LibOverride data.
Essentially calls `BKE_lib_override_library_resync`, with either to
current ID as resync root for a partial resync, or the actual hierarchy
root for a complete resync of the whole hierarchy.
2023-08-31 16:46:25 +02:00
Jacques Lucke
e92c59bc9b Geometry Nodes: refactor simulation storage and how simulation nodes access it
Goals of the refactor:
* Internal support for baking individual simulation zones (not exposed in the UI yet).
* More well-defined access to simulation data in geometry nodes. Especially, it
  should be more obvious where data is modified. A similar approach should also
  work for the Bake node.

Previously, there were a bunch of simulation specific properties in `GeoNodesModifierData`
and then the simulation input and output nodes would have to figure out what to do with that
data. Now, there is a new `GeoNodesSimulationParams` which controls the behavior of
simulation zones. Contrary to before, different simulation zones can now be handled
independently, even if that is not really used yet. `GeoNodesSimulationParams` has to be
subclassed by a user of the geometry nodes API. The subclass controls what each simulation
input and output node does. This some of the logic that was part of the node before, into
the modifier.

The way we store simulation data is "transposed". Previously, we stored zone data per
frame, but now we store frame data per zone. This allows different zones to be more
independent. Consequently, the way the simulation cache is accessed changed. I kept
things simpler for now, avoiding many of the methods we had before, and directly
accessing the data more often which is often simple enough. This change also makes
it theoretically possible to store baked data for separate zones independently.
A downside of this is, that existing baked data can't be read anymore. We don't really
have compatibility guarantees for this format yet, so it's ok. Users will have to bake again.
The bake folder for the modifier now contains an extra subfolder for every zone.

Drawing the cached/baked frames in the timeline is less straight forward now. Currently,
it just draws the state of one of the zones, which usually is identical to that of all other
zones. This will change in the future though, and then the timeline drawing also needs
some new UI work.

Pull Request: https://projects.blender.org/blender/blender/pulls/111623
2023-08-31 16:28:03 +02:00
Pratik Borhade
daa4c0f91e Fix: set default bone collection active
Bone collection added by default along with the armature is not marked
as active. Visually this looks active but actually it's not (hover over the
properties like remove/move)

Also, when a new collection is added, mark that collection active.

Pull Request: https://projects.blender.org/blender/blender/pulls/111733
2023-08-31 16:26:57 +02:00
Campbell Barton
4a42f2b07c Cleanup: spelling 2023-08-31 10:38:13 +10:00
Hans Goudey
249a03525c Fix: Build error with Audaspace turned off 2023-08-30 18:14:42 -04:00
Hans Goudey
4e94db97e2 Mesh: Add three cached topology maps
Add three cached topology maps to `Mesh`, to avoid computations when
mesh data isn't changed. Choosing the right maps to cache is a bit
arbitrary, but generally we have to start somewhere. The limiting
factor is memory usage (all the new caches combined have a
comparable footprint to a UV map).

For now, the caches added are:
- Vertex to face corner
- Vertex to face
- Face corner to face

These caches are used in quite a few places already;
- Face corner normal calculation
- UV value merging
- Setting sharp edges from face angles
- Data transfer modifier
- Voxel remesh attribute remapping
- Sculpt mode painting
- Sculpt mode normal calculation
- Vertex paint mode
- Split edges geometry node
- Mesh topology geometry nodes

Caching topology maps means they don't have to be rebuilt every time
they're used. Meshes copied but without topology changes can share
the cache, further reducing re-computations. For example, FPS with a
large mesh using the "Corners of Vertex" node went from 1.8 to 2.3.
Entering sculpt mode is slightly faster too.

There is some obvious work for future commits:
- Use caches in attribute domain interpolation
- More multithreading of second phase of map building
- Update/build caches eagerly in some geometry nodes

Pull Request: https://projects.blender.org/blender/blender/pulls/107816
2023-08-30 23:41:59 +02:00
Marcos Perez
1015bed2fd VSE: Sound equalizer modifier
The sound equalizer is using the Audaspace FFT Convolver.
The blender part creates an array of descriptions of power per "band"
and orders the creation of Equalizer (ISound) in the Audaspace.

Modifier can be created on sound strips. It lets you define
amplification or attenuation over frequency range from 30Hz to 20 kHz.
The power is limited to -30 db - 30 db. This is done using curve
mapping widget.

Co-authored-by: menda <alguien@aqui.es>
Co-authored-by: Richard Antalik <richardantalik@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/105613
2023-08-30 22:36:36 +02:00
Hans Goudey
9600b74318 Fix: geometry nodes asset traits not written to file
Mistakenly removed in e071288ab2
2023-08-30 16:35:38 -04:00
Leon Schittek
30114476c7 Fix #111593: Auto-offset when inserting nodes on links inside frames
Apply auto-offset animation in relative steps to avoid issues, when
the parent space of the currently offset node changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/111637
2023-08-30 22:08:23 +02:00
Julian Eisel
8c193180d3 Fix memory leak when freeing custom preview icons
Mistake in eefee47a8a.
2023-08-30 19:25:17 +02:00
Julian Eisel
ce8e9c6a37 Fix error in preview image freeing, own earlier commit
The wrong function was called (function called itself in fact). Mistake
in eefee47a8a.
2023-08-30 19:01:49 +02:00
Julian Eisel
401340fade MSVC: Attempt to fix build error because C++ type in C-linkage block 2023-08-30 18:59:38 +02:00
Julian Eisel
eefee47a8a UI: Refactor deferred preview image storage
Previously we'd just allocate extra space for additional data for the
deferred loading, and then do pointer arithmetic to access that data.
This is cryptic and not type safe.

Instead, use an internal type deriving from `PreviewImage`, and manage
that internally. This ensures type safety, while keeping this as
implementation detail (not visible outside of the preview image API) and
keeping internals easy to understand.

Some code did shallow copies of preview images, making ownership
unclear. That made things a bit tricky, but I've made support for
shallow copies explicit now and noted this in comments.
2023-08-30 17:50:48 +02:00
Hans Goudey
e56b1fc164 Cleanup: Make SubdivCCG a non-trivial struct
Allocate with `MEM_new`, free with `MEM_delete`, and provide
explicit defaults to guarantee values after initialization.
2023-08-30 11:36:36 -04:00
Hans Goudey
fdd6065c21 Cleanup: Add missing struct forward declaration 2023-08-30 11:26:20 -04:00
Jacques Lucke
152f5dc897 Fix #111633: crash with cyclic node tree zones
The problem was that there was a cyclic nesting dependency that was not detected
correctly, which led to problems further down the line. See the PR for details.

Right now, the zones just disappear when there is an error. This has to be improved
at some point, but it outside of the scope of this patch.

A regression test that covers this case is added as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/111689
2023-08-30 14:50:53 +02:00
Lukas Tönne
e071288ab2 Nodes: Panels integration with blend files and UI
Part 3/3 of #109135, #110272

Switch to new node group interfaces and deprecate old DNA and API.
This completes support for panels in node drawing and in node group
interface declarations in particular.

The new node group interface DNA and RNA code has been added in parts
1 and 2 (#110885, #110952) but has not be enabled yet. This commit
completes the integration by
* enabling the new RNA API
* using the new API in UI
* read/write new interfaces from blend files
* add versioning for backward compatibility
* add forward-compatible writing code to reconstruct old interfaces

All places accessing node group interface declarations should now be
using the new API. A runtime cache has been added that allows simple
linear access to socket inputs and outputs even when a panel hierarchy
is used.

Old DNA has been deprecated and should only be accessed for versioning
(inputs/outputs renamed to inputs_legacy/outputs_legacy to catch
errors). Versioning code ensures both backward and forward
compatibility of existing files.

The API for old interfaces is removed. The new API is very similar but
is defined on the `ntree.interface` instead of the `ntree` directly.
Breaking change notifications and detailed instructions for migrating
will be added.

A python test has been added for the node group API functions. This
includes new functionality such as creating panels and moving items
between different levels.

This patch does not yet contain panel representations in the modifier
UI. This has been tested in a separate branch and will be added with a
later PR (#108565).

Pull Request: https://projects.blender.org/blender/blender/pulls/111348
2023-08-30 12:37:21 +02:00
Campbell Barton
3d607be572 Cleanup: spelling in comments 2023-08-30 10:57:12 +10:00
Hans Goudey
7563b96945 Geometry Nodes: Avoid attribute copy in simple case of points to curves
When the final curve point indices are in the same order as the input
points, and there are many curves, avoid copying point domain
attributes, by generalizing the existing check from the mesh
to curve conversion node.

Pull Request: https://projects.blender.org/blender/blender/pulls/111662
2023-08-29 20:12:47 +02:00
Philipp Oeser
a3c045d49d Fix: Customdata merging does not check layer limit on destination
`LayerTypeInfo` can define a `layers_max()` function which determines the
maximum allowed number of layers.

Upon merging, this limit was respected from the source, but not on the
destination, so it was possible to exceed the max (if there were layers
on the destination already).

NOTE: `layers_max()` is currently only defined for legacy CD_MTFACE, but
we might want to enforce this for UVs / CD_PROP_FLOAT2 again.

This came up in #111608.

Pull Request: https://projects.blender.org/blender/blender/pulls/111609
2023-08-29 18:02:36 +02:00
Hans Goudey
69c498084a Cleanup: Remove unnecessary Mesh C API functions 2023-08-29 11:47:29 -04:00