Commit Graph

106029 Commits

Author SHA1 Message Date
Hans Goudey
4aad32bcfe Cleanup: Fix linker error after recent cleanup
Also avoid unnecessary .c_str() calls.
2024-01-18 16:34:27 -05:00
Hans Goudey
85842b0ef3 Fix: Display newly added node in front
The ui order needs to be higher than the other nodes before the
nodes are sorted later.
2024-01-18 16:13:00 -05:00
Hans Goudey
ff657f28d0 Fix #117235: Frame node sorting sometimes incorrect
Sometimes a frame node can't be behind another because of parenting.
Comparing the two nodes with `compare_node_depth` would give that
result too, but sometimes every combination of frame node isn't tested.
In that case, the existing values of `ui_order` matter, and we should start
the sort there. So first sort based on the existing order, then do a stable
sort to fulfill the constrains coming from  selection and parenting.
2024-01-18 16:13:00 -05:00
Hans Goudey
dd0a2f3982 Cleanup: Move node transform convert file to C++ namespace 2024-01-18 16:13:00 -05:00
Hans Goudey
49078e68e3 Nodes: Avoid unnecessarily sorting nodes after transform 2024-01-18 16:13:00 -05:00
Hans Goudey
f929fb5d77 Cleanup: Store uiBlock name as std::string
And change some adjacent code to benefit from the simplicity
and constant time access to the length of the string.
2024-01-18 16:13:00 -05:00
Hans Goudey
821b077149 Fix #117272: Color property with popover causes Blender freeze
Caused by 29f3af9527, exposed by bff51ae66c.

The problem was that a `uiBut` pointer was being passed to a function
and then dereferenced as a `PanelType`. In the past, the button used to
just have zeros where the pointer was then read from, but after the
changes in the second commit, this was no longer the case.

Fix by being more explicit about the argument type, and changing the
argument from a button to the panel type for one callback. It's a bit
complex because the panel type and panel type idname are stored in
different places depending on the button type.
2024-01-18 13:57:30 -05:00
Thomas Barlow
7d77caab9b PyAPI: Add ShapeKey.points for faster foreach_get/set of Mesh shape key data
Mesh shape key data elements are always of the `ShapeKeyPoint` type and
only have a `.co` property which is stored contiguously. However, the
`.data` collection property's elements are dynamically typed because
Legacy Curve shape key data elements use a mix of `ShapeKeyCurvePoint`
and `ShapeKeyBezierPoint` elements. The necessary support for handling
the dynamic/mixed typing of the shape key data elements disables raw
access to the collection and its elements which makes `foreach_get`/
`foreach_set` slower.

`ShapeKey.points` is a new collection property whose element type is
fixed as `ShapeKeyPoint` and uses the `#rna_iterator_array_next` and
`#rna_iterator_array_get` collection functions which enable raw access
to the collection.

To complete the raw access to Mesh shape key data, the `.co` property of
`ShapeKeyPoint` also needs raw access. To accomplish this, the RNA
definition for `ShapeKeyPoint` now uses the `#vec3f` DNA struct and its
`.co` property is set to start from the `x` field of the `#vec3f` DNA
struct.

Lattice shape keys also use `ShapeKeyPoint` and also benefit from using
`.points` instead of `.data`, though Lattice objects typically have far
fewer data, such that performance is of minimal concern.

On shape keys belonging to Legacy Curves (`bpy.types.Curve`/
`bpy.types.SurfaceCurve`), `.points` will simply always be empty because
they do not have `ShapeKeyPoint` elements.

---

**Performance**

The increase in performance is specifically for foreach_get/foreach_set,
there is no noticeable performance difference to iterating through or
accessing individual elements of `.points` directly through Python, e.g.
`.points[0].co` vs `.data[0].co`.

`foreach_get` with a Python list is about 2.8 times faster.

`foreach_get` with an incompatible buffer (NumPy ndarray with np.double
dtype) is about 1.4 times faster.

`foreach_get` with a compatible buffer now scales better with larger
collections, so it is about 11.7 times faster at 100 elements and about
200.0 times faster at 100000 elements, dropping off to about 65 times faster for much larger collections.

The increase in `foreach_set` performance is slightly better than in
each `foreach_get` case, but scales the same overall.

`foreach_set` with a Python list is about 3.8 times faster.

`foreach_set` with an incompatible buffer (NumPy ndarray with np.double
dtype) is about 1.45 times faster.

`foreach_set` with a compatible buffer now scales better with larger
collections, so it is about 13.4 times faster at 100 elements and about
220.0 times faster at 100000 elements, dropping off to about 70 times faster for much larger collections.

The performance drop-off might be to do with hardware/OS specifics of `memcpy`. The drop-off occurs for me on Windows 10 with my AMD Ryzen 7 3800X at just above 1.5MiB of data copied (1572888B copied -> 200x faster, 1572900B copied -> 75x faster).

