Commit Graph

99420 Commits

Author SHA1 Message Date
Omar Emara
f9b5b0efd2 Fix #107583: HSV node gives differ from CPU compositor
The HSV node in the realtime compositor produces different values from
the CPU compositor in its identity settings.

This happens because the realtime compositor clamped the saturation
value after HSV correction, while the CPU compositor did not, so this
patch unifies that behavior. Additionally, negative values are now
clamped in both the HSV node and Hue correction node to also match the
CPU compositor.
2023-05-09 14:22:35 +03:00
Brad Smith
322dab936f Build: fixes for OpenBSD
Pull Request: https://projects.blender.org/blender/blender/pulls/107666
2023-05-09 13:19:16 +02:00
Jacques Lucke
8ba9d7b67a Functions: improve handling of thread-local data in lazy functions
The main goal here is to reduce the number of times thread-local data has
to be looked up using e.g. `EnumerableThreadSpecific.local()`. While this
isn't a bottleneck in many cases, it is when the action performed on the local
data is very short and that happens very often (e.g. logging used sockets
during geometry nodes evaluation).

The solution is to simply pass the thread-local data as parameter to many
functions that use it, instead of looking it up in those functions which
generally is more costly.

The lazy-function graph executor now only looks up the local data if
it knows that it might be on a new thread, otherwise it uses the local data
retrieved earlier.

Alongside with `UserData` there is `LocalUserData` now. This allows users
of the lazy-function evaluation (such as geometry nodes) to have custom
thread-local data that is passed to all the lazy-functions automatically.
This is used for logging now.
2023-05-09 13:13:52 +02:00
Campbell Barton
21e6677682 Fix renaming bookmarks stripping non-UTF8 characters 2023-05-09 20:33:47 +10:00
Campbell Barton
768948f51b Cleanup: correct strcpy use for RNA string access 2023-05-09 20:33:11 +10:00
Campbell Barton
c183962c5d Cleanup: quiet unused variable warnings in release builds 2023-05-09 20:32:13 +10:00
Campbell Barton
7f7804e62d Cleanup: use doxygen groups for BLI_string_tests 2023-05-09 20:32:13 +10:00
Sybren A. Stüvel
5532d05622 Anim: remove assumption of array_index order when blending quaternions
The pose library blending code assumed that quaternions would be keyed
in order of `array_index`. This is normally the case when creating a
pose asset, but when manually editing a pose asset Action this
assumption may not hold.

The code still assumes that all FCurves of a single quaternion are
sequential, i.e. are not inter-mixed with other keyed properties. They
just no longer have to be ordered by array index.

Ref: blender-addons/issues#104591
2023-05-09 11:26:27 +02:00
Omar Emara
e8c660b855 Realtime Compositor: Implement Denoise node
This patch implements the Denoise node for the realtime compositor. The
denoiser executes on the CPU and we pay for the CPU<->GPU round trip to
memory, so this is not realtime, as one might expected. And is just a
temporary implementation until OIDN supports GPU execution.

This is different from the CPU implementation in that it doesn't use the
auxiliary passes if they were not provided, because using an inflated
buffer of an undefined value doesn't make much sense.

Pull Request: https://projects.blender.org/blender/blender/pulls/107375
2023-05-09 11:09:06 +02:00
Jeroen Bakker
43bee6ea69 Vulkan: Ensure Minimum Size of VKBuffer
In Vulkan it is not allowed to allocate a buffer of zero bytes. This
would generate an error. In Blender it is possible that a buffer is zero
bytes. For example when the draw manager is drawing instances and there
are no instanced in the scene.

This PR ensures that at least a single byte is allocated in order to not
fail later on.

Co-authored-by: Jeroen Bakker <j.bakker@atmind.nl>
Pull Request: https://projects.blender.org/blender/blender/pulls/107731
2023-05-09 10:20:54 +02:00
Jeroen Bakker
63cc5a1e61 Vulkan: Frame Buffer Flipping
Vulkan coordinate system is flipped compared to OpenGL. This PR
flips the drawing when drawn to the on-screen frame buffer.
Offscreen frame buffers are still drawn upside down.

The flipping is done by making the viewport of the framebuffer negative.

