Commit Graph

105379 Commits

Author SHA1 Message Date
Hans Goudey
c8aecac001 Cleanup: Remove unused sculpt code
Remove abstract edge and face types. The design is to not abstract away
the code data structures like this and focus on sharing code more with the
rest of Blender rather than within sculpt mode.
2023-12-14 18:25:20 -05:00
Hans Goudey
b3aca5b28f Cleanup: Simplify PBVH build process slightly
Before this happened as two steps: first allocating the PBVH with a type,
then calculating the BVH and filling it with data. This just confused things,
so change to allocating the struct when building it. Also move the functions
to the C++ namespace, and fix some cases of requiring the PBVH to be set
when it wasn't yet.
2023-12-14 18:20:46 -05:00
Harley Acheson
8c6898c04d Fix #116135: Ensure blf_font_width_to_rstrlen always works
If the string is shorter than the cut-off length, ensure we always
exit cleanly when we iterate to the very start of the string.

Pull Request: https://projects.blender.org/blender/blender/pulls/116208
2023-12-14 23:19:08 +01:00
Hans Goudey
87e8a282bc Fix: PBVH has face sets check ignored for BMesh 2023-12-14 15:41:02 -05:00
Hans Goudey
4c1f766d0d Cleanup: Remove unnecessary PBVH threading settings function
There were just two more places using the C threading API in sculpt code.
Switch them to the C++ API and remove the settings function.
2023-12-14 15:39:33 -05:00
Hans Goudey
ce4ec6d42b Cleanup: Tweak PBVH node face indices functions, add comments 2023-12-14 15:31:12 -05:00
Hans Goudey
71b6f0ecbe Cleanup: Pass vertex update array as argument when building PBVH
To prepare for potentially not storing this array in the PBVH.
2023-12-14 15:13:52 -05:00
Hans Goudey
1d94003660 Cleanup: Remove unnecessary sculpt visibility update
Mainly for semantic reasoning-- these face set gestures don't change visibility.
2023-12-14 15:06:08 -05:00
Hans Goudey
f15bca64f2 Cleanup: Remove useless PBVH update function
This `update_vertex_data` only found nodes with the color update
tag and also added redraw tags. But whenever nodes are marked
for a color update, those redraw tags are already set anyway.
It appears this was meant to solve problems switching active
color attributes during undo and redo, but it doesn't make a
difference when this function is removed.
2023-12-14 15:01:27 -05:00
Hans Goudey
262572a6a0 Cleanup: Move PBVH update functions to C++ namespace 2023-12-14 14:56:25 -05:00
Hans Goudey
5be9a1cce4 Cleanup: Slightly simplify some loops in delaunary triangulation
Use a local variable for the faces, use range based for loops.
2023-12-14 12:40:46 -05:00
Hans Goudey
34bf1f6c0c Cleanup: Slightly simplify delaunay triangulation input gathering
Separate allocation of input arrays and assignment to input class.
The main purpose is to simplify #111061.
2023-12-14 12:40:46 -05:00
Hans Goudey
bb2a289a9a Cleanup: Use utility function to calculate face normal
Rather than inlining all the logic into OBJ export code
2023-12-14 12:40:46 -05:00
Miguel Pozo
9bf942dcc9 Cleanup: Conver macros into functions
Avoids macro redefinition warnings in unity builds.
2023-12-14 18:34:20 +01:00
Iliya Katueshenock
999c0f6878 Cleanup: Fix compiler warning in face group boundaries node
Fix error of wrong parameter for `compare_exchange_weak`. Second
one parameter is used for write new value, but a mistake occurred and
the wrong parameter (for read) was used. Default param is enough for
this, so just delete last one.

Pull Request: https://projects.blender.org/blender/blender/pulls/116010
2023-12-14 18:32:21 +01:00
Sybren A. Stüvel
b5e7e6b214 Cleanup: Anim, add explanation to bone collection assign operator
Just a little explanation of the code, because I got confused by my own.

