Commit Graph

112787 Commits

Author SHA1 Message Date
Campbell Barton
792c29e52f Fix uninitialized memory use rendering from the sequencer
SeqRenderData::is_playing & is_scrubbing used uninitialized stack
memory, seq_prefetch_start(..) read both values.

Resolve by setting defaults.
2024-09-06 16:32:09 +10:00
Jeroen Bakker
458faa6486 Preferences: GPU backend selection
This PR allows users to select a GPU backend.

In the system tab of the user preferences the GPU backend can be selected in the `Display Graphics` panel.
It will require a restart of Blender before the changes become effective.

During startup minimum requirements are checked. Blender will switch automatically
to OpenGL when no compatible Vulkan device could be detected. A dialog will be shown
to inform the user.

The setting of the in the `Display Graphics` panel are still overridden when blender is started
using the `--gpu-backend` option. When starting blender with `--debug-gpu` the backend
detection will print to the console.

See PR for detailed information and screenshots of the UI.

Implements #126504
Pull Request: https://projects.blender.org/blender/blender/pulls/126545
2024-09-06 08:28:41 +02:00
Pratik Borhade
df996ad837 Fix #126824: Allow instancing override child collection in outliner
In case of overridden collection, only root collection can be instanced
from outliner. Whereas, "Add collection instance" operation from viewport
works with child collections as well. To make outliner operation consistent,
set `is_liboverride_allowed` to true. This will let instancing of child collection that
are overridden.

Co-authored-by: Bastien Montagne <mont29@noreply.localhost>
Pull Request: https://projects.blender.org/blender/blender/pulls/126881
2024-09-06 08:25:15 +02:00
Campbell Barton
016ab453dd Fix crash in sculpt poll function without an active object 2024-09-06 16:03:03 +10:00
Campbell Barton
43f7b50df3 Fix #127127: bpy.types sometimes reference their parent's "bl_rna"
Accessing `bl_rna` for type defined in `scripts/modules/bpy_types.py`
could return their parent-classes RNA when accessed via their parent
types __subclasses__() method.
2024-09-06 14:57:26 +10:00
Aaron Carlisle
55ac8c701c Docs: Add descriptions to some property sub types
- Clarify the difference between `COLOR` and `COLOR_GAMMA` Descriptions match `wm.py`

Fixes https://projects.blender.org/blender/blender-manual/issues/104767
2024-09-05 22:36:52 -04:00
Campbell Barton
9d917b73b9 Cleanup: remove duplicate depsgraph tagging
Operations on collections could tag the same collection multiple times.
Track the changed state instead. Also rename (ok/updated to "changed"),
for clarity & consistency.

Remove duplicate depsgraph tagging from ED_rigidbody_object_remove too.
2024-09-06 12:17:10 +10:00
Campbell Barton
2954323c2d Fix missing depsgraph tags after removing an object from a collection
Follow up to fix for #127213, resolving the bug in other contexts.
2024-09-06 12:05:33 +10:00
Campbell Barton
f5b16e474f Fix #127213: crash on undo after unlinking an object in the outliner 2024-09-06 11:45:13 +10:00
Campbell Barton
73ac0275c6 Fix missing check for "-c" to terminate argument parsing
Arguments to CLI commands could accidentally enable guarded allocator
when using "-c" instead of "--command".
2024-09-06 10:38:02 +10:00
Sean Kim
fbf95a05d5 Cleanup: Various changes for cavity automasking
* Use `float3` where possible
* Adjust names, introduce a utility `struct` to represent the accumulation
  happening in the method
* Remove dead code
* Use `std::queue` instead of custom hand-written queue working on a
  `Vector`
* Apply `const` where possible
* Use C++ math library

