Commit Graph

120055 Commits

Author SHA1 Message Date
Hans Goudey
56ed17b60f Fix #129159: Memory leak when node asset sockets have non-unique names
We weren't handling the failure case of `IDP_AddToGroup` when the
property already exists. Arguably this is a bit bad because we're not
recording the type of the second socket with the same name, but we
don't really have the tools to solve that with IDProperties.
2024-11-22 18:39:45 -05:00
Sean Kim
0f76521994 Cleanup: Update comment for calc_vert_neighbors
Pull Request: https://projects.blender.org/blender/blender/pulls/130768
2024-11-23 00:38:56 +01:00
Hans Goudey
ea875f6f32 Geometry Nodes: Port triangulate node from BMesh to Mesh
Add a Mesh implementation of triangulation, which is currently just
implemented for BMesh. The main benefit of this is performance and
decreased memory usage. The benefit is especially large because the
node currently converts to BMesh, triangulates, and then converts back.
But the BMesh implementation is entirely single threaded, so it will
always be much slower.

The new implementation uses the principle of "never just process a
single element at a time" but it also tries to avoid processing _too_
many elements at once, to decrease the size of temporary buffers.
Practically that means the work is organized into chunks of selected
faces, but within each chunk, each task is done in a separate loop.
Arguably I went a bit far with some optimizations, and some of the
complexity isn't necessary, but I hope everything is clear anyway.

Unlike some other Mesh ports like the extrude node or the split edges
code, this generates a new mesh. I still go back and forth on that
aspect, but reusing the same mesh would have required reallocating
face attributes from scratch anyway. Implicit sharing is used to
avoid copying vertex attributes though.

The result mesh is reorganized a bit. Unselected face data comes first,
then selected triangles, then triangulated NGons, then triangulated
quads. This makes attribute interpolation and internal calculations
more efficient.

The "Minimum Vertices" socket is replaced with versioning. In the new
implementation it would have an impact on code complexity, and for a
builtin "atomic" node it makes more sense as part of the selection.

The performance difference depends on the number of CPU threads, the
number of attributes, and the selection size. As all of those numbers
go up, the benefit will grow. The "modes" also affect the performance,
obviously.

With a Ryzen 7950x, I tested performance in a few situations (in ms):
|                            | Selection | Before | After | Change |
| -------------------------- | --------- | ------ | ----- | ------ |
| 1.4 m quads (fixed)        | 50%       | 1533   | 15.9  | 96x    |
| 10 m quads (shortest)      | 100%      | 9700   | 165.0 | 59x    |
| 1 m 10-side Ngons (beauty) | 90%       | 3785   | 115.9 | 33x    |
| 1 m quads many attributes  | 100%      | 54600  | 332.3 | 164x   |

In follow-up commits, I'll move other areas to use mesh triangulation
instead of BMesh. This is the last geometry node using BMesh besides
the Ico Sphere primitive.

Pull Request: https://projects.blender.org/blender/blender/pulls/112264
2024-11-23 00:25:52 +01:00
Sean Kim
3941a4947b Fix #130606: Crash when switching workspace
When we enter Sculpt mode, a depsgraph evaluation is triggered. In 4.2,
a change was added in ada367a0e9 which
causes `sculpt_update_object` to exit early if it is unable to get the
evaluated mesh.

This function is responsible for ultimately ensuring the PBVH is built.

Later on when entering Sculpt Mode, we push an undo change to the stack
to signal changing and avoid a memfile undo push; this `undo::push_begin`
function was changed in 4.3 to require the PBVH, as it was expected to
only be used for cases where we needed the total number of mesh elements
(i.e. when making a stroke on the mesh)

Currently, this causes a crash because in this instance, the PBVH is now
no longer created. To fix this, this commit adds a new function to the
sculpt undo namespace to indicate that thsi special undo step is being
performed, which is similar to a geometry undo step and does not require
the PBVH.

Pull Request: https://projects.blender.org/blender/blender/pulls/130649
2024-11-23 00:09:35 +01:00
Clément Foucault
edbdfabc45 Fix: Overlay-Next: Change lattice overlay enable state 2024-11-22 23:45:04 +01:00
Sean Kim
b5d7d5ef45 Fix #130692: Relax topology operations do not work on boundary vertices
Affects both the Slide Relax brush when using the `shift` smooth mode
and the Relax mode of the mesh.

This commit simply changes the `calc_vert_neighbors_interior` method for
`calc_vert_neighbors` in the shared functions to avoid filtering out
boundary vertices by default.