No functional changes, except for the addition of a `BLI_assert_msg()`.
2023-12-14 18:07:10 +01:00
Hans Goudey
a494d6a641 Cleanup: Remove unnecessary C API for delaunay triangulation
The only user was the Python API. Convert that to use the C++ API.
That simplifies things a bit even, since the encoding of "arrays of arrays"
is a fair amount simpler with the C++ data structures. The motivation
is to simplify the changes from #111061.
2023-12-14 11:40:06 -05:00
Aras Pranckevicius
5cac8e2bb4 VSE: reduce effects code duplication, making gaussian blur faster in the process
Now that the code is in C++, quite some duplication between "byte" and
"float" effect code paths can be reduced (easier than it was in C times).
So I did that, removing about 400 lines of code.

In that process I accidentally made Gaussian Blur faster, since while
reducing the amount of code I noticed it was doing some things
sub-optimally (calculated kernel tables for each job, etc.). Applying
100x100 gaussian blur on 4K UHD resolution image strip on Ryzen 5950X
went 630ms -> 450ms.

Pull Request: https://projects.blender.org/blender/blender/pulls/116089
2023-12-14 17:31:05 +01:00
Jeroen Bakker
4a34dcbb69 Studiolight: Free Resources for Unused Lights.
Studio lights based on image resources are kept in memory, even when only
displayed as an icon. When having many studio lights configured
leads to allocating a lot of memory that are not used.

This patch free image resources when only icons are requested.
For studio lights that are used in a viewport the image resources are kept.

Pull Request: https://projects.blender.org/blender/blender/pulls/116191
2023-12-14 16:17:55 +01:00
Hans Goudey
451aa56d9c Cleanup: Move BLI_delaunay_2d.hh to C++ 2023-12-14 10:05:35 -05:00
Hans Goudey
5b053204ed Fix #116017: Mesh edit mode vertex slide allocation ignores alignment
`float4x4` requires 16 byte alignment. The compiler can add padding
within the struct, but the allocation needs to know about the alignment
too. Fix by using an allocation function that handles this properly.
2023-12-14 09:30:19 -05:00
Aras Pranckevicius
1e0bf33b00 ImBuf: optimize IMB_transform
IMB_transform is used by Sequencer (and other places) to do image
translation/rotation/scale on the CPU. This PR speeds up parts of it,
particularly when bilinear filtering is used. No behavior changes are
expected.

- Don't use virtual function calls inside inner loop. The code was using
  class hierarchies with virtual calls just to do equivalent of "outside
  of image? ignore" and "wrap UV coordinates or not?" decisions. Make those
  use non-virtual function based code.
- Simplify pixel sampling functions to only do the work as needed by
  anything within Blender codebase. For example, bilinear sampling of uchar
  images always uses 4 RGBA channels and never does "UV wrap" logic.
- Bilinear interpolation uchar: completely branchless SIMD code now.
- Bilinear interpolation float: 2x floor() calls instead of 4x floor() +
  2x ceil(), and final sample blending is done with SIMD.

Sequencer at 4K UHD resolution, with two image strips that need a transform,
playback framerate:

- Windows Ryzen 5950X: 18.7fps -> 26.2fps (IMB_transform time per frame goes
  26.3ms -> 11.2ms)
- Mac M1 Max: 27.3fps -> 31.4fps

At that point the IMB_transform is not the slowest part of where playback
takes time (but rather sequencer effect application etc.).

Note: the amount of _actual code_ got a bit smaller. But I've added 100 lines
of unit tests in BLI_math_interp_test.cc, the bilinear interpolation
functions were only tested very indirectly by CPU compositor template
image tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/115653
2023-12-14 15:10:30 +01:00
Jeroen Bakker
a52a362527 Studiolights: Remove Unused Options
Studio lights had gone over several iterations during 2.80. Some
unused options where still in the code, but not used.

This PR cleans up the studio lights to options that are still in use.
Removing:

- Spherical Harmonics: It was used by workbench, but was replaced
  by regular OpenGL lights
- Irradiance textures: Was used by an old eevee world light evaluation
- Cached data files.

Pull Request: https://projects.blender.org/blender/blender/pulls/116186
2023-12-14 14:29:28 +01:00
Christoph Lendenfeld
915358f8b6 Cleanup: Remove unused EnumPropertyItem
The channel_bake_remove_options were forgotten
to be removed. They were no longer in use after
addressing review comments.
This fixes the compiler warning.
2023-12-14 14:21:16 +01:00
Christoph Lendenfeld
1e931f5bd7 Anim: Bake Channel operator
This is a replacement for the workflow that uses
"Bake Curve" and "Unbake Curve" to quickly generate
dense key data.