Pull Request: https://projects.blender.org/blender/blender/pulls/107743
2023-05-09 09:22:26 +02:00
Joseph Eagar
4768348583 Sculpt: fix topology automasking not working when factor cache exists 2023-05-08 22:18:38 -07:00
Campbell Barton
47149d2532 Cleanup: order string size argument after the string
This is the convention almost everywhere.
2023-05-09 15:06:41 +10:00
Campbell Barton
788a57c6ef Cleanup: reserve the suffix 'len' for string length 2023-05-09 15:02:12 +10:00
Campbell Barton
c49a0fa474 Cleanup: remove redundant use of BLI_snprintf (no formatting args given)
The SNPRINTF macro isn't usable as it expectes at least one argument.
2023-05-09 14:08:19 +10:00
Campbell Barton
3958ae7241 Cleanup: use STRNCPY, SNPRINTF macros 2023-05-09 14:08:19 +10:00
Campbell Barton
2d99b935f3 BLI_string: add macros to wrap BLI_vsnprintf 2023-05-09 13:16:09 +10:00
Hans Goudey
e151425c5c Fix #107694: Assert adding custom normals to empty mesh 2023-05-08 18:41:06 -04:00
Hans Goudey
150943e084 Cleanup: Move remaining sculpt_paint files to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/107757
2023-05-08 23:48:38 +02:00
Hans Goudey
ce96abd33a Fix: Build error after simulation header cleanup
Making the geometry state's geometry public to remove
the accessors didn't work without the constructor.
2023-05-08 17:21:15 -04:00
Hans Goudey
2f349ce884 Cleanup: Add comments to simulation state header
Pull Request: https://projects.blender.org/blender/blender/pulls/107744
2023-05-08 21:42:38 +02:00
Harley Acheson
8e4e616a4b Fix #106023: File Browser Lists with Incomplete Previews
Ensure all File Browser list items get previews.

Pull Request: https://projects.blender.org/blender/blender/pulls/107698
2023-05-08 20:53:08 +02:00
Iliya Katueshenock
819cd58864 Cleanup: Make Accumulate Attribute node more generic
Geometry Nodes strives to reduce template usage in code,
to use it only for extremely important loops or for template math
processing on attributes. Due to this, this pull request cleans up
to delete template classes and uses `convert_to_static_type` in
accumulate function directly.

Pull Request: https://projects.blender.org/blender/blender/pulls/104440
2023-05-08 20:36:12 +02:00
Julian Eisel
50d49e24c4 Asset Views: Decrease default preview cache size
This was set to a higher value than intended, because the actual caching
doubles the size internally. So it would keep up to 512 previews in
memory which is a bit excessive. See discussion in #107711.
2023-05-08 19:57:56 +02:00
illua1
07ac8cb15a Fix #107506: Depsgraph: non-geometry component is treated as geometry component
Pull Request: https://projects.blender.org/blender/blender/pulls/107509
2023-05-08 18:51:15 +02:00
Bastien Montagne
527b21f0ae LibOverride: Restore local references to virtual linked liboverrides on resync.
When resyncing linked liboverride data, new IDs may be created that do
not exist in actual library file (since the lib file has not been resynced).

If such 'virtual linked liboverrides' data-blocks are used locally (e.g.
by adding such object to a local collection), on next file read they will be
detected as missing.

Now resync code will list such missing linked IDs that were
liboverrides, and try to re-use them when matching (by root name and
library) with newly generated virtual liboverrides.

The process may not be 100% perfect, especially a perfect one-to-one
remapping cannot be ensured if source data keep being changed over and
over (because of the order in which virtual linked liboverrides
generated by resync may change over time). However, in practice this
should fix the vast majority of issues, especially if sane naming
practices are used on IDs.

---------------

For the record, an attempt was made to write liboverride data together
with the placeholders for linked IDs in .blendfile. In theory, this
should ensure a perfect and fully valid re-usage of such IDs.

However, for this to work, not only the liboverride data of linked IDs need
to be written on disk, but also all ID references in this data has to be
considered as directly linked, to ensure that such liboverride data can
be re-read properly.

Otherwise, these placeholders would get a liboverride data with NULL ID
pointers, which is useless.

Such change feels way to intrusive for the very limited benefit, so for
now would consider current solution as the best option.

Pull Request: https://projects.blender.org/blender/blender/pulls/107144
2023-05-08 18:22:33 +02:00
Sybren A. Stüvel
0327d2c963 Add missing notifier when setting cursor.matrix
Add a notifier when setting `scene.cursor.matrix`. This was already in
place for `cursor.location` and `cursor.rotation`, but was still missing
for `cursor.matrix`, which caused the cursor to remain displayed in its
old transform.
2023-05-08 16:58:26 +02:00
Jeroen Bakker
8759ae1760 GPU: Initialize SRGB In TestCases
Vulkan test cases uses SRGB conversion. These test cases where failing
as the conversion table wasn't initialized.

