blender.git
41 hours agoMerge branch 'master' into sculpt_curve_collisionssculpt_curve_collisions
Lukas Tönne [Tue, 19 Jul 2022 05:54:11 +0000 (19 06:54 +0100)]
Merge branch 'master' into sculpt_curve_collisions

44 hours agoFix T99785: Make Principled Hair IOR input behave like other IOR sliders
Jesse Yurkovich [Tue, 19 Jul 2022 03:37:11 +0000 (18 20:37 -0700)]
Fix T99785: Make Principled Hair IOR input behave like other IOR sliders

Was accidental regression in rBed9b21098dd27bf9364397357f89b4c2648f40c2

Remove the input slider's PROP_FACTOR subtype in favor of the default to
align with other IOR sliders. This provides much better control when
dragging the value with the mouse.

Differential Revision: https://developer.blender.org/D15477

44 hours agoFix T99737: Dropping files fails with Wayland
Campbell Barton [Tue, 19 Jul 2022 03:33:02 +0000 (19 13:33 +1000)]
Fix T99737: Dropping files fails with Wayland

Drop events ignored the cursor coordinates, under the assumption that
cursor motion events would also be sent to update the cursor location.

This depended on the behavior of the compositor, it failed for Sway
but worked for Gnome-shell & River.

Resolve by making use of the drop events cursor coordinates.

44 hours agoCleanup: quiet compiler warnings
Campbell Barton [Tue, 19 Jul 2022 03:32:23 +0000 (19 13:32 +1000)]
Cleanup: quiet compiler warnings

46 hours agoFix T99794: regression from uv unwrap selected
Chris Blackbourn [Tue, 19 Jul 2022 01:25:46 +0000 (19 13:25 +1200)]
Fix T99794: regression from uv unwrap selected

Restore only_selected_faces flag inadvertently changed by c0e453233132

Differential Revision: https://developer.blender.org/D15480

2 days agoFix T99781: uv minimize stretch now unflips flipped faces
Chris Blackbourn [Mon, 18 Jul 2022 22:24:29 +0000 (19 10:24 +1200)]
Fix T99781: uv minimize stretch now unflips flipped faces

Add a small gradient to flipped faces proportional to length of edges.

Differential Revision: https://developer.blender.org/D15475

2 days agoFix Text Editor highlight of assert and async
Henrik Dick [Mon, 18 Jul 2022 21:33:30 +0000 (18 23:33 +0200)]
Fix Text Editor highlight of assert and async

Due to the ordering of the checks, assert and async were not highlighted
in the editor, even though they were in the list of keywords.

Differential Revision: http://developer.blender.org/D15483

2 days agoFix wrong alpha for scene linear byte images during texture painting
Brecht Van Lommel [Mon, 18 Jul 2022 15:31:19 +0000 (18 17:31 +0200)]
Fix wrong alpha for scene linear byte images during texture painting

Make the update logic consistent with the case where the initial texture is
created. Also fixes a wrong assert.

Thanks Clément for spotting this.

2 days agoContext: implement an active_action property that returns a single action.
Alexander Gavrilov [Sun, 10 Jul 2022 09:28:44 +0000 (10 12:28 +0300)]
Context: implement an active_action property that returns a single action.

Although e.g. in the dopesheet there is no specific concept of
active action, displaying panels requires singling out one action
reference. It is more efficient and clearer to implement this
natively in the context rather than using selected_visible_actions[0].

- In the Action Editor the action is taken from the header.
- In the Dope Sheet the first selected action is chosen, because
  there is no concept of an active channel or keyframe.
- In the Graph Editor the action associated with the active curve
  is used, which should also be associated with the active vertex.
  This case may be different from selected_visible_actions[0].

Differential Revision: https://developer.blender.org/D15412

2 days agoContext: implement indexing for list properties in path_resolve.
Alexander Gavrilov [Fri, 24 Jun 2022 14:08:54 +0000 (24 17:08 +0300)]
Context: implement indexing for list properties in path_resolve.

The real RNA path_resolve method supports indexing lists,
but the python version on the Context object does not. This
patch adds the missing feature for completeness.

Differential Revision: https://developer.blender.org/D15413

2 days agoFix T99750: crash with file output node, after image colorspace saving changes
Brecht Van Lommel [Mon, 18 Jul 2022 13:47:21 +0000 (18 15:47 +0200)]
Fix T99750: crash with file output node, after image colorspace saving changes

2 days agoBuild: update Embree to 3.13.4, enable Neon2x on Arm
Brecht Van Lommel [Mon, 18 Jul 2022 12:38:43 +0000 (18 14:38 +0200)]
Build: update Embree to 3.13.4, enable Neon2x on Arm

* Allows Apple Silicon machines to use 8-wide BVH, which the release notes
  mention give an 8% performance boost.
* An update to this version is also required for OpenPGL.

This patch includes contributions from Jason Fielder and Sebastian Herholz.

Ref D15286, T98555

Differential Revision: https://developer.blender.org/D15482

2 days agoCleanup: change internal Cycles compact BVH default to match UI
Brecht Van Lommel [Mon, 18 Jul 2022 12:55:21 +0000 (18 14:55 +0200)]
Cleanup: change internal Cycles compact BVH default to match UI

2 days agoI18n: translate add node operator tooltips
Damien Picard [Mon, 18 Jul 2022 13:09:37 +0000 (18 15:09 +0200)]
I18n: translate add node operator tooltips

The tooltips from the Add Node menu were extracted, but not translated.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15467