Compared to the existing workflow it has the advantage
of allowing the user more control over the key types,
and distance between keys, as well as the frame range affected.

Operator options

* Range: the range that will be baked.
Defaults to the scene range or preview range.

* Step: Distance between keyframes.
Can be used to bake on 2s or even bake to subframes.

* Remove Existing Keys: Boolean option that
if enabled also removes keys outside the specified baking range

* Interpolation Type: Choose a interpolation mode used
for new keys e.g. Constant or Bezier

* Bake Modifiers: If enabled bakes the effect of the
modifier stack to keys and deletes the modifier stack.
If false, the code disables the modifiers before baking,
so the resulting keys will behave as if the modifiers didn't exist

The operator can be found in the Graph Editor under `Channel->Bake Channels`

Part of: #111050

Pull Request: https://projects.blender.org/blender/blender/pulls/111263
2023-12-14 11:35:25 +01:00
Christoph Lendenfeld
9bfd7debcd Refactor: Move ED_id_action_ensure to animrig
No functional changes.

Move the function ED_id_action_ensure to animrig,
and rename it to `id_action_ensure`.
This is in order to reduce references from animrig
to the editor code.

Pull Request: https://projects.blender.org/blender/blender/pulls/116101
2023-12-14 10:17:18 +01:00
Christoph Lendenfeld
92ad16ab90 Anim: Don't use keying sets when inserting keyframes during autokeying
Prior to this PR, the autokeying system used keying sets
to insert keyframes where required.

With the functions introduced in #113504
the code can be simplified and made to not rely on keying sets,
allowing autokeying to also insert keys by rna path directly.

This also removes all the code related to "Insert Needed" from autokeying.
The insert key functions deal with that now, all that is needed is to pass
in the flag.

Part of #113278

Pull Request: https://projects.blender.org/blender/blender/pulls/115522
2023-12-14 09:04:09 +01:00
Omar Emara
a8e13994b8 Realtime Compositor: Implement Cryptomatte node
This patch implements the Cryptomatte node for the Realtime Compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/115884
2023-12-14 08:49:41 +01:00
Jason Fielder
2db12cc049 Fix #116121: Resolve framebuffer resize issue in Metal
Changing size of framebuffer attachments would
throw an assertion as framebuffer size was not
correctly reset to zero. Zero allows any size
to override the current if there are no set attachments.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/116162
2023-12-14 08:09:03 +01:00
Campbell Barton
410e202e2d Cleanup: quiet parentheses warning 2023-12-14 13:52:31 +11:00
Hans Goudey
e5cb2b2798 Fix #116141: Missing task isolation when storing sculpt undo node
We shouldn't use parallelism internally for each node, but it snuck in
with recent changes to use `array_utils::gather`. That's a nice change,
but we need a better way to turn off parallelism for that sort of
function. Until that's decided on, add a quick fix to fix the deadlock.
2023-12-13 21:46:32 -05:00
Campbell Barton
3241db35cd Docs: correct code comment for LaplacianSystem::tris
Also use doxygen doc-strings as they more easily allow comments to be
expanded on.
2023-12-14 12:51:21 +11:00
Campbell Barton
bff5ffc09b Cleanup: use naming for the size of a looptris array 2023-12-14 12:51:20 +11:00
Campbell Barton
664b49c2ef Cleanup: replace C expressions with plain text in cloth errors
Also remove the print as BKE_modifier_set_error prints a warning.
2023-12-14 12:51:19 +11:00
Campbell Barton
0d9acf84c6 Cleanup: match argument naming for headers/source 2023-12-14 12:51:18 +11:00
Campbell Barton
944e0483a6 Cleanup: clarify naming for MLoopTri
The term `looptri` was used ambiguously for both single & arrays.
The term `tri` was also used, causing `tri->tri`.

Use terms:

- `looptris` for an array or when dealing with multiple items.
- `looptri` is used when dealing with a single item.
- `lt` for a single MLoopTri variables & arguments.

This was already a convention but not followed closely.
2023-12-14 12:32:11 +11:00
Campbell Barton
931b2554e2 Refactor: move BEZKEYTYPE define to DNA
Recently this was inlined [0] however the purpose of this define is to
allow for the method of setting the value to be changed.
It also means the hack doesn't have to be explained whenever it's used.