Pull Request: https://projects.blender.org/blender/blender/pulls/130697
2024-11-22 23:39:25 +01:00
Sean Kim
c7f58514c7 Fix #130636: Sculpt performance regression under certain circumstances
As part of the overall sculpt brush refactor project, the `corner_tris`
attribute was removed from the PBVH and accessed directly from the mesh
runtime data.

A new set of methods was introduced to the `TrianglesCache` `struct` to
prevent tagging the cache as dirty and requiring a subsequent evaluation
because the performance hit while in sculpt mode was significant. This
was enabled upon entering sculpt mode and disabled upon exiting it.

Unfortunately, there are some operations inside Sculpt mode which can
cause either the Mesh object itself or the MeshRuntime object to be
recreated, effectively unfreezing the cache. A few examples that cause
this are:

* Undoing the first brush operation on file load
* Performing a remesh operation

To fix this issue, this commit checks and re-freezes the cache if it
is detected to be in a bad state prior to tagging the cache as dirty.
Further changes to fix this on a more fundamental level are well
outside of the scope of a fix needed for 4.3.1.

Pull Request: https://projects.blender.org/blender/blender/pulls/130709
2024-11-22 23:22:43 +01:00
Sean Kim
5b4144cdf3 Fix #130704: Multiplane Scrape brush too strong with invert mode
Introduced in d106592f7b

`add_v3_v3(a, b)` was mistakenly turned into `a = b` instead of `a += b`

Pull Request: https://projects.blender.org/blender/blender/pulls/130711
2024-11-22 23:20:01 +01:00
Miguel Pozo
49bb73b7d8 Fix: Overlay-Next: Visibility settings
Support extras and motion tracking visibility settings.

Pull Request: https://projects.blender.org/blender/blender/pulls/130761
2024-11-22 22:38:15 +01:00
Harley Acheson
82667d5626 UI: Misc Changes to Area Splitting Operator
Changes to area splitting when dragging from a corner action zone.
Increases the distance you must drag into the area before anything
starts. Increases minimum size that you can create to about 2X the
header height. Slight snap to 50% when no modifier keys are held.

Pull Request: https://projects.blender.org/blender/blender/pulls/130706
2024-11-22 19:23:53 +01:00
Hans Goudey
76e9dc0f04 Spreadsheet: Improve mesh selection filter domain interpolation
Previously the spreadsheet always used vertex selections to figure
out which geometry elements to display. This caused unexpected
filtering because of generic domain propagation rules.

Instead, implement filtering separately for each domain. This
requires a bit more boilerplate but the code is much clearer
and should be a bit more efficient too.
2024-11-22 13:15:52 -05:00
Hans Goudey
7b1ae015ff Cleanup: Remove unnecessary parantheses 2024-11-22 13:12:21 -05:00
Harley Acheson
62541bffc2 UI: Area Move Snap to Min and Max
While resizing areas by dragging on their edges, add a slight snapping
to the minimum and maximums without any modifier keys pressed.

Pull Request: https://projects.blender.org/blender/blender/pulls/130702
2024-11-22 18:34:51 +01:00
Clément Foucault
b8a2519bcf Cleanup: Overlay: Centralize call to DRW_state* functions
This is to remove global DST access from Overlays.
2024-11-22 18:06:59 +01:00
Hans Goudey
fa7dea4154 Cleanup: Formatting 2024-11-22 09:40:51 -05:00
Omar Emara
fa9bde230b Compositor: Implement Anisotropic Kuwahara for new CPU compositor
Reference #125968.
2024-11-22 16:35:15 +02:00
Pratik Borhade
42445ed5c9 Fix #130725: Grease Pencil: Avoid sculpting strokes with locked material
Return editable_elements instead of entire range of points/stroke from
`point/stroke_selection_mask()` function

Pull Request: https://projects.blender.org/blender/blender/pulls/130727
2024-11-22 15:12:45 +01:00
Clément Foucault
0915015437 Cleanup: Overlay-Next: Camera: Code re-organization to follow code stype 2024-11-22 15:00:17 +01:00
Julian Eisel
4651cad73d Cleanup: Move asset library types to own directory
I found the naming of these files awkward, where we prefixed them with
`asset_library_` to keep them grouped together, and then a library type
name. This resulted in rather un-natural names.  Also, there are files
like `asset_library_service.cc`, which is in fact not another asset
library type, but seems like one with the old convention.