Pull Request: https://projects.blender.org/blender/blender/pulls/116637
2024-01-18 19:15:17 +01:00
Harley Acheson
6d357dc60d UI: Dialog to Insert Unicode Characters for Text Objects
Dialog box that allows the entry of any Unicode character into a 3D
Text Object string by entering its hexadecimal codepoint value.

Pull Request: https://projects.blender.org/blender/blender/pulls/116966
2024-01-18 17:59:36 +01:00
Hans Goudey
4d03de9113 Cleanup: Make format 2024-01-18 11:40:19 -05:00
Christoph Lendenfeld
0b67cc1db4 Refactor: rename function to evaluate a driver
No functional changes.

In #116823 the function `remap_driver_frame` was moved,
but the name doesn't exactly correspond to what the function is doing.

Since it evaluates the driver, with different parameters, it is now called
`evaluate_driver_from_rna_pointer`.

We could maybe remove the function because it is only called once.

Pull Request: https://projects.blender.org/blender/blender/pulls/117294
2024-01-18 17:19:15 +01:00
Miguel Pozo
b5743dcf0a Fix #117159: GPU: Specialization constants binding deleted programs
The lack of a move constructor in GLProgram was causing Map reallocations
to delete their owned shaders/programs.
2024-01-18 17:12:24 +01:00
Christoph Lendenfeld
4e0141c67f Refactor: move code from RNA to blender::animrig
No functional changes.

Moves the code recently introduced with #116815
The logic now lives in a new function called `reevaluate_fcurve_errors`

Pull Request: https://projects.blender.org/blender/blender/pulls/117290
2024-01-18 16:51:20 +01:00
Thomas Dinges
64fc6d7890 Docs: Replace most wiki links with links to new developer docs
Exceptions:
* Links to personal wiki pages
* Pages that are not in the new developer docs yet (like Human Interface Guidelines)
* tools\check_wiki\check_wiki_file_structure.py needs a refactor
2024-01-18 16:49:38 +01:00
Hans Goudey
290b417998 Cleanup: GPv3: Small tweaks to modifiers
- Fix modifier icon
- Remove unused includes
- Remove unused argument
- Change function name
- Use `eval_frame` for retrieving drawings
- Avoid unnecessary cast
- Remove unnecessary parentheses
- Declare some variables const

Pull Request: https://projects.blender.org/blender/blender/pulls/117281
2024-01-18 16:29:03 +01:00
Christoph Lendenfeld
f0f1afd250 Refactor: remove driver dependency in keying code
No functional changes expected.

Before this PR the keyframing code was aware of driver specifics
and changed the frame where a key is inserted to the current driver value.

This is now changed so that the calling code needs to know where on the
FCurve the key should be inserted. This removes the need for the
`INSERTKEY_DRIVER` flag.

Pull Request: https://projects.blender.org/blender/blender/pulls/116823
2024-01-18 15:40:07 +01:00
Omar Emara
538ace5750 Fix: GPU Directional Blur distorts input
The GPU Directional Blur node distorts the inputs if the resolution is
not square. This is because rotation is performed on normalized
coordinates. This patch performs the normalization at the texture
evaluation.
2024-01-18 16:19:44 +02:00
Germano Cavalcante
7e53fe106a Fix: Individual projection sometimes snapping to the wrong object
The code was comparing real distance to square distance, which is
obviously wrong.
2024-01-18 11:17:00 -03:00
Hans Goudey
c70a7c933f Cleanup: Make format 2024-01-18 08:46:25 -05:00
Pratik Borhade
e97d34aba6 Fix #117266: Sculpt: Initialize Face Sets not updating
Likely caused by 251069ae5b due to missing flag for updating draw buffers.

Pull Request: https://projects.blender.org/blender/blender/pulls/117273
2024-01-18 14:19:55 +01:00
Jason Fielder
11afaa8dc6 Fix #116414: EEVEE Shadow compilation macOS
Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/117278
2024-01-18 14:10:24 +01:00
Hans Goudey
83b7b729a1 Fix #114657: Store default color attribute on store if none set yet
When there is no default color attribute yet, when creating a new color
attribute with the store named attribute node, set the default. Though
we generally try to avoid this more magical behavior, there's little
downside in this case, and it's probably what users expect.

Don't set the active attribute though, since that's UI data that generally
shouldn't be changed procedurally. It's okay if there's no active color
attribute.

Pull Request: https://projects.blender.org/blender/blender/pulls/117249
2024-01-18 14:02:27 +01:00
Omar Emara
f0f073bd1f Fix: Files with Pixelate nodes have zero pixel size
Old files with the pixelate node have zero pixel sizes. This patch just
adds versioning to properly initialize the pixel size.
2024-01-18 14:39:23 +02:00
Alexander Gavrilov
b350d7a4c3 Shape Keys: support locking to protect from accidental editing.
It is very common for graphical editors with layers to support
locking individual layers to protect them from accidental edits due
to misclicks. Blender itself already supports locking vertex groups.
This adds lock toggles for shape keys, with lock/unlock all operators.