Pull Request: https://projects.blender.org/blender/blender/pulls/127212
2024-09-06 01:07:03 +02:00
Hans Goudey
07d7404390 Fix: Correct wireframe drawing after recent PBVH storage refactor
Somehow this untested implementation made it in, I thought I had
tested this. The mistake I made was imagining the VBOs were "indexed"
using the node vertex indices, but we use a flat duplicate-per-triangle
vertex VBO format.
2024-09-05 15:42:15 -04:00
Hans Goudey
e05d55f4c9 Cleanup: Remove unnecessary PBVH free function
Just call `reset()` directly instead.
2024-09-05 14:51:19 -04:00
Hans Goudey
c6e426fc8f Refactor: Sculpt: Pass object to sculpt session free function 2024-09-05 14:46:35 -04:00
Hans Goudey
b8d3de8598 Cleanup: Use accessor function for retrieving PBVH
Missed in previous commit
2024-09-05 14:46:35 -04:00
Jesse Yurkovich
832d243249 Fix #116615: Store Blender bone lengths on USD Skeletons
USD Skeletons (armatures) are joint-based rather than bone-based in
construction. This means that there's no native bone concept nor is
there any bone lengths. Currently, Blender's USD import uses an
estimation, roughly corresponding to the average distance between
joints in the entire Skeleton, to set the bone length in situations
where it's not obvious that 2 joints are directly connected. This is
imperfect but shouldn't affect actual functioning of the rig.

For armatures coming from external software this is probably the best we
can do. However, for armatures originating from Blender, we can use a
custom primvar to store the bone lengths directly. This allows Blender
armatures to be exported and re-imported in much better fidelity.

This is superior to prior techniques, like those employed by FBX, which
alter the actual Skeleton, inserting extra joints where unnecessary. Not
only is this detrimental when using these files in external software,
but it's still imperfect when importing back into Blender too.

Pull Request: https://projects.blender.org/blender/blender/pulls/126954
2024-09-05 20:37:22 +02:00
Hans Goudey
d33e708343 Refactor: Sculpt: Use function to access PBVH
Part of #118145.
In the future we want to move the ownership of the BVH tree to the
original mesh rather than `SculptSession`, in order to persist it
across some more general non-topology changing operations like
node tools. The first step of that change is replacing all places
that used `SculptSession::pbvh` for access with a function.
2024-09-05 14:16:40 -04:00
Hans Goudey
4c8e1fbeca Cleanup: Reduce indentation in sculpt object update function 2024-09-05 14:07:16 -04:00
Hans Goudey
39e653d479 Cleanup: Sculpt: Add geometry index accessor functions to node structs
Add `.faces()`, `.verts()`,`.all_verts()`, and `.grids()` functions to nodes.
Don't change BMesh data access yet. More complex const correctness
makes that situation more difficult.

Pull Request: https://projects.blender.org/blender/blender/pulls/127201
2024-09-05 20:07:03 +02:00
Habib Gahbiche
ed13dad08b Compositor: UI: remove preview for viewer and composite nodes
In geometry nodes, the viewer gets activated by clicking on the preview icon. For the compositor, preview is enabled either using the image viewer or the backdrop.

Another difference is that all nodes can be previewed in the compositor. Which makes the preview icon on the composite and viewer node redundant.

Pull Request: https://projects.blender.org/blender/blender/pulls/127044
2024-09-05 19:52:07 +02:00
Habib Gahbiche
5a99d5d3fc Compositor: UI: Use hide icon for preview
Replace material icon with hide (eye) icon and enable toggling on/off. This makes it consistent with the UI of geometry nodes viewer node

Pull Request: https://projects.blender.org/blender/blender/pulls/127042
2024-09-05 19:51:31 +02:00
Jacques Lucke
809fed764a Geometry Nodes: expose node warnings on modifier in Python API
This exposes warnings that are propagated to the modifier in the Python API.
This allows people to show these warnings in custom UIs for their node groups.

Warnings are accessed like this:
```python
for warning in modifier.node_warnings:
    print(warning.message)
    print(warning.type)
```

Note that this only works on the geometry nodes modifier. These warnings may
be extended with more information in the future. E.g. it could be useful to know
which node created the warning.

Pull Request: https://projects.blender.org/blender/blender/pulls/127193
2024-09-05 19:45:40 +02:00
Aras Pranckevicius
a4d9bcf106 VSE: Optimize the Color Balance modifier
Speedup the Color Balance VSE strip modifier, with two things:

- Generally, use a much lower overhead parallel_for, also with
  lower grain size (32 image rows, instead of 64 that were used
  before). This is what makes the "float" variant faster.
- For "byte" variant, create a precalculated lookup table instead
  of doing all the math per-pixel. This was *almost* done in
  existing code, except it was put into the code path that was
  never-ever used. However, since this is all done on premultiplied
  values, I'm using lookup table size of 1024 instead of 256, so
  that semitransparent pixels get some more precision for
  "in-between values". This LUT is what results in the main speedup
  of "byte" variant.