2 days agoFix T99742: crash when generating rigify rigs, after recent changes
Jun Mizutani [Mon, 18 Jul 2022 12:47:26 +0000 (18 14:47 +0200)]
Fix T99742: crash when generating rigify rigs, after recent changes

Differential Revision: https://developer.blender.org/D15473

2 days agoSubdiv: remove unused GPU device choice, fix crash with libepoxy on init
Brecht Van Lommel [Fri, 15 Jul 2022 17:32:09 +0000 (15 19:32 +0200)]
Subdiv: remove unused GPU device choice, fix crash with libepoxy on init

openSubdiv_init() would detect available evaluators before any OpenGL context
exists, causing a crash with libepoxy. This test however is redundant as we
already check the requirements on the Blender side through the GPU API.

To simplify things, completely remove the device detection in the opensubdiv
module and reduce the evaluators to just CPU and GPU. The plan here is to move
to the GPU module abstraction over OpenGL/Metal/Vulkan and so all these
different backends no longer make sense.

This also removes the user preference for OpenSubdiv compute device, which was
not used for the new GPU subdivision implementation.

Ref D15291

Differential Revision: https://developer.blender.org/D15470

2 days agoFix error indenting new-lines in generated RST API docs
Campbell Barton [Mon, 18 Jul 2022 09:55:51 +0000 (18 19:55 +1000)]
Fix error indenting new-lines in generated RST API docs

New-lines in RNA type descriptions caused invalid RST indentation.

This resolve the error noted by @nutti in D15481.

3 days agoFix T99644: Anchored brush mode fails for negative brushes
Joseph Eagar [Sun, 17 Jul 2022 00:27:25 +0000 (16 17:27 -0700)]
Fix T99644: Anchored brush mode fails for negative brushes

The stroke code now supports raycasting the original mesh.
This fixes anchored mode not working for negative brushes,
which might move the mesh out of the initial mouse cursor
position.

3 days agoSculpt: Fix scene spacing mode (phase 1)
Joseph Eagar [Sat, 16 Jul 2022 23:45:41 +0000 (16 16:45 -0700)]
Sculpt: Fix scene spacing mode (phase 1)

The scene spacing code was failing to
check if a raycast failed, which can happen
when sculpting the edges of objects in negative
mode.

Note I removed what I suspect was a hack put
in to fix this, spacing was clamped
to 0.001 scene units.

Scene spacing mode is actually quite broken,
so it will be fixed in a series of phases.

4 days agoAudaspace: minor formatting fix for last commit.
Jörg Müller [Sat, 16 Jul 2022 20:20:08 +0000 (16 22:20 +0200)]
Audaspace: minor formatting fix for last commit.

4 days agoFix T99039: bpy.ops.sound.mixdown returns indecipherable error
Colin Basnett [Sat, 16 Jul 2022 18:57:28 +0000 (16 20:57 +0200)]
Fix T99039: bpy.ops.sound.mixdown returns indecipherable error

Fix for {T99039}.

The problem was that `AUD_mixdown` and `AUD_mixdown_per_channel` were returning pointers to freed memory.

Two key changes are made:
1. The return value of those functions now simply return a bool as to whether the operation succeeded, instead of an optional error string pointer.
2. The error string buffer is now passed into the function to be filled in case an error occurs. In this way, the onus of memory ownership is unamibiguously on the caller.

Differential Revision: https://developer.blender.org/D15260

4 days agoCurve sculpt: Make constraint solver parameters configurable.
Lukas Tönne [Sat, 16 Jul 2022 12:10:17 +0000 (16 13:10 +0100)]
Curve sculpt: Make constraint solver parameters configurable.

Default curve radius, max. contact number, and solver iteration count
are now accessible properties of the constraint solver.

4 days agoMerge branch 'master' into sculpt_curve_collisions
Lukas Tönne [Sat, 16 Jul 2022 07:55:39 +0000 (16 08:55 +0100)]
Merge branch 'master' into sculpt_curve_collisions

4 days agoCurve sculpting: Fix threading issues in constraint solver.
Lukas Tönne [Sat, 16 Jul 2022 07:39:05 +0000 (16 08:39 +0100)]
Curve sculpting: Fix threading issues in constraint solver.

The constraint solver gets a span of changed curve indices. The comb
brush collects these in a thread-local vector, which is only valid in
a `parallel_for` loop.

The BVH storage also needs to be local to the function, otherwise
parallel calls to the constraint solver will free the shared storage
at the end of the task.

4 days agoPyAPI: re-enable the "bgl" module for headless builds
Campbell Barton [Sat, 16 Jul 2022 07:28:09 +0000 (16 17:28 +1000)]
PyAPI: re-enable the "bgl" module for headless builds

Instead of removing the `bgl` module, set all it's functions to stubs
so importing `bgl` or any of it's members doesn't raise an error.

This avoids problems for scripts that import bgl but don't call it's
functions when running in background mode.

4 days agoCleanup: early exit MEM_lockfree_freeN when called with NULL pointer
Campbell Barton [Sat, 16 Jul 2022 07:13:25 +0000 (16 17:13 +1000)]
Cleanup: early exit MEM_lockfree_freeN when called with NULL pointer

Simplify logic for freeing a NULL pointer. While no null-pointer
de-reference was performed, this wasn't as so obvious as the pointer
was passed to MEM_lockfree_allocN_len before checking for NULL.

NOTE: T99744 claimed the a NULL pointer free was a vulnerability,
while I can't see evidence for this - exiting early makes it clearer
the memory isn't accessed.

