Commit Graph

120055 Commits

Author SHA1 Message Date
Hans Goudey
4fcc1b2ba1 Cleanup: Sculpt: Avoid copying float3 values, const for local variables 2024-09-16 22:05:16 -04:00
Hans Goudey
d0119ed552 Cleanup: Sculpt: Remove unused PBVHVertRef accessor function 2024-09-16 22:03:12 -04:00
Hans Goudey
3a9a64aafe Refactor: Sculpt: Specialize automasking vertex factors
Part of #118145.
2024-09-16 21:59:43 -04:00
Hans Goudey
7c42c80126 Refactor: Sculpt: Specialize automasking face sets and boundary modes
Part of #118145.
2024-09-16 21:38:29 -04:00
Hans Goudey
037b064480 Refactor: Sculpt: Specialize automask cavity factor calls
Part of #118145.
2024-09-16 21:37:37 -04:00
Hans Goudey
a4c9c01f31 Refactor: Sculpt: Specialize automasking factors loop per geometry type
Also duplicate for the face sets brush automasking calculation.
Further work in the area will cleanup in incremental steps.
Part of #118145.
2024-09-16 20:53:49 -04:00
Sean Kim
210dfd316a Refactor: Sculpt: Specialize IK chain FK face set calculation
Part of #118145.

* Removes usages of PBVHVertRef and flood_fill:execute for specific
  versions per PBVH type
* Adds stub method for BMesh face set retrieval to make future
  implementation easier.

Pull Request: https://projects.blender.org/blender/blender/pulls/127666
2024-09-16 22:29:18 +02:00
Sean Kim
0c02840a46 Fix: Incorrect debug assert in average_data_grids
Introduced in 0205db4f03

Pull Request: https://projects.blender.org/blender/blender/pulls/127724
2024-09-16 20:51:44 +02:00
Julian Eisel
d28956ab99 Tools: Add BPY tool definition option for brush type
Adds a new `brush_type` argument to pass when defining a tool.
Previously the `data_block` argument would be used for this, but its
name was unclear and misleading, it never ended up being used for
anything but brushes. `brush_type` is much more clear. Note that this
isn't used yet until !125449 is merged.

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

Reviewed as part of
https://projects.blender.org/blender/blender/pulls/125449.
2024-09-16 20:07:37 +02:00
Sybren A. Stüvel
12fe0dd0cf Anim: make action/slot assignment code more generic
In the `blender::animrig` namespace, add two new functions
`generic_assign_action()` and `generic_assign_action_slot()`. These are
now used as basis for (un)assigning Actions and Action slots, both
directly on the ID and for NLA strips.

The method `Action::assign_id()` has been removed, in favour of free
functions for (un)assigning Actions and slots.

This is almost a non-functional change. The only thing that's different
is when both an Action and a slot should get assigned in one go.

Old behaviour: the slot would be inspected, and if not suitable for the
animated ID, the entire operation would be aborted. In other words, any
previously-assigned Action would still be assigned, making this an
atomic operation.

New behaviour: assigning an Action + a slot is no longer atomic. First
the new Action is assigned (which uses the automatic slot selection
based on the name). If after this the given slot cannot be assigned, the
new Action + the auto-selected slot are still kept.

This makes the Action & slot assignment more uniform in behaviour, where
"assign this Action + this slot" as one operation behaves the same as
two sequential operations "assign this Action" + "assign this slot". If
it turns out to be confusing, we can always improve things.

The return code for slot assignment is now more explicit (enum instead
of boolean), so that the caller can decide what to do in case of which
error (like unassigning the slot if the automatic behaviour is
unwanted).

Pull Request: https://projects.blender.org/blender/blender/pulls/127712
2024-09-16 19:31:35 +02:00
Hans Goudey
22cf74d23b Cleanup: Use C++ Array for dependent shape key data
Avoids manual memory management and potentially avoids
an allocation with the inline buffer.
2024-09-16 12:46:54 -04:00
Hans Goudey
5c792e429f Fix #127638: Crash switching to wireframe with custom bone shape
The "edge fac" buffer's dependency on loose geometry indices wasn't
encoded properly in `calc_loose_geom`.
2024-09-16 11:17:45 -04:00
Clément Foucault
0d9ab189d1 Fix: #126524: Overlay: Missing loose geometry wireframe with sub-D mesh
This was caused by default normal for these loose geom
to not be zero.