Move the BEZKEYTYPE to DNA, update it's doc-string and restore the
original comment.

[0]: fd3629b80a
2023-12-14 11:20:27 +11:00
Campbell Barton
d8ffa648eb Cleanup: merge doc-strings, correct comments in WM_api.hh 2023-12-14 11:18:06 +11:00
Campbell Barton
a4af406b81 Clenaup: spelling in comments 2023-12-14 11:14:50 +11:00
Campbell Barton
adb74ad0f3 Cleanup: follow convention for naming array lengths
In the context of meshes `totface` reads as if its the number of faces
in the mesh. This was infact the number of looptris however as this
is converted into a "bodyface" array, use that as the prefix.
2023-12-14 11:10:33 +11:00
Campbell Barton
173a4dfbb6 Fix invalid size of allocated looptris array
Regression in [0], moving to C++ types.

[0]: 321c1af26e
2023-12-14 11:08:35 +11:00
Hans Goudey
cdb2f1e1ba Fix #116140: GPU subdivision ignores completely smooth shading
Extraction of data is done in a different order for GPU subdivision
drawing. The necessary normals domain of the mesh has to be
retrieved before that.
2023-12-13 18:59:28 -05:00
Harley Acheson
463dc4dbec Fix #116137: Overflow causing event time false positive warnings
The intent of `ghost_event_proc_timestamp_warning` is to give a console
warning when an event time is outside of an expected 5 second window
around the last time. However if an event happens within the first 5
seconds we get an overflow in a calculation and we get warnings for
normal times within the range.

Pull Request: https://projects.blender.org/blender/blender/pulls/116164
2023-12-13 22:45:50 +01:00
Richard Antalik
f372ac6f61 VSE: Keep exiting retiming when changing speed
Add "Preserve Current Retiming" option to set speed operator. This
option is enabled by default. When changing speed of retiming segment,
the strip changes length instead of changing next segment speed.

Ref: #112343
2023-12-13 20:45:49 +01:00
Richard Antalik
5092fe60e6 VSE: implement selection of "linked" retiming keys
This feature improves workflow, where it is necessary to select all
retiming keys after one that is selected in order to change speed of
only 1 segment.

The feature is reusing `sequencer.select` "linked time" feature and
mapped Ctrl key.

Ref: #112343
2023-12-13 20:45:16 +01:00
Miguel Pozo
8e9ce4d03d Fix: EEEVEE-Next: Volume lighting
Fix socket_not_white and socket_not_black logic.
(Volume lighting would be disabled if any scatter channel was 0)
Remove unnecesary clamps.
2023-12-13 19:49:31 +01:00
Miguel Pozo
937c4ed2c4 Fix: from_up_axis sign
Same as 6c40adcc36
Fixes the case where up.z == 0
2023-12-13 19:27:30 +01:00
Bastien Montagne
60a9c8ee25 Fix #115486: Linked scenes disappear after reopening file.
Caused by 133dde41bb, it is expected behavior now for linked ID in
general, see also #105786 and #106321.

However, Scenes are a special case here, since they are almost never
(and should not be) indirectly linked by other data, and have (almost)
never any real user, unless they are active in one of the open main
windows.

So this commit essentially reverts the new behavior implemented
in #106321, for linked scenes only.

Should be backported to a potential bugfix release of 4.0.
2023-12-13 18:50:07 +01:00
Bastien Montagne
b840ba1f59 Fix (unreported) crash when trying to link/append while a linked scene is active.
Link/append code sets the scene pointer to `null` when the active
scene is a linked one, to avoid attempt to instantiate linked data
(objects or collections) into a linked scene, which is forbidden.

However, code was still calling some functions expecting a valid scene
pointer, leading to crash.

It is unclear when exactly this issue was introduced code wise. From a
user perspective, it seems to have been revealed between 3.6 and 4.0
release (bisect points at 00a36cbf24, which does not seem to be
directly related...).

In any case, the fix is trivial and safe, so should we do another 4.0
bugfix release, this commit should be backported.
2023-12-13 18:34:13 +01:00
Miguel Pozo
6c40adcc36 Fix: GPU: from_up_axis
glsl sign can return 0.
Fixes surfels display when normal.z == 0.
2023-12-13 17:47:48 +01:00