*Details*

- Add MEMHEAD_LEN macro, avoids redundant NULL check.
- Use "UNLIKELY(..)" hint's for error cases
  (freeing NULL pointer and checking if `leak_detector_has_run`).

4 days agoFix T99744: NULL pointer free with corrupt zSTD reading
Campbell Barton [Sat, 16 Jul 2022 06:32:36 +0000 (16 16:32 +1000)]
Fix T99744: NULL pointer free with corrupt zSTD reading

4 days agoFix error in assertion after 92a99c14965905e73f049bc1f92b597a903977fc
Campbell Barton [Sat, 16 Jul 2022 06:12:48 +0000 (16 16:12 +1000)]
Fix error in assertion after 92a99c14965905e73f049bc1f92b597a903977fc

5 days agoFix workbench background render broken after recent changes from D15463
Brecht Van Lommel [Fri, 15 Jul 2022 18:10:42 +0000 (15 20:10 +0200)]
Fix workbench background render broken after recent changes from D15463

For Eevee the light baking can initialize OpenGL earlier, but for workbench we
can't assume the backend exists here already.

5 days agoFix Eevee backround render crash after recent changes from D15463
Brecht Van Lommel [Fri, 15 Jul 2022 16:58:35 +0000 (15 18:58 +0200)]
Fix Eevee backround render crash after recent changes from D15463

Backend initialization needs to be delayed until after the OpenGL context
is created. This worked fine in foreground mode because the OpenGL context
already exists for the window at the point GPU_backend_init_once was called,
but not for background mode.

Create the backend just in time in GPU_context_create as before, and
automatically free it when the last context id discarded. But check if any
GPU backend is supported before creating the OpenGL context.

Ref D15463, D15465

5 days agoCycles: refactor rays to have start and end distance, fix precision issues
Brecht Van Lommel [Wed, 13 Jul 2022 14:54:53 +0000 (13 16:54 +0200)]
Cycles: refactor rays to have start and end distance, fix precision issues

For transparency, volume and light intersection rays, adjust these distances
rather than the ray start position. This way we increment the start distance
by the smallest possible float increment to avoid self intersections, and be
sure it works as the distance compared to be will be exactly the same as
before, due to the ray start position and direction remaining the same.

Fix T98764, T96537, hair ray tracing precision issues.

Differential Revision: https://developer.blender.org/D15455

5 days agoFix Cycles MetalRT error after recent specialization changes
Brecht Van Lommel [Fri, 15 Jul 2022 16:00:45 +0000 (15 18:00 +0200)]
Fix Cycles MetalRT error after recent specialization changes

5 days agoCleanup: compiler warnings
Brecht Van Lommel [Fri, 15 Jul 2022 14:47:07 +0000 (15 16:47 +0200)]
Cleanup: compiler warnings

5 days agoFix compiler error in debug builds after 1cf465bbc331
Julian Eisel [Fri, 15 Jul 2022 14:52:01 +0000 (15 16:52 +0200)]
Fix compiler error in debug builds after 1cf465bbc331

5 days agoFix GPU backend deleting resources without an active context
Brecht Van Lommel [Fri, 15 Jul 2022 10:44:35 +0000 (15 12:44 +0200)]
Fix GPU backend deleting resources without an active context

This causes an assert with libepoxy, but was wrong already regardless.

Refactor logic to work as follows:
* GPU_exit() deletes backend resources
* Destroy UI GPU resources with the context active
* Call GPU_backend_exit() after deleting the context

Ref D15291

Differential Revision: https://developer.blender.org/D15465

5 days agoFix overly noisy surface deform warning message
Sergey Sharybin [Fri, 15 Jul 2022 13:54:14 +0000 (15 15:54 +0200)]
Fix overly noisy surface deform warning message

An increased number of vertices is not a stopper for the surface
deform modifier anymore. It might still be useful to expose the
message in the UI, but printing error message to the console on
every modifier evaluation makes real errors to become almost
invisible.

Differential Revision: https://developer.blender.org/D15468

5 days agoCleanup: VSE waveform drawing
Richard Antalik [Fri, 15 Jul 2022 13:46:50 +0000 (15 15:46 +0200)]
Cleanup: VSE waveform drawing

No functional changes.

5 days agoCleanup: compiler warning
Brecht Van Lommel [Fri, 15 Jul 2022 13:05:56 +0000 (15 15:05 +0200)]
Cleanup: compiler warning

5 days agoFix T99706: Crash rendering with headless builds
Campbell Barton [Fri, 15 Jul 2022 12:14:04 +0000 (15 22:14 +1000)]
Fix T99706: Crash rendering with headless builds

When rendering with headless builds, show an error instead of crashing.

Previously GPU_backend_init was called indirectly from
DRW_opengl_context_create, a new function is now called from the window
manager (GPU_backend_init_once), so it's possible to check if the GPU
has a back-end.

This also disables the `bgl` Python module when building WITH_HEADLESS.

Reviewed By: fclem

Ref D15463

5 days agoUI: make many modifier strings translatable
Damien Picard [Fri, 15 Jul 2022 12:12:34 +0000 (15 14:12 +0200)]
UI: make many modifier strings translatable

This includes:
- new modifier names

It mostly uses `N_` because the strings are actually translated elsewhere.
The goal is simply to export them to .po files.

Most of the new translations were reported in T43295#1105335.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15418