The flags are checked by sculpt brushes, edit mode transform tools,
and Smooth, Propagate and Blend From Shape operators. This selection
aims to cover operations that only deform the mesh, where the shape
key selection matters.

Topology changing operations always apply to all keys, and thus
incorrect shape key selection is less impactful. Excluding them
from the new feature greatly reduces the patch size.

Pull Request: https://projects.blender.org/blender/blender/pulls/104463
2024-01-18 13:17:24 +01:00
Alexander Gavrilov
f5602becde Shape Keys: replace the BKE_keyblock_from_key function with find_index.
The function for retrieving a shape key by its index is named
somewhat confusingly, and effectively reimplements BLI_findlink.

However, more importantly, for some reason it is coded to return
null for the index 0 instead of the basis shape key. This severely
limits its usability in some cases.

This refactor replaces the function with a simple strongly typed
wrapper around BLI_findlink, using a different name, and updating
the call sites to check that the index is not 0 where necessary.
2024-01-18 13:17:20 +01:00
Jeroen Bakker
1ba2c933b4 Fix: Compile Issue Grease Pencil 2024-01-18 13:07:09 +01:00
YimingWu
4d387843e9 GPv3: Subdivide Modifier
This ports the Subdivide modifier from GPv2.

Pull Request: https://projects.blender.org/blender/blender/pulls/117056
2024-01-18 13:02:53 +01:00
Bastien Montagne
03c1cc4310 Cleanup: Move BKE_lib_query header to Cpp era. 2024-01-18 12:21:19 +01:00
Omar Emara
feb2d02709 Realtime Compositor: Rewrite Pixelate node
This patch rewrites the pixelate node to average a window of a certain
pixel size, following the new CPU implementation.

Pull Request: https://projects.blender.org/blender/blender/pulls/117243
2024-01-18 11:52:20 +01:00
Falk David
c448fd214c Fix: ModifierTypeFlag max value
The maximum value of `ModifierTypeFlag` was not updated.
2024-01-18 11:46:10 +01:00
Omar Emara
5309d1c574 Fix: Crash in Defocus node when no camera exist
The Defocus node crashes when no camera exist in the scene. We fix this
by defaulting to a focus distance of 10 when a camera doesn't exist.
2024-01-18 12:34:55 +02:00
Sergey Sharybin
baab14ca38 Compositor: Re-write Pixelate node for CPU compositor
The old implementation was a simple rounding operation and was not
implemented for full-frame compositor.

The issue with the old implementation is that it will not give
satisfactory results for images with high frequency details,
including cases when is used for a preview on Cycles render with
low number of samples. Additionally, when applied on animated
footage it produces very noisy result.

The new algorithm uses an explicit pixel size setting, which allows
the node to be used on its own, without need to have scale-down and
scale-up nodes. It also uses neighbour averaging, which produces
better looking result during animation and noisy input images.

The old tiled compositor setup will render without changes with
this change. This commit does not include modifications in the GPU
compositor implementation.

Ref #88150

Pull Request: https://projects.blender.org/blender/blender/pulls/117223
2024-01-18 11:30:55 +01:00
Jeroen Bakker
545f2c04fa EEVEE: Skip Forward Rendering Pipeline Stages When Empty
Increase performance when drawing scenes that don't have blended materials. This should
save some CPU and GPU cycles as parts (or the whole pipeline) can be skipped.

Mostly it ensures that the hiz isn't tagged dirty and has a chance that it is being reused
by other areas. Shadows and irradiance caches aren't forced to be updated.

Mac Studio M1 Ultra
 - space_raceship.blend went from 27 fps to 33 fps (10%-20% improvement).

This is a common scenario to optimize as by default materials are not blended and require
user action to set them up. When using compositing/renderpasses, blended materials aren't
supported and most likely not being used.

Pull Request: https://projects.blender.org/blender/blender/pulls/117269
2024-01-18 11:10:03 +01:00
Omar Emara
d875e5d4cb Fix: Wrong GPU compositor assert in background mode
An assert that ensures the GPU compositor executes in a non main thread
wrongly fires in background mode, that's because in background mode,
rendering happens in the main thread. So add a condition for background
mode.
2024-01-18 11:31:59 +02:00
Christoph Lendenfeld
d08e826b24 Fix #115183: Show errors only shows errors when channels have been expanded
When enabling the "Only Show Errors" option in the Dope Sheet/Graph Editor,
it might not show anything even though there are FCurves with errors.
The issue is that the flag `FCURVE_DISABLED` is set by the drawing code,
which means the channels have to be visible first.
This creates a workflow issue where you want to filter down to only the
curves with problems, but you need to find them first...

