Commit Graph

115242 Commits

Author SHA1 Message Date
Hans Goudey
ef68097161 Fix #130826: Property search crash after recent region runtime cleanup 2024-11-24 13:37:59 -05:00
Hans Goudey
66a476455b Cleanup: Improve variable name for copied region 2024-11-24 13:37:59 -05:00
Clément Foucault
d8b6b2b1b7 Overlay-Next: Make grease pencil depth plane follow design
This move depth plane computation to right before drawing.
Making sync cycles not rely on view.
2024-11-24 19:35:18 +01:00
Hans Goudey
4587a87b6e Fix: Build error in overlay next from missing include
Switch to using FunctionRef over std::function which is generally
preferrable when the callback doesn't need to be stored for later.
2024-11-24 13:28:45 -05:00
Hans Goudey
fdb1bec6c8 Fix #130811, #130842: Non-mesh object edit mode crash evaluated mesh
The "is edit mode" checks in the draw module have been simplified
to just check the object mode. We need to be a bit more careful to
avoid retrieving the original mesh from a non-mesh object.

This commit improves the "get pre-modified mesh" function with
better comments and checks that reflect the relatively recent cases
where the original and evaluated geometry data types don't match.
It's always called with a mesh object too.

Pull Request: https://projects.blender.org/blender/blender/pulls/130850
2024-11-24 17:43:55 +01:00
Hans Goudey
705972e6af Cleanup: Workbench: Follow style guide for public class variable references
_No response_

Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/130819
2024-11-24 17:37:17 +01:00
Clément Foucault
0ec7afff26 Fix #130802: Overlay Next: Crashes when selecting with Intel GPU
The shaders were invalidly marked as selection shaders.

Also fix the selection buffer / pass setup logic.
2024-11-24 15:45:50 +01:00
Clément Foucault
5f9c63963c Overlay-Next: Support selection of flat meshes in orthographic view
This workaround had not been ported over from the legacy overlays.
2024-11-24 15:29:26 +01:00
Clément Foucault
910ad6d031 Overlay-Next: Refactor flat object outline drawing
This workaround was against design and having conditional
sync depending on the view.

Now, the flat objects are put in a list and conditionally
put in a different pass at draw time.
2024-11-24 15:29:26 +01:00
Clément Foucault
08ed51d5db Cleanup: BKE: Const correctness for BKE_object_dimensions_get 2024-11-24 15:29:26 +01:00
Habib Gahbiche
35ea495bb6 UI: Nodes: Remove some snapping options
Compositor: UI: remove snapping to nodes.

Snapping nodes to other nodes behaves in a very unpredictable way, which makes most snapping options useless.

The patch removes the following:
- Snapping options `Node X`, `Node Y` and `Node XY`
- Menu `Snap Node Element`
- Menu `Snap Target`

New behavior:
- Activating `Snap` always acts as 'Snap to Grid'

Part of https://projects.blender.org/blender/blender/issues/128612

Pull Request: https://projects.blender.org/blender/blender/pulls/127667
2024-11-24 14:30:22 +01:00
Pratik Borhade
f181262634 Fix #130579: Un-isolating collection fails in presence of linked-collection
Visibility of linked collection cannot be changed after 4e907829d3 and
e494a44024. This results in failing "un-isolate" collection. To resolve
that, treat linked/overridden collections as isolated by returning true in
`outliner_collection_is_isolated()`.

Pull Request: https://projects.blender.org/blender/blender/pulls/130604
2024-11-24 06:59:40 +01:00
Pratik Borhade
8dc8e48e9a Fix #130478: Toolbar tooltips have uncentered vertical padding
Pass `is_pad=false` for title text to prevent additional space above
them.

Pull Request: https://projects.blender.org/blender/blender/pulls/130498
2024-11-24 06:51:10 +01:00
Hans Goudey
21e2fba621 Fix #130808: Crash with GPU subdivision, edit mode, and mirror modifier
Mistake in deedbee971.
We need to take into account original indices in the evaluated mesh to
extract the proper original selection state.
2024-11-23 22:12:10 -05:00
Clément Foucault
23ac825a15 Cleanup: Overlay-Next: Deduplicate global UBO binding
No functional changes.
2024-11-24 01:23:10 +01:00
Clément Foucault
37bb1dedf5 Overlay-Next: Document each overlay class 2024-11-24 01:02:55 +01:00
Clément Foucault
6e6711772f Overlay-Next: Move debug scope to capture command generation dispatch
This is more useful to track down visibility issue.
2024-11-24 01:02:55 +01:00
Clément Foucault
170277f703 DRW: Batch Cache: Avoid dummy batch creating invalid draw calls
The vertex length of the batch was 1 which lead to invalid
drawcall if trying to render triangles or lines.