5 days agoFix (unreported) LibOverride: invalid behaviors when creating (partial) overrides.
Bastien Montagne [Fri, 15 Jul 2022 10:57:37 +0000 (15 12:57 +0200)]
Fix (unreported) LibOverride: invalid behaviors when creating (partial) overrides.

The outliner would tagg all existing local IDs (for remap from linked
reference data to newly created overrides) when creating a new override.
This would become critical issue in case there is several existing
copies of the same override hierarchy (leading to several hierarchies
using the same override).

Further more, BKE override creation code would not systematically
properly remapp linked usages to new overrides one whithin the affected
override hierarchy, leading to potential undesired remaining usages of
linked data.

5 days agoCycles: generalize shader sorting / locality heuristic to all GPU devices
Brecht Van Lommel [Thu, 14 Jul 2022 14:42:43 +0000 (14 16:42 +0200)]
Cycles: generalize shader sorting / locality heuristic to all GPU devices

This was added for Metal, but also gives good results with CUDA and OptiX.
Also enable it for future Apple GPUs instead of only M1 and M2, since this has
been shown to help across multiple GPUs so the better bet seems to enable
rather than disable it.

Also moves some of the logic outside of the Metal device code, and always
enables the code in the kernel since other devices don't do dynamic compile.

Time per sample with OptiX + RTX A6000:
                                         new                  old
barbershop_interior                      0.0730s              0.0727s
bmw27                                    0.0047s              0.0053s
classroom                                0.0428s              0.0464s
fishy_cat                                0.0102s              0.0108s
junkshop                                 0.0366s              0.0395s
koro                                     0.0567s              0.0578s
monster                                  0.0206s              0.0223s
pabellon                                 0.0158s              0.0174s
sponza                                   0.0088s              0.0100s
spring                                   0.1267s              0.1280s
victor                                   0.0524s              0.0531s
wdas_cloud                               0.0817s              0.0816s

Ref D15331, T87836

5 days agoCycles: Apple Silicon optimization to specialize intersection kernels
Michael Jones [Tue, 12 Jul 2022 13:32:46 +0000 (12 15:32 +0200)]
Cycles: Apple Silicon optimization to specialize intersection kernels

The Metal backend now compiles and caches a second set of kernels which are
optimized for scene contents, enabled for Apple Silicon.

The implementation supports doing this both for intersection and shading
kernels. However this is currently only enabled for intersection kernels that
are quick to compile, and already give a good speedup. Enabling this for
shading kernels would be faster still, however this also causes a long wait
times and would need a good user interface to control this.

M1 Max samples per minute (macOS 13.0):

                    PSO_GENERIC  PSO_SPECIALIZED_INTERSECT  PSO_SPECIALIZED_SHADE

barbershop_interior       83.4             89.5                   93.7
bmw27                   1486.1           1671.0                 1825.8
classroom                175.2            196.8                  206.3
fishy_cat                674.2            704.3                  719.3
junkshop                 205.4            212.0                  257.7
koro                     310.1            336.1                  342.8
monster                  376.7            418.6                  424.1
pabellon                 273.5            325.4                  339.8
sponza                   830.6            929.6                 1142.4
victor                    86.7              96.4                   96.3
wdas_cloud               111.8            112.7                  183.1

Code contributed by Jason Fielder, Morteza Mostajabodaveh and Michael Jones

Differential Revision: https://developer.blender.org/D14645

5 days agoCycles: keep track of SVM nodes used in kernels
Michael Jones [Tue, 12 Jul 2022 15:22:36 +0000 (12 17:22 +0200)]
Cycles: keep track of SVM nodes used in kernels

To be used for specialization in Metal, to automatically leave out unused nodes
from the kernel.

Ref D14645

5 days agoCycles: refactor to move part of KernelData definition to template header
Brecht Van Lommel [Tue, 12 Jul 2022 15:26:29 +0000 (12 17:26 +0200)]
Cycles: refactor to move part of KernelData definition to template header

To be used for specialization on Metal in a following commit, turning these
members into compile time constants.

Ref D14645

5 days agoRender: camera depth of field support for armature bone targets
Damien Picard [Fri, 15 Jul 2022 11:30:57 +0000 (15 13:30 +0200)]
Render: camera depth of field support for armature bone targets

This is useful when using an armature as a camera rig, to avoid creating and
targetting an empty object.

Differential Revision: https://developer.blender.org/D7012

5 days agoRender: improve render border operator in image editor
Brecht Van Lommel [Thu, 14 Jul 2022 18:18:56 +0000 (14 20:18 +0200)]
Render: improve render border operator in image editor

* Snap border to pixels just outside the drawn border, to more easily select
  specific pixels by drawing a border inside them.
* Support cropped border renders.

5 days agoCleanup: add utlity function to compute render resolution
Brecht Van Lommel [Thu, 14 Jul 2022 18:16:34 +0000 (14 20:16 +0200)]
Cleanup: add utlity function to compute render resolution

Instead of duplicating logic many times.

5 days agoCleanup: make format
Brecht Van Lommel [Fri, 15 Jul 2022 11:08:51 +0000 (15 13:08 +0200)]
Cleanup: make format

5 days agoFix T98061: uv resize with individual origins could break constrain to bounds
Chris Blackbourn [Fri, 15 Jul 2022 11:13:59 +0000 (15 23:13 +1200)]
Fix T98061: uv resize with individual origins could break constrain to bounds

Fix unreported: Resize with Constrain To Bounds will now limit one shared scale
value for both U and V instead of calculating separate scale values for each.

To fix T98061, the individual origins (transdata->center) is now used when
that mode is active.