Setting it to zero fixes the drawing issue.
2024-09-16 16:57:06 +02:00
Clément Foucault
d3b655f76d Fix: #127135: Curve and hair drawing asserting on 0 sized VBO
These buffers are bound as texture buffers and will have
their backend object created whether or not the subsequent
drawcall is emited.

Ensuring a minimum size fixes the issue.
2024-09-16 16:01:59 +02:00
Jeroen Bakker
4be5d7f99f Vulkan: Refactor cached compiler instance
ShaderC compiler was cached on the Vulkan backend. The compiler itself
is light-weight and doesn't require any caching. This PR removes the
cached instance from the backend.

Pull Request: https://projects.blender.org/blender/blender/pulls/127693
2024-09-16 15:51:55 +02:00
Jeroen Bakker
f8ff74f821 GPU: Update stubs of shader builder 2024-09-16 15:02:49 +02:00
Clément Foucault
e90a84469f EEVEE: Simplify barycentric_distances_get
This uses the path that metal was using.

This doesn't seems to create any difference in render
tests. This simplify the backend code and avoid
specific path for metal.

Idea suggested by Kevin Chuang

Pull Request: https://projects.blender.org/blender/blender/pulls/127687
2024-09-16 14:19:53 +02:00
Jeroen Bakker
a407186dbf GPU: Make shader cache clearing backend independent
Parallel shader compilation introduced `GPU_shader_cache_dir_clear_old`.
The implementation was specific to OpenGL and could not be overwritten
by other backends. This PR improves the implementation so the backend
can have its own implementation.

This is needed for upcoming changes to the Vulkan backend where we
want to use similar mechanisms to speed up shader compilation and caching.

Pull Request: https://projects.blender.org/blender/blender/pulls/127680
2024-09-16 14:03:14 +02:00
Aras Pranckevicius
806b0e8379 BLI: improve 2/3/4d vector codegen for debug or asserts-enabled builds
Majority of math operations on VecBase<> were implemented by calling into an
indexing operator, sometimes coupled with unroll<Size> template.

When compiler optimizations are off (e.g. Debug build), or when asserts are on
(e.g. usual "developer" setup), this resulted in codegen that is very
sub-optimal. Especially if these vector types are used a lot, e.g. when
scaling down a screenshot for saving as a thumbnail into the blend file.