Moving these files to an own directory keeps the grouping while allowing
more natural sounding names.
2024-11-22 14:58:48 +01:00
Clément Foucault
fcc04e131f Cleanup: Overlay-Next: Camera: Simplify functions, remove legacy API calls 2024-11-22 14:56:29 +01:00
Jeroen Bakker
48b10a266f Vulkan: Limit NVIDIA drivers to 550 and above.
Older drivers seems to not work correctly and stall on the first frame.
We encourage users to use the latest driver and this driver support
devices from GTX 750 to RTX 4000 series.

NOTE: Later we should review this issue as supporting more drivers is
always better. The current issue could also be related to sending empty
command buffers to the GPU. Ideally we should support 535 as well.
Some Linux distributions don't package 550.

Ref: #129157
Pull Request: https://projects.blender.org/blender/blender/pulls/130737
2024-11-22 14:54:30 +01:00
Jeroen Bakker
b334502168 Vulkan: Make dynamic rendering optional
!129062 introduces a workaround for dynamic rendering. However that
change didn't marked dynamic rendering as an optional feature. GPU that
didn't had dynamic rendering would still not be able to start Blender.

This PR marks dynamic rendering optional so the device will be
considered when searching for compatible GPUs.

Ref: #129157

Pull Request: https://projects.blender.org/blender/blender/pulls/130736
2024-11-22 14:53:09 +01:00
Laurynas Duburas
cc61ab4dbd Refactor: Curves: Various changes to extrude operator
Removes redundant variables and duplicated logic. Some expressions
simplified. Refactored to make use of `OffsetIndices`. For example,
`Span<IndexRange> curve_interval_ranges` is rewritten into
`OffsetIndices<int> intervals_by_curve`.

Pull Request: https://projects.blender.org/blender/blender/pulls/130229
2024-11-22 14:36:28 +01:00
Hans Goudey
076e1150fc Fix #130720: Crash when saving blend file
Regions were created zero initialized in a couple places for rendering,
those need the region runtime reference.
2024-11-22 08:23:25 -05:00
Omar Emara
01af6ffd22 Compositor: Implement Blur node for new CPU compositor
Reference #125968.
2024-11-22 15:22:32 +02:00
Omar Emara
986802fc87 Composite: Implement Van Vliet Gaussian blur for CPU
Reference #125968.
2024-11-22 15:22:32 +02:00
Omar Emara
3379652bfd Compositor: Implement Deriche Gaussian blur for CPU
Reference #125968.
2024-11-22 15:22:32 +02:00
Omar Emara
edbad1fbde Compositor: Implement Symmetric Separable Blur for CPU
Reference #125968.
2024-11-22 15:22:32 +02:00
Falk David
dc6e879d0f Grease Pencil: Setter for drawing property on frame python API
Previously, it wasn't possible to copy a drawing from one frame to another
if that drawing was in another layer or object.

This allows the `frame.drawing` property to be set to any another drawing.
Setting `drawing` to `None` clears the drawing geometry.

Pull Request: https://projects.blender.org/blender/blender/pulls/130523
2024-11-22 14:19:20 +01:00
Philipp Oeser
06e1da7230 Fix #130719: Painting face sets does not work with hidden faces
Caused by b2ec10184c

Above commit just used the wrong domain retrieving the "hide_poly"
attribute.

Pull Request: https://projects.blender.org/blender/blender/pulls/130724
2024-11-22 13:45:08 +01:00
Jeroen Bakker
30864a975b Vulkan: Incorrect attachment description for sRGB
When binding sRGB textures as attachment to a none-sRGB framebuffer the
attachment description didn't match the image view. This results into a
validation error. This PR makes sure that the description and image view
uses the same VkFormat.

Pull Request: https://projects.blender.org/blender/blender/pulls/130730
2024-11-22 13:30:39 +01:00
Clément Foucault
68fa0a031c Overlay-Next: Do not enable outline drawing for selection
Should speed up selection a bit.
2024-11-22 13:04:38 +01:00
Clément Foucault
f08979cb3f Fix #130669: EEVEE: Filter Size of 0 doesn't result in sharp viewport if using pixel scaling
Clamping the filter size when using scaling factor > 1 fixes
the issue.
Without this, the filter becomes a dirac and samples gets
only the fallback weight. This would results in a box
blur instead of no filtering.
2024-11-22 13:04:38 +01:00
Falk David
b8ace9331c Grease Pencil: Add python tests for the layer.frames API
This adds tests for the `frames.new`, `frames.remove`, `frames.copy`,
and `frames.move` python API.