Calculating Color Balance at 4K resolution, times in milliseconds:
- PC (Ryzen 5950X), PNG (byte): 22.2 -> 2.9 ms, EXR (float): 20.1 -> 15.2 ms
- Mac (M1 Max), PNG (byte): 28.9 -> 7.5 ms, EXR (float): 21.8 -> 8.5 ms

More timing details in PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/127121
2024-09-05 19:21:35 +02:00
Sean Kim
29ccc7cddb Cleanup: Specialize automasking boundary factor initialization
Part of #118145.

Pull Request: https://projects.blender.org/blender/blender/pulls/127167
2024-09-05 19:10:18 +02:00
Mike93
cc5ed48cd3 Modifiers: Add custom attribute weight support to bevel modifier
As of 2a56403cb0, bevel weight data is stored as a generic
attribute. The bevel modifier is currently hard-coded to use the
`bevel_weight_edge` attribute as the data source for the weights.
This commit adds a string textbox where the user can specify alternate
attributes for the bevel's edge weights.

The string name field is added as a search button which provides a list
of all attributes in the original mesh. This is meant to work similarly
to geometry nodes, so mismatched attribute data types and domains are
automatically converted/interpolated as necessary. Attributes created
by previous modifiers can also be used, but they won't appear in the
search menu.

Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/117366
2024-09-05 17:15:34 +02:00
Sybren A. Stüvel
0ad22e9128 Anim: Add slot deletion to Action editor
Slots can now be deleted from an Action via the channel list in the Action
editor. As with all deletions there, it deletes the associated F-Curves
from the Action without any warnings.

Pull Request: https://projects.blender.org/blender/blender/pulls/127112
2024-09-05 16:34:02 +02:00
Sybren A. Stüvel
d79f5edb79 Refactor: Anim, change if (ale->type == ...) to 'switch (ale->type)`
Refactor `if (ale->type == ANIMTYPE_GROUP)` into `switch (ale->type)`
with a single `case` filled out. This will make an upcoming commit
cleaner, as it simply adds another case.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/127112
2024-09-05 16:34:01 +02:00
Sybren A. Stüvel
f7d4a517e3 Anim: add Action::slot_remove() method to remove an action slot
Add a method to remove a slot from an Action. This is also exposed as
`Action.slots.remove(slot)` to RNA/Python.

Removing a slot deletes all its associated animation data in the Action.
It also un-assigns the slot from any ID that was animated by it. The
Action reference is left untouched.

Pull Request: https://projects.blender.org/blender/blender/pulls/127112
2024-09-05 16:34:01 +02:00
Philipp Oeser
4221f827cf Fix #127077: Edit voxel size op unpredictable with large/small meshes
If voxel sizes were big, code could run into clamping at 1.0f, making it
look like nothing was happening, also even though the "step size" was
taking into account the initial voxels size (only in relative mode,
absolute mode was, well... absolute, no matter what object this was
happening on, also see 5946ea938a).

So previously, a reasonable voxels size could not achieved using this
operator for e.g. a terrain-size mesh.

Now code allows for bigger/smaller meshes to behave predictably.
This is done by storing a reasonable min and max voxel size (this is
taken from the bounding plane which is also displayed to the user),
making the max the length of the longer side of the bounding plane and
the min a fraction of it (based on `VOXEL_SIZE_EDIT_MAX_GRIDS_LINES` --
smaller voxels would not display anyways...)

Based on the above, we can have a reasonable range to base the change on
which is done moving the mouse.
Because this is more predictable than before, we can even remove the
`relative` mode (dont think it makes too much sense now anymore).

Pull Request: https://projects.blender.org/blender/blender/pulls/127109
2024-09-05 16:31:05 +02:00
Hans Goudey
5e63435e74 Sculpt: Store faces instead of triangles in BVH
Currently each sculpt BVH node stores the indices of its triangles.
It also stores triangles of vertex indices local to the node, and also
potentially the indices of the face corners in the node.

The problem with this is that the leaf nodes store plenty of redundant
information. The triangles in each face aren't split up between multiple
nodes, so storing triangle instead of face indices is unnecesssary. For
the local vertex triangles, there is also duplicate information-- twice
the number of indices as necessary for quad meshes. We also often need
a node's faces, which is currently done with a triangle to face map
using 4 bytes per triangle.