This PR fixes the issue by validating all FCurves whenever the option
is enabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/116815
2024-01-18 10:27:12 +01:00
Campbell Barton
0192a955be Cleanup: reduce variable scope & use const values 2024-01-18 15:19:04 +11:00
Campbell Barton
12195eb6e1 PyAPI: keep the associated preference when renaming an add-on module 2024-01-18 14:53:53 +11:00
Damien Picard
8564e03cdf Fix FPS menu in "Format" panel not following translation setting
The FPS menu was using a cached value which wasn't being refreshed
when translation changed.

Add `bpy.app.handlers.translation_update_post` handler which runs
when translation changes, this can be used to clear any cached UI
values.

Ref !117049
2024-01-18 11:31:38 +11:00
Campbell Barton
d068407a00 Fix #114801: Scene.use_audio value flipped
Regression in [0] caused the value to be flipped.

[0]: e37dc17991
2024-01-18 11:01:13 +11:00
Campbell Barton
b8a340e630 UI: always return shortcuts from UI_but_string_info_get on request
Change the behavior of UI_but_string_info_get to fill in shortcuts
when requested.

Previously shortcuts were ignored for menus, because showing shortcuts
in tool-tips which are already displayed in the menu isn't needed.

Move this logic to tool-tip creation so other the shortcuts may be
accessed in other contexts.
2024-01-18 10:52:58 +11:00
Campbell Barton
a3b4078be3 Cleanup: spelling in comments 2024-01-18 10:39:24 +11:00
Campbell Barton
c48283edcb Cleanup: quiet enum conversion warning 2024-01-18 10:38:23 +11:00
Hans Goudey
633e8f09c8 Cleanup: Remove unused asset C functions
This information can be retrieved from `AssetRepresentation` now.
Also remove unnecessarily specific lambda capture. That usually suggests
usage in `std::function` with a more complex lifetime.
2024-01-17 11:13:35 -05:00
Harley Acheson
8ba7e40bb4 Revert #106653: Cleanup Dialog to Manage Orphaned Data
Reverting 58e1e88dc3 because of concerns by reviewer.

Pull Request: https://projects.blender.org/blender/blender/pulls/117241
2024-01-17 17:05:24 +01:00
Falk David
4a77cdf745 Cleanup: GPv3: Remove unused editor function 2024-01-17 16:53:56 +01:00
Falk David
f566f51f29 Cleanup: GPv3: Move curve smoothing to geometry namespace
Moves the `gaussian_blur_1D` and `smooth_curve_attribute` functions to the `geometry` namespace.

Pull Request: https://projects.blender.org/blender/blender/pulls/117238
2024-01-17 16:48:35 +01:00
Omar Emara
e4a93d7b8c Compositor: Add High Precision option to Kuwahara
For high radii Kuwahara, we use a Summed Area Table (SAT) implementation
to accelerate the classic variant of the algorithm. The problem is that
due to limited floating point precision, the SAT can produce artifacts
in its output.

An attempt to fix this was implemented in #114191, and while that patch
improved precision by 10x, the artifacts still existed, albeit less
noticeable. But since the improved precision also meant a performance
penalty, it was decided that the improvement is not worth it.

Since the artifacts are only noticeable for scenes with very high
values, this patch adds a High Precision option that defaults to false
and can be enabled by the user upon noticing any artifacts. The option
simply uses direction convolution instead of SAT in this case. The
downside, of course, is that it can be orders of magnitude slower.

An alternative to using this option is for the user to clamp the input
or downsample the image. Both methods should be documented in the
documentation.

Fixes: #113578.

Pull Request: https://projects.blender.org/blender/blender/pulls/115763
2024-01-17 14:30:29 +01:00
Pratik Borhade
1e85feb542 Fix #117161: Detectable geometry for the brush doesn't update after Undo
Caused by aaa25bc882
This seems to be due to missing flag for updating bounds

Pull Request: https://projects.blender.org/blender/blender/pulls/117192
2024-01-17 14:29:53 +01:00
Jacques Lucke
c954940e76 Fix: remove assert when creating interface socket
We don't actually protect against interface sockets with empty
names elsewhere. This assert was triggered when trying to group
a `Bake` node, because it tried to create an interface socket of
the extend socket. This case is handled by the check below.
2024-01-17 14:27:51 +01:00
Falk David
049e48b431 GPv3: Add curve plane normal cache
This adds a cache to read a normal vector for a plane that (roughly) fits a curve.
If the curve lies on a plane, the vector always point along this plane normal, otherwise it's an approximation.
The cache is lazily calculated and invalidated when the positions are tagged for a change.
2024-01-17 14:09:42 +01:00