Setting a length of 0 allows the GPU module to bypass the
drawcall.
2024-11-24 01:02:55 +01:00
Hans Goudey
b5f9db919b Fix: Viewer node overlay broken after recent draw extraction fix
The viewer node is not edit mode data, it should be extracted from
a final evaluated mesh (that's just the mechanism that geometry
nodes uses to get the data to the engines. The requests were probably
just added to the bottom by mistake.
2024-11-23 16:45:55 -05:00
Jesse Yurkovich
32b9f50319 Cleanup: USD: remove another dead field from ImportSettings struct
Pull Request: https://projects.blender.org/blender/blender/pulls/130803
2024-11-23 22:04:50 +01:00
Clément Foucault
702c1dc833 Fix #130756: Overlay-Next: Viewer node attributes values are not shown in the 3D viewport
Straightforward port.

Rel #102179
2024-11-23 20:22:49 +01:00
Clément Foucault
95c6a94450 Overlay-Next: Undo changes to Lattice drawing logic
The previous behavior was following legacy overlay.
2024-11-23 19:51:33 +01:00
Harley Acheson
ed6e6200d4 UI: Slightly Softer 50% Split Snap
Based on feedback from Alaska, this slightly narrows (softens) the
snapping to 50% when splitting an area without modifiers held.

Pull Request: https://projects.blender.org/blender/blender/pulls/130800
2024-11-23 19:28:08 +01:00
Hans Goudey
421e1a0c24 Cleanup: Replace some uses of GSet and GHash with C++ classes
For type safety and potentially improved performance.

Pull Request: https://projects.blender.org/blender/blender/pulls/130796
2024-11-23 17:00:21 +01:00
Leon Schittek
13e0077c5c Nodes: Add new shader for node sockets
Add a new shader specifically for node sockets rather than using the
keyframe shader.

Motivation:
1. Allow easier addition of new socket shapes
2. Simplify socket drawing by avoiding special handling of multi-inputs
3. Support multi-inputs for all socket types (diamond, square, etc.)

The new shader is tweaked to look the same to the old ones.

**Comparison**
The biggest difference is that the multi socket is now more consistent
with the other sockets.
For single sockets there can be small size differences depending on zoom
level because the old socket shader always aligned the sockets to the
pixel grid. This could cause a bit of jiggling compared to the rest of
the node when slowly zooming. Therefore I left it out of the new shader
and it now scales strictly linear with the view.

**Multi Socket Types**
While there currently is no need for (.) internally, there are a few
obvious use-cases for multi-input field (diamond) sockets like
generalized math nodes with an arbitrary number of inputs (Add,
Multiply, Minimum etc.).

Co-authored-by: Jacques Lucke <jacques@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/119243
2024-11-23 16:42:38 +01:00
Hans Goudey
b6b312d98f Cleanup: Remove unused GSet forward declarations 2024-11-23 10:07:30 -05:00
Jacques Lucke
9895ad2479 Refactor: Readfile: extract function to decode .blend file header
This simplifies the code a bit in my opinion. It also makes it easier to sneak in an
additional bit in the header for #129309.

Pull Request: https://projects.blender.org/blender/blender/pulls/129746
2024-11-23 13:15:56 +01:00
Clément Foucault
7c97978eca Overlay-Next: Add base class for documentation
Add the base `Overlay` class for documenting the methods.

This cleans up the inconsistency in the method implementation
and add TODOs for method not complying with the interface.

Pull Request: https://projects.blender.org/blender/blender/pulls/130790
2024-11-23 13:11:01 +01:00
Clément Foucault
79b7bce125 Cleanup: Overlay-Next: Make armature method parameter consistent 2024-11-23 11:14:43 +01:00
Philipp Oeser
531ed68061 Fix #130686: Outliner vertex groups sorting is broken
Caused by 8214109778

Before said commit, a vertexgroup `TreeElement` would take its `idcode`
in a questionable way described in the commit messages of 0c0bc61918
and 0a633a4e07.

Since 8214109778 this is not the case anymore, it is just 0.

4292bb060d made this comment (guess this never happened):
>/* We need to figure out how to deal with the idcode for non-
TSE_SOME_ID types still. Some rely on it... */

So in order to return to the prior behavior, we could just enable the
following line (even for the new type design), this will work, but feels
rather shaky (the basic question here is just "do we want idcode to
point to the owner ID for something like vertexgroups?" -- still cannot
answer this question tbh.):
`te->idcode = GS(owner_id->name);`

So one of the places where the logic relied on `idcode` is alphabetical
sorting. The logic excluded some elements from the sorting (by
explicitly setting their `idcode` to zero) and this is where we now
coughing up because... well we are always having a zero `idcode` for the
new type design.

To resolve, just explicitly enable sorting for `TSE_DEFGROUP` again by
explicitly setting their `idcode` to non-zero(one).

Pull Request: https://projects.blender.org/blender/blender/pulls/130750
2024-11-23 10:51:56 +01:00
Clément Foucault
b5f11dc6e1 Cleanup: Overlay-Next: Make drawing functions name consistent
Use same naming convention as the associated framebuffers.
2024-11-23 10:37:55 +01:00
Clément Foucault
d9ab2d1598 Overlay-Next: Move view to local storage
This keeps the visibility resources alive,
avoiding recreating them for each redraw.
2024-11-23 10:37:55 +01:00
Clément Foucault
12048170c9 Cleanup: Overlay-Next: Remove unused members 2024-11-23 10:37:55 +01:00
Clément Foucault
93bfc19ef9 Cleanup: Overlay-Next: Use convenience function for overlay flags 2024-11-23 10:37:55 +01:00
Clément Foucault
aa4ae8add4 Cleanup: Overlay-Next: Use convenience function for selection mode 2024-11-23 10:37:55 +01:00
Clément Foucault
61f601e705 Cleanup: Overlay-Next: Use convenience function for space type checks 2024-11-23 10:37:54 +01:00
Ray molenkamp
87a7cab146 CMake: Fix Policy CMP0175 warning
CMake 3.31 has begun emitting CMP0175 [1] when you call add_custom_command
with invalid keywords. While `MAIN_DEPENDENCY` is a valid keyword for
`add_custom_command(OUTPUT)` [2] it is not for `add_custom_command(TARGET)` [3]

proper fix is to remove the offending parameters.

[1] https://cmake.org/cmake/help/latest/policy/CMP0175.html
[2] https://cmake.org/cmake/help/latest/command/add_custom_command.html#generating-files
[3] https://cmake.org/cmake/help/latest/command/add_custom_command.html#build-events

Pull Request: https://projects.blender.org/blender/blender/pulls/130565
2024-11-23 01:55:00 +01:00
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