This "double storage" results in extra processing too. For example,
during BVH builds we need to combine twice the number of "Bounds"
objects for a quad mesh. And we have to recalculate a node's face
indices every time we want them.

This commit replaces the PBVH triangle indices with face indices, and
replaces the local vertex triangles array by using a `VectorSet` to store
each node's vertex indices. This results in significant performance and
memory usage improvements.

|                   | Before   | After    | Improvement |
| ----------------- | -------- | -------- | ----------- |
| BVH build time    | 1.29 s   | 0.552 s  | 2.3x        |
| Brush stroke time | 3.57 s   | 2.52 s   | 1.4x        |
| Memory usage      | 4.14 GiB | 3.66 GiB | 1.3x        |

All testing is done with a 16 million vertex grid and a Ryzen 7950x.

My guess is that the brush stroke time is improved by the added sorting
of node vertex indices, and by the overall increase in memory bandwidth
availability for mesh data. Personally I'm pleasantly surprised by the
whole improvement, since I usually try to avoid hash table data
structures for this sort of use case. But a lookup into this set ends up
just being a boolean and with an array lookup, so it's quite cheap.

Pull Request: https://projects.blender.org/blender/blender/pulls/127162
2024-09-05 16:21:43 +02:00
Jeroen Bakker
b2fdae6f0e Vulkan: GPU depth picking
GPU depth picking was not working on all GPUs. When a GPU requires a
DEPTH32F to store depths the conversion to unsigned normalized could
wrap around. Making depths of 1.0 become 0. In stead of MAX_DEPTH.

This solves depth picking issues on Intel and AMD GPUs.
2024-09-05 15:14:40 +02:00
Bastien Montagne
a5cb4a6ae3 Fix (unreported) broken do_version on particles settings for very old files.
'Normal' Versioning code is not allowed to create new IDs nowadays,
needs exceptions for legacy one that does.
2024-09-05 14:29:40 +02:00
Jacques Lucke
75d5e69d44 Fix #127039: missing update when disconnecting links 2024-09-05 13:10:50 +02:00
Jeroen Bakker
98feb87f40 Vulkan: Disk cache for static pipelines
This PR introduces disk cache for static pipelines. The pipelines are
stored in `<cache folder>/vk-pipeline-caches/static-shaders.bin`.

Due to limitations in some drivers we add a custom header to the
cache file to identify if the cache file was created by the same driver
for the same GPU for the same Blender.

Reading/writing the cache is skipped when running blender with
`--debug-gpu` as that would generate different shader modules. For
now that isn't a problem, but the final implementation would check
before compiling a shader if a certain key is in the pipeline cache if
that is the case the compilation step is skipped and the cached shader
module is used.

Reference: #126229
Pull Request: https://projects.blender.org/blender/blender/pulls/127110
2024-09-05 13:02:40 +02:00
Jeroen Bakker
52a84b6c01 Vulkan: Don't overwrite pipeline base when already set
Base pipelines are used to optimize the vulkan pipeline creation.
Instead of building each pipeline from scratch a base pipeline can
be used to share resources and faster code-paths.

We used to overwrite the base pipeline with the last created pipeline.
This PR doesn't overwrite the base pipeline after it was initially set
giving less confusion when working with base pipelines.

Pull Request: https://projects.blender.org/blender/blender/pulls/127181
2024-09-05 13:00:39 +02:00
Clément FOUCAULT
093192a9d0 Cleanup: DRW: Remove unused variable warning 2024-09-05 12:23:43 +02:00
Jacques Lucke
871b25b219 Geometry: generalize attribute filters beyond just for anonymous attributes
This introduces the concept of an #AttributeFilter. It's used to tell a geometry
algorithm which attributes it should process/propagate and which can be ignored.

We already had something similar before named
`AnonymousAttributePropagationInfo`. However, as the name implies, this was
specific to anonymous attributes. This had some downsides:
* A lot of code had to be aware of the concept of anonymous attributes even if
  it did nothing special with anonymous attributes.
* For non-anonymous attributes we often had a separate `Set<std::string> skip`
  parameter. It's not nice to have to pass two kinds of filters around and to
  have to construct a `Set<std::string>` in many cases.

`AttributeFilter` solves both of these downsides.

Technically, `AttributeFilter` could also just be a `FunctionRef<bool(StringRef
attribute_name)>`, but that also has some issues:
* The `bool` return value is often ambiguous, i.e. it's not clear if it means
  that the attribute should be processed or not. Using an enum works better.