See also: 0e9367fc29bc

Differential Revision: https://developer.blender.org/D15420

5 days agoI18n: Add suport for labels from modifiers' subpanels.
Bastien Montagne [Fri, 15 Jul 2022 09:41:13 +0000 (15 11:41 +0200)]
I18n: Add suport for labels from modifiers' subpanels.

Was a bit oif a struggle since those functions take a first string which
is not our label, but should work fine now.

Reported/detected as part of D15418.

5 days agoFix: Move DRW_shgroup_add_material_resources(grp, mat) to after the null-check for...
Martijn Versteegh [Fri, 15 Jul 2022 09:22:10 +0000 (15 11:22 +0200)]
Fix: Move DRW_shgroup_add_material_resources(grp, mat) to after the null-check for grp.

Reviewed By: fclem

Maniphest Tasks: T99646

Differential Revision: https://developer.blender.org/D15436

5 days agoFix T99606: Regression: TexCoordinate losing precision far away from origin
Clément Foucault [Fri, 15 Jul 2022 09:15:59 +0000 (15 11:15 +0200)]
Fix T99606: Regression: TexCoordinate losing precision far away from origin

Same root cause as T99128. The fix also needed to be done in another place.

5 days agoGPU: Fix shader builder on hardware that does not have all features
Clément Foucault [Fri, 15 Jul 2022 09:03:42 +0000 (15 11:03 +0200)]
GPU: Fix shader builder on hardware that does not have all features

5 days agoCleanup: GPU: Replace NULL by nullptr from C++ files
Clément Foucault [Fri, 15 Jul 2022 08:36:24 +0000 (15 10:36 +0200)]
Cleanup: GPU: Replace NULL by nullptr from C++ files

5 days agoFix an increasing bottleneck when key press operator is too slow
Sergey Sharybin [Wed, 13 Jul 2022 08:22:04 +0000 (13 10:22 +0200)]
Fix an increasing bottleneck when key press operator is too slow

The goal of this change is to fix an increasing bottleneck of the event
queue handling when there is an operator bound to a key press event and
is taking longer to finish than a key-repeat speed on the system.

Practical example of when it happens is the marker tracking operator in
a single-frame track mode. Quite often artists will hold down Alt-arrow
to track a segment of footage which seems trivial to track. The issue
arises when the Alt-arrow is released: prior to this change it is was
possible that more frames will be tracked. It also seems that redraws
are less smooth.

It is a bit hard to make easily shareable computer-independent test
case. Instead, a synthetic case can be reproduced by adding a 50 ms
sleep in the `text_move_exec()`. In such synthetic case open a long
text in the text editor and hold left/right arrow button to navigate
the cursor. The observed behavior is that seemingly redraws happen
less and less often and cursor travels longer and longer distances
between redraws. The cursor will also keep moving after the buttons
has been released.

The proposed solution is to ignore sequential key-press events from
being added to the event queue. This seems to be the least intrusive
and the most safe approach:

- If the operator is fast enough there will be no multiple press events
  in the queue in both prior and after of this change.

- If the operator is slow enough, clicking the button multiple times
  (i.e. clicking arrow button 3 times in a heavy shot will change the
  scene frame by exactly 3 frames because no events are ignored in
  this case).

- Only do it for key press events, keeping mouse and tabled behavior
  unchanged which is crucial for the paint mode.

Note that this is a bit different from the key repeat tracking and
filtering which is already implemented for keymaps as here we only want
to avoid the event queue build-up and do want to ignore all repeat
events. In other words: we do want to handle as many key presses as the
operator performance allows it without clogging anything.

A possible extension to this change could be a key press counter, so
that instead of ignoring the event we merge it into the last event in
the queue, incrementing some counter. This way if some operator really
needs to know exact number of key repeats it can still access it.

Differential Revision: https://developer.blender.org/D15444

5 days agoGPU: Remove USD dependency from shader_builder.
Ray Molenkamp [Fri, 15 Jul 2022 08:51:46 +0000 (15 10:51 +0200)]
GPU: Remove USD dependency from shader_builder.

Dependency was added as shader builder depended to blenkernel as an
umbrella, in stead of adding the actual dependencies it required.

5 days agoBLI_bitmap: fix _BITMAP_NUM_BLOCKS to not over-count by one block
Aras Pranckevicius [Fri, 15 Jul 2022 07:21:27 +0000 (15 10:21 +0300)]
BLI_bitmap: fix _BITMAP_NUM_BLOCKS to not over-count by one block

For bit counts that were exact multiple of block size, the macro was
computing one block too much.

Reviewed By: Campbell Barton, Bastien Montagne
Differential Revision: https://developer.blender.org/D15454

5 days agoBLI_bitmap: ability to declare by-value, and function to find lowest unset bit
Aras Pranckevicius [Fri, 15 Jul 2022 07:20:04 +0000 (15 10:20 +0300)]
BLI_bitmap: ability to declare by-value, and function to find lowest unset bit

In preparation for a larger change (D14162), some BLI_bitmap
functionality that could be submitted separately:

- Ability to declare a fixed size bitmap by-value, without extra
  memory allocation: BLI_BITMAP_DECLARE
- Function to find the index of lowest unset bit:
  BLI_bitmap_find_first_unset
- Test coverage of the above.

Reviewed By: Campbell Barton, Bastien Montagne
Differential Revision: https://developer.blender.org/D15454