This PR initializes the conversion table and fix the Vulkan data
conversion tests.
2023-05-08 15:32:15 +02:00
Julian Eisel
7e79e0eec0 File Browser: Avoid filling file cache needlessly on auto-complete
This would iterate over all files and call the sneaky `filelist_file()`,
meaning each file would be added to the cache for a minor query. That's
plenty of unnecessary work and kinda defeats the purpose of the partial
cache design.
2023-05-08 15:01:00 +02:00
Julian Eisel
be19edf356 Cleanup: Add API comment on side-effect of file browser query function
`filelist_file()` is an easy way to do a bunch of unnecessary work and
fill the file browser caching for little reason. Unfortunately the
caching affects too many things to be a mere API implementation detail,
so rather be clear about this and point out alternatives.
2023-05-08 15:01:00 +02:00
Julian Eisel
c0ce427760 Cleanup: Move file cache lookup into function
The details on the file cache lookup just look confusing and make the
function look daunting. Encapsulate it into a function so it's trivial
to see what's going on
2023-05-08 15:01:00 +02:00
Lukas Tönne
967cd7f99e Fix: Viewer node crashes when the editor is pinned and has no Object ID
This case was not properly handled by the previous fix in #107621.

The viewer node path function still assumes that the node editor space
has a valid ID pointer (`snode.id`) and that it is an `Object`.
The ID pointer can be null when setting a pinned node tree through the
python API, like so:
```Py
space.pin = True
space.node_tree = some_other_node_tree
```

In this case the `ED_node_tree_start` function is called without and ID
pointer, which is allowed! This patch makes sure that the viewer node
path function is only used with a valid object context.

Pull Request: https://projects.blender.org/blender/blender/pulls/107737
2023-05-08 14:52:06 +02:00
Lukas Tönne
304e8a842d Fix: editor crashes during simulation bake
Fixes crashes in timeline and spreadsheet editors during simulation
nodes baking:
* Timeline tries to access the `states_at_frames_` list of the cache to
  determine which frames to draw as baked. This can collide with the
  baking thread. Needs a mutex to safely access the cache state.
  Note: the old point cache has a pre-allocated flag array
  `cached_frames` which the baking thread writes into while timeline is
  reading it concurrently - not thread-safe but harmless.
* Spreadsheet keeps a data pointer during drawing, which may become
  deallocated when the cache is updated. Common approach here is to use
  `G.is_rendering` to lock the editor while baking.

Pull Request: https://projects.blender.org/blender/blender/pulls/107621
2023-05-08 14:34:21 +02:00
Sybren A. Stüvel
f3be425e97 Fix Pose Library: crash when using partially-keyed quaternions
Remove the assumption that quaternions are always fully keyed in a pose
asset. Even though quaternions really should be fully keyed, better not
make Blender crash when this assumption doesn't hold.

If the quaternion is only partially keyed, the other components are taken
to be from the unit quaternion (`[1, 0, 0, 0]`) and the result is
normalized before blending into the existing pose.

This fixes blender/blender-addons#104591, which was reported against the
pose library add-on, but actually was caused by an issue in Blender.
2023-05-08 13:54:07 +02:00
Lukas Tönne
3e888d77ba Geometry Nodes: Simulation calculate to frame operator
Adds a new operator that resets caches and then iterates from the start
frame to the current frame in order to update caches.

Pull Request: https://projects.blender.org/blender/blender/pulls/107627
2023-05-08 13:41:21 +02:00
Jacques Lucke
b4fb17f11c Geometry Nodes: allow skipping frames during simulation
The maximum delta time is still capped to one frame even if multiple
frames are skipped. Passing in a too large delta time is mostly unexpected
and can reduce the stability of the simulation. Also it can be very slow
when the simulation uses the delta time to determine e.g. how many particles
should be added.
2023-05-08 13:10:30 +02:00
Jeroen Bakker
1f3fda16e6 Vulkan: Extract Correct UniformBuf Name From Interface
Fixes an issue as the uniformbuf name was incorrectly extracted
from the shader interface.

Pull Request: https://projects.blender.org/blender/blender/pulls/107736
2023-05-08 13:01:10 +02:00
Bastien Montagne
3c2dc42712 Fix (studio-reported) crash in liboverride resync code after recent changes. 2023-05-08 12:46:03 +02:00
Jacques Lucke
ae1c52b3f2 Cleanup: remove dead code 2023-05-08 11:48:01 +02:00
Jacques Lucke
d8388ef36a Fix: avoid extra depsgraph evaluation when stopping animation playback
The `NC_SCENE | ND_FRAME` was originally added so that the sequencer
preview is redrawn so that the fps stops showing (2855485565).