Pull Request: https://projects.blender.org/blender/blender/pulls/130726
2024-11-22 12:47:50 +01:00
Clément Foucault
fb1a8ca654 Fix #130714: Overlay Next: Can't Select Meshes with X-ray On
Xray mode also need to draw the object surfaces.
The only difference is that the depth test is disabled
by `select_bind`. So the prepass do not write to depth
and it is safe to enable.
2024-11-22 12:36:28 +01:00
Jacques Lucke
12c17e9579 Blenloader: use int64_t in API more consistently
This replaces various uses of `int` and `uint` with `int64_t` in the blenloader API.
This will be necessary for #129309.

Pull Request: https://projects.blender.org/blender/blender/pulls/130591
2024-11-22 12:35:27 +01:00
Christoph Lendenfeld
16c2e71ab0 Anim: Symmetrize collection assignments when symmetrizing Armatures
This patch makes it so collection assignments of bones are
symmetrized when the "Symmetrize" operator is run.

* Only collections with names that can be symmetrized are modified.
* Collections are created if they don't exist,
they are created under the same parent as the source collection
* In the case of a "left" bone assigned to a "right" collection the
resulting "right" bone will be assigned to a "left" collection.
The system does explicitly not try to be smart here.

Also adds unit tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/130524
2024-11-22 12:31:29 +01:00
Jeroen Bakker
dfc0d97abf Fix #129678: Vulkan: Synchronization issue
Copying editors to the swap chain is done by a series of draw and copy.
When doing draw, copy, draw the swap chain layout was not matching the
draw command as it resumed previous rendering.

This is solved by validating the pipeline barriers when resuming rendering.
There are also other cases that required this which have been updated.

Pull Request: https://projects.blender.org/blender/blender/pulls/130721
2024-11-22 11:58:23 +01:00
Pratik Borhade
70d30529bf Fix #130571: "Edit lines" mode in fill tool is not working
`eGP_FillDrawModes` case is ignored. When it's edit line, set
`radius_scale` to 0. Otherwise, vertex buffer will write value for thickness
attribute in vertex buffer inside `draw_grease_pencil_stroke`. Looking at
the `gpu_shader_gpencil_stroke_vert.glsl`, thickness attribute is later used
to tweak vertex position.

Pull Request: https://projects.blender.org/blender/blender/pulls/130578
2024-11-22 10:02:46 +01:00
Jeroen Bakker
e440828221 Fix #130588: Vulkan: Depth stencil readback
Functionality like snapping cursor requires readback of depth stencil
textures. This was not supported yet. This PR will add readback of depth
stencil textures to float.

Fixes: #128624, #130588

Pull Request: https://projects.blender.org/blender/blender/pulls/130717
2024-11-22 09:45:38 +01:00
Hans Goudey
fb17e7f1a0 Fix: Incorrect size for writing new short2 attribute type 2024-11-21 15:23:32 -05:00
Hans Goudey
2b20871216 Cleanup: Move region UI block name map from GHash to Map 2024-11-21 14:04:34 -05:00
Hans Goudey
129a2aa0f4 Refactor: Move region runtime data out of DNA
Pull Request: https://projects.blender.org/blender/blender/pulls/130303
2024-11-21 19:34:53 +01:00
Hans Goudey
fd97477529 Fix: Incorrect assignment of original edit mesh to evaluated mesh
This is incorrect after the changes in 839108f623.
It was only happening for non edit-mode object evaluation anyway
so it likely didn't have any effect in practice.
2024-11-21 13:18:58 -05:00
Clément Foucault
409012956f Overlay-Next: Enable by default and add option to enable legacy code
The legacy option is turned off by default and will be removed
in the following weeks. It is only there to check for
regression for a short period of time. Afterward checking
for regression will require to use 4.3 as a reference.

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/130683
2024-11-21 18:55:39 +01:00
Miguel Pozo
d724ba1f24 Fix: Overlay-Next: v2d depth 2024-11-21 18:51:12 +01:00
Clément Foucault
b36a11aee2 Overlay-Next: Fix discrepancy with xray fade and in-front
This require another depth buffer for correct merging
of overlays. Hopefully we can remove this mandatory
allocation later.
2024-11-21 18:38:02 +01:00
Miguel Pozo
e13504f435 Fix: Overlay-Next: Paint mode wireframes 2024-11-21 18:07:38 +01:00
Clément Foucault
80031a7659 Fix: Overlay-Next: In-front overlays not intersecting the grid correctly
For this to work, we sample the infront second depth and mix it appropriately
to occlude the grid.

The content of the infront framebuffer can be undefined in this
case, so we clear it when appropriate.

Pull Request: https://projects.blender.org/blender/blender/pulls/130625
2024-11-21 18:02:36 +01:00
Miguel Pozo
6d61fff240 Fix: Overlay-Next: Facedot size 2024-11-21 17:51:08 +01:00