5 days agoGHOST/Wayland: partial support for updating the UI scale
Campbell Barton [Fri, 15 Jul 2022 05:42:24 +0000 (15 15:42 +1000)]
GHOST/Wayland: partial support for updating the UI scale

Partial support for changing the UI scale while Blender is open.

The scale is set but issues with the window size not updating remain.

5 days agoGHOST/Wayland: fix error setting the cursor scale
Campbell Barton [Fri, 15 Jul 2022 05:36:21 +0000 (15 15:36 +1000)]
GHOST/Wayland: fix error setting the cursor scale

Calculate a scale that's compatible with the cursor size.
Needed so the cursor is always a multiple of scale.

5 days agoblend_render_info: add check for negative BHead length (corrupt file)
Campbell Barton [Fri, 15 Jul 2022 04:52:32 +0000 (15 14:52 +1000)]
blend_render_info: add check for negative BHead length (corrupt file)

Without this check, corrupt files would raise a Python exception,
now early exit with a useful error.

5 days agoFix T99711: Eternal loop reading blend file thumbnail
Campbell Barton [Fri, 15 Jul 2022 04:47:18 +0000 (15 14:47 +1000)]
Fix T99711: Eternal loop reading blend file thumbnail

Account for negative BHead length (already handled by blend file loading).

5 days agoCleanup: Use const pointers for ImageSaveOptions and ImageFormatData
Jesse Yurkovich [Fri, 15 Jul 2022 04:27:58 +0000 (14 21:27 -0700)]
Cleanup: Use const pointers for ImageSaveOptions and ImageFormatData

Use const pointers to ImageSaveOptions and ImageFormatData for API
parameters where appropriate.

Differential Revision: https://developer.blender.org/D15400

5 days agoFix T79304: improve uv island calculation when in edge selection mode
Chris Blackbourn [Thu, 14 Jul 2022 00:40:43 +0000 (14 12:40 +1200)]
Fix T79304: improve uv island calculation when in edge selection mode

Differential Revision: https://developer.blender.org/D15419

6 days agoCleanup: separate clipUVTransform into two different functions
Chris Blackbourn [Thu, 14 Jul 2022 22:04:50 +0000 (15 10:04 +1200)]
Cleanup: separate clipUVTransform into two different functions

No functional changes.

Prep for D15420 / T98061.

6 days agoFix T99705: fix integer overflow in thumbnail extractor
Ray Molenkamp [Thu, 14 Jul 2022 18:18:35 +0000 (14 12:18 -0600)]
Fix T99705: fix integer overflow in thumbnail extractor

It was smart enough to check if the buffer had the right
size but neglected to cast to a 64 bit value so it
overflowed.

Differential Revision: https://developer.blender.org/D15457
Reviewed By: brecht

6 days agoModifiers: fix mesh to volume modifier on non-volume objects
Jacques Lucke [Thu, 14 Jul 2022 18:05:14 +0000 (14 20:05 +0200)]
Modifiers: fix mesh to volume modifier on non-volume objects

6 days agoFix `on_drag_start` handler not getting ID when dragging from Outliner
Julian Eisel [Thu, 14 Jul 2022 17:21:56 +0000 (14 19:21 +0200)]
Fix `on_drag_start` handler not getting ID when dragging from Outliner

We would first invoke the dragging, and then set the drag data (like the
ID or the dragged modifier), so the `wmDropBox.on_drag_start()` handler
wouldn't be able to access this. This broke dragging some IDs from the
Outliner, noticed in D15333.

It's now possible to first create/request drag data, extend it, and then
invoke the actual dragging. The normal function to start dragging
returns `void` now instead of `wmDrag *`, so the drag data can't easily
be modified after starting anymore.

6 days agoUI: Tweak layout of File Browser Preferences
Julian Eisel [Thu, 14 Jul 2022 17:07:13 +0000 (14 19:07 +0200)]
UI: Tweak layout of File Browser Preferences

* Don't nest "Show Recent Locations" and "Show System Locations" under a
  "Defaults" heading. They are not just a default setting but completely
  hide panels from the UI.
* Use own "Show Locations" heading instead, and remove redundant words
  from labels.
* Move the options to the top of the panel, they are more general since
  they can't be toggled in a File Browser session, and thus have bigger
  impact.

We may want to remove these options in a future major release, I don't
think they are useful.

Agreed on with Pablo Vazquez.

6 days agoI18n: Fix regex for messages from `BKE_modifier_set_error`.
Bastien Montagne [Thu, 14 Jul 2022 16:46:52 +0000 (14 18:46 +0200)]
I18n: Fix regex for messages from `BKE_modifier_set_error`.

Signature of this function changed at some point, regex to extract
messages from it was no longer working.

Reported/detected as part of D15418.

6 days agoFix T99702: Gpencil Flip strokes did not support multiframe edit
Antonio Vazquez [Thu, 14 Jul 2022 14:33:21 +0000 (14 16:33 +0200)]
Fix T99702: Gpencil Flip strokes did not support multiframe edit

This was a missing feature and this commit solves this.

6 days agoFix Cycles MNEE wrong results with area light spread
Olivier Maury [Thu, 14 Jul 2022 13:59:26 +0000 (14 15:59 +0200)]
Fix Cycles MNEE wrong results with area light spread

When the solve is successful, the light sample needs to be updated since the
effective shading point is now on the last refractive interface. Spread was
not taken into account, creating false caustics.

Differential Revision: https://developer.blender.org/D15449

6 days agoCleanup: replace state flow macros in the kernel with functions
Brecht Van Lommel [Wed, 13 Jul 2022 12:22:42 +0000 (13 14:22 +0200)]
Cleanup: replace state flow macros in the kernel with functions