Using this specific notifier has the side effect that it also causes a depsgraph
update in `wm_event_do_notifiers`. However, that is not necessary just to
trigger the redraw. Using the `NC_SPACE | ND_SPACE_SEQUENCER` notifier
also triggers the redraw without causing a depsgraph update.
2023-05-08 11:27:50 +02:00
Jacques Lucke
8e9ada0079 Fix: force frame update only when starting animation timer
Otherwise this always causes an extra depsgraph update when
animation playback is stopped.
2023-05-08 11:27:50 +02:00
Jacques Lucke
037b3f87bd Fix: scrubbing time always has extra update that is only used by sequencer
The sequencer has a feature where it only draws a preview while scrubbing.
This was introduced in 8abdc89912.
When scrubbing ends, the sequencer requires an extra update so that the
non-preview version is shown again.

This is only needed by the sequencer and hence the update should not be
done if the sequencer is not used.

Changing `screen->scrubbing` is moved out of the sequencer specific
functions, because it's used elsewhere as well.
2023-05-08 11:27:50 +02:00
Jacques Lucke
2fbbc7acbb Fix: unnecessary depsgraph update when scrubbing in timeline
Previously, there was always a depsgraph update when the mouse moves
while scrubbing in the timeline. Even when the mouse movement does
not change the actual frame. This can happen when e.g. the mouse first
hovers over frame 5.2 and then it moves to frame 5.3. In both cases the
actual frame is rounded to 5, so no update is necessary (that is unless
subframes are used).
2023-05-08 11:27:50 +02:00
Campbell Barton
cd49cb08e3 BLI_string: call BLI_string_debug_size from functions with a buffer size 2023-05-08 19:12:48 +10:00
Campbell Barton
55f7f082a8 Cleanup: avoid BLI_path_basename when the filename is known 2023-05-08 19:12:48 +10:00
Jacques Lucke
c3365666e5 Fix #107637: crash when using density brush on empty hair 2023-05-08 09:26:15 +02:00
Philipp Oeser
04d50f4b23 UI: support operator enums in Quick Favorites
Part of #59244

This was heavily requested since there are a lot of usages of
`operator_menu_enum` around in our UI [and these menus all cannot be
added to Quick Favorites atm.].

The following are just a small sample from the 3D viewport menus (object
mode), but there are many more.

- Object
-- Set Origin
-- Relations >> Make Local...
-- Convert To
- Add
-- Grease Pencil
-- Empty
-- Force Field
-- Collection Instance
- Select
-- Select All by Type
-- Select Grouped
-- Select Linked
- ...

So in order to make this work, `USER_MENU_TYPE_OPERATOR` /
`bUserMenuItem_Op` is reused (but extended with a string to the property
in question). (Alternatively, a new type could be introduced -- but
would share most of the code with the type that is reused in this
patch).

Depending on being used with an enum or not [detected by the usage of
that new string] we then either call `uiItemFullO_ptr` or
`uiItemMenuEnumFullO_ptr` in `screen_user_menu_draw`.

NOTE: support for other enums (property enums such as pivot point or
transform orientations) will follow in a separate commit (building upon
6a13b6324b, trying to solve the way these draw as menus)

NOTE: opening User Preferences with such "new" Quick Favorites even
works (just not drawn with a menu)

Pull Request: https://projects.blender.org/blender/blender/pulls/107616
2023-05-08 09:14:45 +02:00
YimingWu
f080dca2c0 Fix #107717: Missing looptri_polys loading lineart
The `looptri_polys` array was missing likely due to a mesh data
structure update, causing lineart loading function to crash. Now fixed.
2023-05-08 12:18:11 +08:00
Campbell Barton
bb5a22539c Cleanup: correct path size argument
BKE_appdir_folder_documents clamps to FILE_MAXDIR internally.
2023-05-08 12:49:44 +10:00
Campbell Barton
8a852de147 BLI_fileops: change BLI_dir_create_recursive string size handling
Replace MAXPATHLEN with FILE_MAX, always allocate if the buffer isn't
big enough since creating a truncated directory isn't useful.

Having some code-paths only run in an ifdef complicated the code
and made it more difficult to follow.

Also assert the path doesn't contain ".." directories as they aren't
supported.
2023-05-08 12:49:44 +10:00