Address that by explicit code paths for 4,3,2 dimensional vectors, that
avoids both the unroll<> template and indexing operator. To avoid repeated long
typo-prone code, do that with C preprocessor :( -- however all of the
preprocessor innards are in a separate file BLI_math_vector_unroll.hh so they
do not get into the way much.

Scaling down a screenshot to the blend file thumbnail, while saving the blend
file, on my machine: (4K screen resolution, Ryzen 5950X, VS2022 build), which
involves two calls to IMB_scale which uses float4 for pixel operations:

- Release with asserts off (what ships to users): no change at 9.4ms
- Release with asserts on ("developer" setup): 38.1ms -> 9.4ms
- Debug: 226ms -> 64ms
- Debug w/ ASAN: 314ms -> 78ms

Pull Request: https://projects.blender.org/blender/blender/pulls/127577
2024-09-16 13:06:16 +02:00
Julian Eisel
65fdb3fa30 Grease Pencil: Properly support brushes with draw mode primitive tools
Part of blender/blender!125449.

Since brush assets were merged, the brush asset selector and some other brush
UIs wouldn't show up for the primitive tools. This is addressed now. The
primitive tools use the same brush as the brush tool, although only the draw
brushes will work properly. !125449 addresses this so the primitive tools
remember their own draw brush, separate from the brush tool.

Turns out that these primitive tools were never tagged as using brushes by
setting the `data_block` member (or setting the `'USE_BRUSHES'` option since
b64bf66257). The UI was just hardcoded to display things like the brush selector
for primitive tools. So as far as the tool system knew, these tools did not use
brushes.

Tagging the tools properly exposed some issues that are addressed here (see PR
for details).

Pull Request: https://projects.blender.org/blender/blender/pulls/127204
2024-09-16 13:04:08 +02:00
Sybren A. Stüvel
c64108305e Cleanup: avoid unused parameter warning in non-experimental build
Avoid warnings about unused parameter `slot_handle` when building without
experimental features.

No functional changes.
2024-09-16 12:30:55 +02:00
Julian Eisel
b64bf66257 Refactor: Tools: Change how tools are marked as using brushes
The previous way of considering tools with the `data_block` member set
as using brushes was rather unclear/confusing, but also a bit outdated
with the brush assets changes. Since then most sculpt/paint modes use a
unified brush tool, there was no tool for every brush type (aka brush
tool) anymore. So now the `data_block` member was just set dynamically to
match the active brush type which is otherwise irrelevant to the tool
system now.

Further, this will become important to bring back some of the tools that
use brushes in grease pencil draw mode, see #116337. For that we want to
keep the unified brush tool, but still allow other tools that only use a
specific brush type. So marking a tool as using brushes should be done
separately from indicating a specific brush type.

Removing/replacing the `data_block` member should happen separately
still, pending further developments (e.g. see #125449).

Pull Request: https://projects.blender.org/blender/blender/pulls/125911
2024-09-16 12:20:25 +02:00
Jacques Lucke
8af75d2fcc Geometry Nodes: improve node timings accuracy
Previously, we only measured the execution time of built-in nodes. To get
execution times of node groups, the time of each nested node was accumulated.
This can lead to very bad accuracy when multiple nodes are evaluated at the same
time.

With this patch, we measure the time spend in each compute context more directly
instead of relying on accumulating many small measurements. This also opens up
some potential optimization opportunities, because we can skip measuring the
time for contexts that we don't care about. However, that is not implemented
yet.

The time shown in the UI can still be misleading when many things are going on
at the same time, but it should at least be more accurate in more situations
now.

Pull Request: https://projects.blender.org/blender/blender/pulls/127658
2024-09-16 12:07:52 +02:00
Falk David
cb0ab83eab Fix #127527: Crash drawing with non-GP material
It was possible for a Grease Pencil object to have a material
with no Grease Pencil settings. This can lead to crashes in many
places because it's often assumed that the material has
these settings.

The fix makes sure that `BKE_object_material_get` returns
a Grease Pencil material when called on a Grease Pencil
object.  If the Grease Pencil settings don't exist,
it returns `nullptr`.

In the future, it should be possible to have these materials
and code that reads from the settings should fall back to
the default material.

Pull Request: https://projects.blender.org/blender/blender/pulls/127570
2024-09-16 12:03:05 +02:00
Campbell Barton
4ec0cce30a WM: improve thumbnail scaling performance (debug builds)
Saving files could take ~3-4 seconds on debug builds because of new
imbuf scaling logic.

Even though debug performance usually isn't much of a consideration,
it gets in the way of development.

Since thumbnails don't require the same accuracy as the sequencer or
compositor, use a faster scaling method that uses a box-filter clamped
to integer bounds & integer math.

In practice the difference between the resulting thumbnails isn't
noticeable in my tests.

For debug build with ASAN this gives a ~25x speedup,
for release builds it gives a ~1.4x speedup which is to be
expected with a more approximate scaling method.
2024-09-16 19:51:32 +10:00
Sybren A. Stüvel
9530852347 Anim: avoid division by zero in Action constraint
Avoid a division by zero when the Action constraint has the same value
for its 'min' and 'max' parameters.

When `min` and `max` are equal, the code will now choose either `min`
(when `target value` ≤ `min`) or max (`target value` > `max`).

Pull Request: https://projects.blender.org/blender/blender/pulls/127583
2024-09-16 11:49:54 +02:00
Clément Foucault
019bc5127a Overlay-Next: Xray Outline
Port the outline wire prepass shader to primitive
expansion API and enable it for xray mode.

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/127657
2024-09-16 11:24:40 +02:00
Clément Foucault
11b07cf309 Overlay-Next: Motion Path
Rel #102179

Fixes discrepancies on Mac.

Pull Request: https://projects.blender.org/blender/blender/pulls/127623
2024-09-16 11:22:54 +02:00
Nathan Vegdahl
68a6317207 Fix: build fails when experimental features are disabled
Caused by using a function behind an experimental feature `ifdef`
in non-experimental code. The fix is to move the function out from
behind the `ifdef`, since it's perfectly fine to use in non-experimental
code.
2024-09-16 11:01:54 +02:00
Jeroen Bakker
0311d8082b Fix #127636: Inconsistent GPU module doc
Documentation of the `gpu.state.active_framebuffer_get` is inconsistent.
It mentions `framebuffer_active_get`. I believe the cause is that the
C methods in the Python wrapper are named inconsistently.

This PR fixes this by making the wrapper + documentation consistent
with the top level API.

Pull Request: https://projects.blender.org/blender/blender/pulls/127677
2024-09-16 09:51:04 +02:00
Campbell Barton
f392d9edad Cleanup: use int2 for WMInitStruct & screen size accessors 2024-09-16 12:40:07 +10:00
Hans Goudey
a0eccb4550 Cleanup: Multires: Use FunctionRef and lambdas in reshape 2024-09-15 22:01:13 -04:00
Hans Goudey
aba29c655a Cleanup: Multires: Use C++ threading API in reshape file 2024-09-15 22:01:13 -04:00
Campbell Barton
276d47095d Cleanup: use explicit cast when comparing size_t to -1 2024-09-16 11:39:03 +10:00
Campbell Barton
a988a85a5e Cleanup: use const variables/arguments 2024-09-16 11:39:02 +10:00
Campbell Barton
2360a3911c BLI_listbase: add a utility to check the number of items in the list
To avoid unnecessary looping over listbase items the function
`BLI_listbase_count_at_most` was used however it resulting in an awkward
expression: `BLI_listbase_count_at_most(list, count + 1) == count`
replace this with `BLI_listbase_count_is_equal_to(list, count)`.
2024-09-16 11:39:00 +10:00
Campbell Barton
47c6ac2930 Refactor: use integer values for cursor width in BLF
As all the values involved in cursor offset calculation are integers,
treating the cursor width to a float doesn't give any benefits.
2024-09-16 11:38:58 +10:00
Campbell Barton
94183b9e2e Refactor: add a function to access the window size in pixels
Replace uses of WM_window_native_pixel_x,y with
WM_window_native_pixel_size() which returns an int2 for convenience
and avoids an unnecessary call to GHOST_GetNativePixelSize(..).
2024-09-16 11:38:57 +10:00
Campbell Barton
bf7c52cfd5 Fix error in stereo3d side-by-side display
Regression in [0] for side-by-side & top-bottom display.

[0]: e01cadd657
2024-09-16 11:38:56 +10:00
Sean Kim
5c38eb0d81 Refactor: Sculpt: Add face set offset parameter for BMesh functions
Part of #118145.

Even though BMesh face set functionality does not currently work, there
are some reasonable assumptions we can make about the needed parameters
for some APIs.

This commit changes the signature for relevant unique face set functions
so that future changes are easier when / if face sets are fully
supported within BMesh.

Pull Request: https://projects.blender.org/blender/blender/pulls/127640
2024-09-15 23:24:13 +02:00
Harley Acheson
2278f8eb1b UI: Small Corrections to Text Caret Placement
This PR has very slight corrections to text cursor placement in input
widgets. The most important is a check for the situation where the
right edge of the current character can be greater than the left edge
of the next character. This can happen for some thin characters before
a space. Otherwise the code assumes RTL direction and gives an
incorrect placement. This also slightly tightens the position when at
the start of string, just after a space, or at end of the string.

Pull Request: https://projects.blender.org/blender/blender/pulls/127662
2024-09-15 21:43:49 +02:00
Jacques Lucke
13d30e22a1 Fix: modifier execution time not set for grease pencil modifiers 2024-09-15 18:02:51 +02:00
Jacques Lucke
f2e557725d Fix: Geometry Nodes: crash when using gizmo after changing area type 2024-09-15 17:46:32 +02:00
Campbell Barton
10e8f2f889 Cleanup: various non-functional changes 2024-09-15 23:22:22 +10:00
Campbell Barton
8b2ab34ec6 Cleanup: avoid redundant copy to access the filename 2024-09-15 23:14:13 +10:00
Campbell Barton
a42611be92 Cleanup: remove redundant checks 2024-09-15 23:14:11 +10:00
Campbell Barton
17f809718a Cleanup: avoid shadowing variables 2024-09-15 23:14:10 +10:00
Campbell Barton
9b39b4c91c Cleanup: use const pointers/references 2024-09-15 23:14:09 +10:00
Campbell Barton
1104e4233d Cleanup: pass string by const reference 2024-09-15 23:14:08 +10:00
Campbell Barton
9be29e1bbc Cleanup: match function & declaration names 2024-09-15 23:14:07 +10:00