6 days agoCycles: add presets to the Performance panel
Brecht Van Lommel [Wed, 13 Jul 2022 13:23:50 +0000 (13 15:23 +0200)]
Cycles: add presets to the Performance panel

With choices Default, Lower Memory and Faster Render. For convenience, and
to help communicate what the various settings do.

Differential Revision: https://developer.blender.org/D15446

6 days agoImprove Tool tip for Add-on search
Gaia Clary [Sun, 10 Jul 2022 08:35:05 +0000 (10 10:35 +0200)]
Improve Tool tip for Add-on search

Differential Revision: https://developer.blender.org/D15411

6 days agoCycles: Improve cache usage on Apple GPUs by chunking active indices
Michael Jones [Wed, 13 Jul 2022 19:56:57 +0000 (13 20:56 +0100)]
Cycles: Improve cache usage on Apple GPUs by chunking active indices

This patch partitions the active indices into chunks prior to sorting by material in order to tradeoff some material coherence for better locality. On Apple Silicon GPUs (particularly higher end M1-family GPUs), we observe overall render time speedups of up to 15%. The partitioning is implemented by repeating the range of `shader_sort_key` for each partition, and encoding a "locator" key which distributes the indices into sorted chunks.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D15331

6 days agoCleanup: minor changes to camera frame fitting
Campbell Barton [Thu, 14 Jul 2022 12:05:31 +0000 (14 22:05 +1000)]
Cleanup: minor changes to camera frame fitting

Use const vars & make order of min/max checks consistent.

6 days agoCleanup: spelling in comments
Campbell Barton [Thu, 14 Jul 2022 12:02:52 +0000 (14 22:02 +1000)]
Cleanup: spelling in comments

Also remove duplicate comments in bmesh_log.h, caused by automated
comment relocation in [0].

[0]: c4e041da23b9c45273fcd4874308c536b6a315d1

6 days agoCleanup: remove redundant `event->val` check for 3D text insertion
Campbell Barton [Thu, 14 Jul 2022 12:01:43 +0000 (14 22:01 +1000)]
Cleanup: remove redundant `event->val` check for 3D text insertion

6 days agoCleanup: clang-tidy changes to GHOST_SystemX11
Campbell Barton [Thu, 14 Jul 2022 11:55:46 +0000 (14 21:55 +1000)]
Cleanup: clang-tidy changes to GHOST_SystemX11

Also remove redundant check.

6 days agoGHOST: remove redundant ascii argument to GHOST_EventKey
Campbell Barton [Thu, 14 Jul 2022 11:39:31 +0000 (14 21:39 +1000)]
GHOST: remove redundant ascii argument to GHOST_EventKey

Now only the utf8 buffer is used there is no reason to pass both.

6 days agoFix: Wrong output types for some compositor nodes
Omar Emara [Thu, 14 Jul 2022 11:52:44 +0000 (14 13:52 +0200)]
Fix: Wrong output types for some compositor nodes

The Difference Matte and RGB To BW nodes have a wrong output type. They
should be floats but are of type color.

This is a regression that was introduced during the migration to the
socket builder API in D13266.

Reviewed By: Blendify, fclem

Differential Revision: https://developer.blender.org/D15232

6 days agoMerge branch 'master' into sculpt_curve_collisions
Lukas Tönne [Thu, 14 Jul 2022 11:11:32 +0000 (14 12:11 +0100)]
Merge branch 'master' into sculpt_curve_collisions

6 days agoGHOST/X11: avoid redundant utf8 text lookups for release events
Campbell Barton [Thu, 14 Jul 2022 11:07:37 +0000 (14 21:07 +1000)]
GHOST/X11: avoid redundant utf8 text lookups for release events

The text representation of release events is never used,
so only calculate this for press events.

6 days agoGHOST/X11: Quiet warning about key-release events having their utf8 set
Campbell Barton [Thu, 14 Jul 2022 10:55:02 +0000 (14 20:55 +1000)]
GHOST/X11: Quiet warning about key-release events having their utf8 set

Quiet warning from [0], no functional change as the this information
was always ignored.

Key release events shouldn't have associated text, this was cleared
for wmEvent's, so there is no reason to pass it from GHOST.

[0]: d6fef73ef110eb43756b7b87c2cba80abae3b39f

6 days agoCleanup: format, unused argument
Campbell Barton [Thu, 14 Jul 2022 10:52:47 +0000 (14 20:52 +1000)]
Cleanup: format, unused argument

6 days agoIDManagement: add more ID naming tests
Aras Pranckevicius [Thu, 14 Jul 2022 10:41:43 +0000 (14 13:41 +0300)]
IDManagement: add more ID naming tests