* Passing function refs around and combining them works, but can very easily
  lead to dangling references.
* The default value of a `FunctionRef` is "empty", i.e. it can't be called. It's
  generally more nice to not have a special case for the default value. Now the
  default `AttributeFilter` propagates all attributes without any extra handling
  on the call-site.

Pull Request: https://projects.blender.org/blender/blender/pulls/127155
2024-09-05 11:33:35 +02:00
Philipp Oeser
f883cb77ba Fix #127117: NLA Channels missing update on animated object visibility
e420caab19 already fixed this for "manually" changing visibility, but
if this change comes through animation, these notifiers dont fire (rna
callbacks dont run).

So to resolve, also redraw on `ND_FRAME`, this is something every region
in animation editors listens to anyways, so probably right for
consistency (and to solve this bug), even though it might eat away some
ticks.

Pull Request: https://projects.blender.org/blender/blender/pulls/127145
2024-09-05 11:29:10 +02:00
Philipp Oeser
69557e316c Fix #127174: GPv3 misses ID selector in Properties Editor Data tab
`ID_code_to_RNA_type` had it, but `RNA_type_to_ID_code` missed the
`RNA_GreasePencilv3` case.

Without it, `ui_template_id` cant work properly.

Pull Request: https://projects.blender.org/blender/blender/pulls/127176
2024-09-05 10:51:06 +02:00
Christoph Lendenfeld
a661a7bf89 Refactor: Move Pose code out of the kernel
Move the functions
* `BKE_pose_apply_action_selected_bones`
* `BKE_pose_apply_action_all_bones`
* and `BKE_pose_apply_action_blend`

out of the blender kernel and into animrig.

This will allow solving #126969 without having to include
animrig code in the blender kernel.

Pull Request: https://projects.blender.org/blender/blender/pulls/126978
2024-09-05 10:41:34 +02:00
Bastien Montagne
938e50a3ed API Doc: Add note to 'liboverride' bpy props flag about ancestors.
For a property to be overridable, all of its ancestors properties also
need to be defined as such.

Missing doc reported in #127125.
2024-09-05 10:30:01 +02:00
Campbell Barton
1235404cfe Fix #127165: crash accessing cls.bl_rna after unregistering 2024-09-05 17:56:56 +10:00
Campbell Barton
acde253b9d Fix invalid MeshRuntime::deformed_only for evaluated edit-meshes
Between 2.93 & 3.2 a regression was introduced where evaluated
meshes from the modifier stack would always have their deformed_only
value set to false.

Resolve by enabling for meshes returned by
BKE_mesh_wrapper_from_editmesh and ensure the value is kept when the
modifier duplicates the cage mesh.

Resolves #123138.
2024-09-05 15:56:39 +10:00
Hans Goudey
07a336c874 Fix #127166: Invalid BMesh normal values after sculpt undo
Building the BVH tree used to recalculate all normals. It makes more
sense to just recalculate them where we actually know it's necessary.
2024-09-04 21:35:37 -04:00
Hans Goudey
c6fe321718 Fix: Sculpt: Data race saving BMesh node original data
Replace modification of vertex indices with a VectorSet for local
index calculation, allowing proper parallelization of the saving.
2024-09-04 21:35:37 -04:00
Hans Goudey
9c86d5e861 Cleanup: Sculpt: Use C++ Array for original BMesh node data 2024-09-04 21:35:37 -04:00
Campbell Barton
3a1e637e26 Cleanup: spelling in comments 2024-09-05 11:31:47 +10:00
Jesse Yurkovich
da2bacae3d Fix: MEM_new/MEM_freeN mismatch inside ui_block_free_active_operator 2024-09-05 03:30:11 +02:00
Pratik Borhade
28fe4f6996 GPv3: Switch to properties tab when stroke icon clicked in outliner
When clicked on icon of GPv3 datablock, switch to object data properties
tab.

Pull Request: https://projects.blender.org/blender/blender/pulls/127139
2024-09-04 23:45:43 +02:00
Harley Acheson
382244c258 UI: Docking Drag Mouse Cursor
This shows the docking feedback very similar to how tooltips are shown
elsewhere. It describes the operation and also includes the icon and
name of the moving/changing area.

Pull Request: https://projects.blender.org/blender/blender/pulls/126898
2024-09-04 22:43:57 +02:00