As part of a larger change (https://developer.blender.org/D14162),
adding more test coverage for existing functionality separately.

New tests:
- ids_sorted_by_default
- ids_sorted_by_default_with_libraries
- name_too_long_handling
- create_equivalent_numeric_suffixes
- zero_suffix_is_never_assigned
- remove_after_dup_get_original_name
- name_number_suffix_assignment
- renames_with_duplicates
- names_are_unique_per_id_type

6 days agoFix curve drawing crash after changing geometry nodes output.
Lukas Tönne [Thu, 14 Jul 2022 10:17:59 +0000 (14 11:17 +0100)]
Fix curve drawing crash after changing geometry nodes output.

Using geometry nodes with attributes on a curve object and changing the
output is crashing. This is because the `render_mutex` in the curve
drawing cache is cleared after changes in `curves_batch_cache_init` and
set to null. The cache isn't actually needed currently because all draw
updates are single-threaded, but the new `drw_attributes_merge` function
still tries to access it (this seems to be tolerated on Linux platforms
but crashes on Windows).

Make sure the render_mutex is always initialized after (re-)initializing
the cache.

6 days agoCorrect error with IME from d6fef73ef110eb43756b7b87c2cba80abae3b39f
Campbell Barton [Thu, 14 Jul 2022 10:07:06 +0000 (14 20:07 +1000)]
Correct error with IME from d6fef73ef110eb43756b7b87c2cba80abae3b39f

6 days agoGeometry Nodes: update curve type counts after realizing instances
Jacques Lucke [Thu, 14 Jul 2022 09:49:28 +0000 (14 11:49 +0200)]
Geometry Nodes: update curve type counts after realizing instances

The type counts have to be updated eagerly. This was missing from
the realize-instances code before, leading to bugs further down
the line.

6 days agoBLI: fix finding indices from virtual array
Jacques Lucke [Thu, 14 Jul 2022 09:32:01 +0000 (14 11:32 +0200)]
BLI: fix finding indices from virtual array

The sorting of index vectors assumed that all vectors have
at least one element. Now this is checked for more explicitely.

6 days agoGeometry Nodes: fix face corner to edge boolean interpolation
Jacques Lucke [Thu, 14 Jul 2022 08:47:26 +0000 (14 10:47 +0200)]
Geometry Nodes: fix face corner to edge boolean interpolation

This is a follow up for rB44e530e1b107fd0d91f472f9a58642ab59fd5422
which did not fix the function that interpolates boolean attributes.

6 days agoGeometry Nodes: fix face corner to edge attribute interpolation
Jacques Lucke [Thu, 14 Jul 2022 08:35:46 +0000 (14 10:35 +0200)]
Geometry Nodes: fix face corner to edge attribute interpolation

Looks like this was wrong all the time.. Luckily, this conversion
is not very common.

Found when testing D15274.

6 days agoUI: translate tooltips coming from menu descriptions
Damien Picard [Thu, 14 Jul 2022 08:28:52 +0000 (14 10:28 +0200)]
UI: translate tooltips coming from menu descriptions

Many menus get their labels exported to the .po file, but then are not actually translated in the UI.

Before:
{F13283752}

After:
{F13283750}

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15417

6 days agoCleanup: Rename & refactor several F-curve functions
Colin Basnett [Thu, 14 Jul 2022 08:22:30 +0000 (14 10:22 +0200)]
Cleanup: Rename & refactor several F-curve functions

Rename and refactor several F-curve key manipulation functions, and move
them from `editors` to `blenkernel`.

The functions formerly known as `delete_fcurve_key`,
`delete_fcurve_keys`, and `clear_fcurve_keys` have been moved from
`ED_keyframes_edit.h` to `BKE_fcurve.h` and have been renamed according
to hierarchical naming rules.

Below is a table of the naming changes.

| From | To |
| -- | -- |
| `delete_fcurve_key(fcu, index, do_recalc)` | `BKE_fcurve_delete_key(fcu, index)` |
| `delete_fcurve_keys(fcu)` | `BKE_fcurve_delete_keys_selected(fcu)` |
| `clear_fcurve_keys(fcu)` | `BKE_fcurve_delete_keys_all(fcu)` |
| `calchandles_fcurve()` | `BKE_fcurve_handles_recalc()` |
| `calchandles_fcurve_ex()`| `BKE_fcurve_handles_recalc_ex()` |

The function formerly known as `delete_fcurve_key` no longer takes a
`do_fast` parameter, which determined whether or not to call
`calchandles_fcurve`. Now, the responsibility is on the caller to run
the new `BKE_fcurve_handles_recalc` function if they have want to
recalculate the handles.

In addition, there is now a new static private function called
`fcurve_bezt_free` which sets the key count to zero and frees the key
array. This function is now used in couple of instances of functionally
equivalent code. Note that `BKE_fcurve_delete_keys_all` is just a
wrapper around `fcurve_bezt_free`.

This change was initially spurred by the fact that `delete_fcurve_keys`
was improperly named; this was a good opportunity to fix the location
and naming of a few of these functions.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D15282

6 days agoFix T99239: weird behavior in Field on Domain node
Iliay Katueshenock [Thu, 14 Jul 2022 08:04:35 +0000 (14 10:04 +0200)]
Fix T99239: weird behavior in Field on Domain node

6 days agoUI: translate quick favorites menu operator names
Damien Picard [Thu, 14 Jul 2022 07:42:48 +0000 (14 09:42 +0200)]
UI: translate quick favorites menu operator names

Some operator titles were not translated in the quick favorites menu.

Before:
{F13283724}

After:
{F13283725}

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15416

6 days agoI18N: Allow translating newly added GP data names, and a missing Surface one.
Damien Picard [Thu, 14 Jul 2022 07:40:55 +0000 (14 09:40 +0200)]
I18N: Allow translating newly added GP data names, and a missing Surface one.

6 days agoFix T99677: crash when convex hull node is used on empty mesh
Jacques Lucke [Thu, 14 Jul 2022 07:57:08 +0000 (14 09:57 +0200)]
Fix T99677: crash when convex hull node is used on empty mesh

Fundamental issue is that the attribute api returns none, because
the custom data api returns null for a layer when the size of 0.
This should be improved separately.