Commit Graph

104677 Commits

Author SHA1 Message Date
Campbell Barton 115f8b0c59 Cleanup: clarify variable being iterated over, avoid shadowing 2024-03-28 13:45:20 +11:00
Hans Goudey 2d9f19c962 Cleanup: Use std::move for asset identifier construction
Pass strings by value and move their result. This gives the caller
the potential to move existing strings into the class. Moving the
std::shared_ptr should just avoid reference counting here.
2024-03-27 22:31:44 -04:00
Hans Goudey 94b985371d Cleanup: Use const in more places in mesh modifier evaluation 2024-03-27 22:25:09 -04:00
Hans Goudey b35831ad6c Mesh: Use shared cache for shrinkwrap boundary data
This is mainly to make the computation threadsafe, to allow computing
the cache on a const mesh, and also to decrease the cost of copying
meshes. Computing caches on const meshes generally makes it easier
to avoid copying meshes unnecessarily in other ways, which would be
useful for some pending fixes and cleanups to modifier evaluation.
2024-03-27 22:25:09 -04:00
Hans Goudey 278c5c9c7e Cleanup: Simplify shrinkwrap cache creation
- Use C++ Array type
- Move to blender::bke::shrinkwrap namespace
- Use edge_is_boundary instead of edge_mode in a few places
- Avoid writing to edge_mode unnecessarily
2024-03-27 22:25:09 -04:00
Hans Goudey 7c01355cad Cleanup: Use forward declaration headers in a few places 2024-03-27 22:25:08 -04:00
Hans Goudey 5d09b0d373 Cleanup: Move remaining curves editors functions to C++ namespace 2024-03-27 22:25:08 -04:00
Harley Acheson 9489173f07 Refactor: Move UI Templates and Regions into Sub-directories
Move interface_region-* files into regions/ folder, and
interface_template-* files into templates/ folder.

Pull Request: https://projects.blender.org/blender/blender/pulls/119991
2024-03-28 03:06:49 +01:00
Campbell Barton d8c69c84e3 Cleanup: correct the vector copy size in ViewOpsData::state_backup
In practice this didn't cause problems as the correct value was
written afterwards.
2024-03-28 13:01:41 +11:00
Campbell Barton a2fa743364 Cleanup: pass std::string by reference instead of value 2024-03-28 13:01:39 +11:00
Campbell Barton 8f88487768 Cleanup: pass LogImageElement by reference or pointer instead of value 2024-03-28 13:01:38 +11:00
Campbell Barton 872c997c8f Cleanup: remove redundant break & return statements 2024-03-28 13:01:37 +11:00
Campbell Barton 939e076fdc Cleanup: remove redundant assignment & null check 2024-03-28 13:01:36 +11:00
Campbell Barton 3ad1a2eb62 Cleanup: remove redundant null check 2024-03-28 13:01:34 +11:00
Campbell Barton 49dd5fae40 Cleanup: remove redundant variable & check 2024-03-28 13:01:34 +11:00
Campbell Barton 868d6eb5e8 Cleanup: quiet signed integer overflow warning from cppcheck 2024-03-28 13:01:32 +11:00
Campbell Barton 481bcc14d7 Cleanup: quiet enum conversion warning 2024-03-28 13:01:31 +11:00
Campbell Barton 618788aa7a Cleanup: remove redundant std::string / c_str conversion 2024-03-28 12:23:46 +11:00
Campbell Barton 2a892012be Render: correct buffer sizes for render cache paths
FILE_CACHE_MAX was meant to be larger than FILE_MAX to make room
for additional layers in the path. An error in the define used
`FILE_MAXFILE + FILE_MAXFILE` instead of `FILE_MAXDIR + FILE_MAXFILE`
causing the value to be smaller allowing a buffer overflow when passing
the string into BLI_path_abs.

Correct the define and call on the directory component before
the file is added so it doesn't clamp the string length unnecessarily.

Note that some values weren't correct since the original commit [0],
although [1] moved them to a shared incorrect define.

[0]: 78cdc707ab
[1]: cef1b9c30f
2024-03-28 12:12:05 +11:00
Campbell Barton db466e9578 Fix buffer overflow from passing undersized buffers to BLI_path_abs 2024-03-28 11:40:50 +11:00
Campbell Barton da49873e89 Fix buffer overflow with BLI_str_format_uint64_grouped
Caused by cd4328dd82.
2024-03-28 11:40:23 +11:00
Campbell Barton 0d3ea69daa Fix sizeof(sizeof(...)) passed to BLI_path_slash_ensure
Regression in [0] which would cause ensuring the slash to do nothing
in most cases. Note that the slash may not be needed, but that should
be handled separately.

[0]: d66f24cfe3
2024-03-28 11:40:21 +11:00
Hans Goudey c28db1f0a0 Cleanup: Use C++ namespace for object editors module
Move the public functions from the editors/object (`ED_object.hh`)
header to the `blender::ed::object` namespace, and move all of the
implementation files to the namespace too. This provides better code
completion, makes it easier to use other C++ code, removes unnecessary
redundancy and verbosity from local uses of public functions, and more
cleanly separates different modules.

See the diff in `ED_object.hh` for the main renaming changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/119947
2024-03-28 01:30:38 +01:00
Hans Goudey 35c6c11c7e Cleanup: Make format 2024-03-27 20:20:07 -04:00
Hans Goudey aae9446599 Cleanup: Remove unnecessary "using namespace"
This file is in the blender namespace already
2024-03-27 20:19:23 -04:00
Hans Goudey fc06dc31d8 Cleanup: Sort forward declaration lists, remove duplicate 2024-03-27 20:19:23 -04:00
Hans Goudey 0bde788d63 Cleanup: Use "All" asset library to simplify node link drag search
The "All" library didn't exist internally when this code was first
written. The "skip_local" check that complicated this isn't necessary
because we don't add local node groups that aren't assets anyway.
2024-03-27 20:19:23 -04:00
Campbell Barton ed5cca4021 Cleanup: quiet missing-declarations warnings 2024-03-28 08:48:03 +11:00
Campbell Barton cd0b0a9272 CMake: remove non-existing include directory
As of [0] this is no longer created.

[0]: f5f7024040
2024-03-28 08:48:02 +11:00
Harley Acheson c433a90138 UI: Minimum Width for Large Confirmation Dialogs
We currently have a single minimum width value for confirmation
dialogs, but we need to set this based on which of the two sizes it
is. Otherwise the larger confirmations with icon look too squished
when the content is shorter.

Pull Request: https://projects.blender.org/blender/blender/pulls/119978
2024-03-27 22:28:00 +01:00
Habib Gahbiche 8377f5d0fb Fix: Compositor GPU backdrop not updating when image transform operators are applied
How to reproduce:
- Have image editor and GPU compositor backdrop enabled and showing the same image
- In image editor, apply operator flip horizontally
- Notice how image editor gets updated but compositor backdrop doesn't

Fixes backdrop for GPU compositor for the following operations:
- image -> transform -> Flip horizontally
- image -> transform -> Flip vertically
- image -> transform -> Rotate 90° clockwise
- image -> transform -> Rotate 90° counter-clockwise
- image -> transform -> Rotate 180°

Pull Request: https://projects.blender.org/blender/blender/pulls/119819
2024-03-27 21:42:47 +01:00
Habib Gahbiche e1a0b6cd9e Fix compositor backdrop not updating for image invert operator
How to reproduce:
- Have image editor and GPU compositor backdrop enabled and showing the same image
- In image editor, apply inver image colors operator
- Notice how image editor gets updated but compositor backdrop doesn't

Fixes backdrop updates for GPU compositor for the following operators:
- Image -> Invert -> Invert image colors
- Image -> Invert -> Invert red channel
- Image -> Invert -> Invert green channel
- Image -> Invert -> Invert blue channel
- Image -> Invert -> Invert alpha channel

Pull Request: https://projects.blender.org/blender/blender/pulls/119820
2024-03-27 21:41:25 +01:00
Jonas Holzman 75a9cbed24 UI: Improvements to Revert File Operator Confirmation Popup
Larger, more informative confirmation when reverting the current file
to saved version. Title of "Revert to the Saved File", content of
"Any unsaved changes will be lost." and button text of "Revert".

Pull Request: https://projects.blender.org/blender/blender/pulls/119758
2024-03-27 18:39:09 +01:00
Hans Goudey 10bc136a1a Fix #119935: Attribute set operator support for 2D integer vector lost
Also fix the poll to properly check for the remaining unsupported types.
Don't add back Quaternion support, since that's arguably less useful,
and we might want different ways to set those values compared to
just entering WXYZ.
2024-03-27 13:14:02 -04:00
Brecht Van Lommel 8682ad1908 Fix: Memory leak and race condition with particle effector RNG
Store RNG on per thread data, instead of the effector itself which may
be used by multiple objects evaluated in different threads.

This has been causing the blendfile_versioning test to fail randomly.
Thanks Ray and Aras for helping track this down.

Pull Request: https://projects.blender.org/blender/blender/pulls/119967
2024-03-27 18:06:31 +01:00
Harley Acheson 1984f08250 Fix #119846: EEVEE-Next: Rendering Infinite Samples
When rendering images, and not in the interactive viewport, do not
use infinite samples. Follow the  behavior of Legacy EEVEE.

Pull Request: https://projects.blender.org/blender/blender/pulls/119893
2024-03-27 16:16:34 +01:00
Germano Cavalcante 3031146097 Fix #119957: Crash when using 'angle constraint' Relative in Knife tool
Most likely caused by 6d491da0be

In that commit, `knife_pos_data_clear` started to clear (set `-1`) the
value of the current object (which is expected).

However, `knife_snap_angle_relative` relies on the current object to
transform the face normal to global space.

This is weak and error prone since the face is obtained from the
function itself.

The code could be optimized and reuse the face identified in
`knife_snap_curr`, but for now just identify the face object.
2024-03-27 10:55:38 -03:00
Sergey Sharybin 896b552672 Fix: Unable to change ID property type to Boolean
Caused by 0cdd429b44.

Steps to reproduce:
- Add a custom property to the default Cube object
- Open property editor
- Change type to Boolean
- Apply the changes

Observe that the property is still Int.

On a code side the issue is caused by the change in the idp_from_PyBool()
which used to return property of type IDP_BOOLEAN before the change, but
IDP_INT after the change.

Pull Request: https://projects.blender.org/blender/blender/pulls/119962
2024-03-27 13:43:00 +01:00
Germano Cavalcante f0479e915f Transform: Implement Snap to Grid mode
Addresses two improvements to `Snap to Grid` as suggested in #73993:
- Make 'Absolute Grid Snapping' a new Snap Mode
- Snap to Grid in Non-Side View performed at ground level

Implementation details:

- Snap to Grid has no cursor symbol, unless we are in `Set Snap Base`
  mode. Similar to the previous 'Absolute Grid Snap' behavior.
- In Non-Side view, Snap to Grid is performed at ground level.
- If `Snap Base` is `Closest`, Snap to Grid uses the transform pivot
  point instead. Similar to the previous 'Absolute Grid Snap' behavior.
- The "Absolute Grid Snap" option has been removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/116109
2024-03-27 13:17:24 +01:00
Pratik Borhade b3fe97414a Fix: Sculpt paint crash after converting active color attribute
Painting after converting active color attribute in sculpt mode causes crash.
Fix is same as 3641b4b884 with some cleanup

Pull Request: https://projects.blender.org/blender/blender/pulls/119780
2024-03-27 12:28:16 +01:00
Omar Emara 0709c07d04 Cleanup: Use actual class instead of base class
Use the TranslateCanvasOperation class in the declaration instead of its
TranslateOperation class. This is just to clarify the code when reading
it.
2024-03-27 12:54:42 +02:00
Omar Emara 4d9678c483 Fix: Sun Beams node is off by half a pixel
The Sun Beams node is off by half a pixel. That's because we add a half
pixel offset to the initial coordinates, but then sample the texture
with the half pixel. To fix thus, use the texture_bilinear_extend
utility to sample the image, which takes care of the half pixel offset.
2024-03-27 12:49:21 +02:00
Sergey Sharybin e9dc9ef9a2 Fix #119936: Crash selecting in mask editor
Regression since 7a2d04a5c4.

Mask evaluation is part of parameters component, and there is no explicit
tags other than copy-on-eval for masks in a lot of cases.

Restore the previous graph topology for the link from copy-on-eval to the
parameters components of mask ID.

Potential candidate for 4.1.1.

Pull Request: https://projects.blender.org/blender/blender/pulls/119956
2024-03-27 11:00:55 +01:00
Omar Emara 5ae5614d1e Fix: Chroma Key differs from reference implementation
The GPU compositor Chroma Key node differs from the reference
implementation. This is caused by a typo, where the acceptance angle was
halved after computing tangent instead of before computing it.
2024-03-27 11:10:49 +02:00
Omar Emara 9aa63aa1e8 Fix: Lens Distortion node is off by half a pixel
The Lens Distortion node is off by half a pixel because their normalized
coordinates were at the pixel corners as opposed to their centers, where
this patch changes the behavior to the latter.
2024-03-27 09:04:34 +02:00
Omar Emara aa208d3d18 Fix: Plane Deform nodes are off by half a pixel
The Plane Track and Corner Pin nodes are off by half a pixel because
their mask is computed at the pixel corners as opposed to their center,
where this patch changes the behavior to the latter.
2024-03-27 08:54:04 +02:00
Omar Emara 7113692206 Fix: Directional Blur node is off by half a pixel
The Directional Blur node is off by half a pixel because it transforms
the pixels at their corner as opposed to their center, where this patch
changes the behavior to the latter.
2024-03-27 08:50:44 +02:00
Omar Emara 6df333a3c7 Fix: Movie Distort node is off by half a pixel
The Movie Distort node is off by half a pixel because it evaluates the
distortion at the corner of pixels as opposed to their center, where
this patch changes the behavior to the latter.
2024-03-27 08:47:07 +02:00
Jonas Holzman 913acaf395 Fix #86325: tilted viewport orientation in default startup
Since v2.5 Blenders viewport view has been tilted by around ~0.8
degrees to the right, resolve this using a lookup table to update
the the defaults.

Ref !113751
2024-03-27 17:13:02 +11:00
Campbell Barton e078112a53 Fix notifiers from window events using the wrong window
The active window in the context may not match the window where GHOST
events are generated. Notifiers for new windows would always be ignored
with the context's window set to null for example.

Noticed while investigating #119871.
2024-03-27 15:04:03 +11:00
Campbell Barton 2a25340da4 Cleanup: quiet missing-declarations warnings 2024-03-27 14:53:58 +11:00
Hans Goudey 7f25242089 Cleanup: Move object mode switching declarations to proper modules
Keep each function's declaration in the header file associated with its
module. Arguably mode switching should be more organized, but for now
it's better to just declare functions in more predictable places.
2024-03-26 23:45:43 -04:00
Hans Goudey 436c0a773e Cleanup: Remove object vgroup functions to proper header
These functions were declared in the editors/mesh module but
defined in the editors/object module. This commit moves them to
a separate header associated with the object editors module.
2024-03-26 23:45:43 -04:00
Hans Goudey 148940ad15 Cleanup: Remove unnecessary keywords from newly C++ headers
Pull Request: https://projects.blender.org/blender/blender/pulls/119943
2024-03-27 02:45:30 +01:00
Hans Goudey b8b745ae1e Cleanup: Move remaining editors internal headers to C++ 2024-03-27 02:45:27 +01:00
Hans Goudey acd1b0b7f9 Refactor: Use C++ Vector for RNA/context collection retrieval
Previously retrieving a collection from the context like "selected_ids"
would give a linked list of allocated items. Now it returns a vector of
RNA pointers. Though the number of items is typically fairly small,
using contiguous memory and avoiding many small allocations are
typical performance improvements that could still be beneficial
when there are many items. Iteration also becomes much simpler.

Pull Request: https://projects.blender.org/blender/blender/pulls/119939
2024-03-27 00:47:39 +01:00
Campbell Barton 3416fe6e1e License headers: add SPDX headers 2024-03-27 10:31:24 +11:00
Campbell Barton 40ab214c0a Cleanup: spelling in comments 2024-03-27 10:25:31 +11:00
Campbell Barton d6c4433451 Cleanup: remove declarations for removed functions 2024-03-27 10:23:53 +11:00
Campbell Barton 3f594f7b2f Cleanup: consistent naming for EditMesh::looptris elements
Use the term `ltri` everywhere.
2024-03-27 10:09:12 +11:00
Campbell Barton 2220696d25 BMesh: avoid copying by value for BMLoop triangles
Caused by [0] which made BMLoop[3] variables & arguments copy by value.

[0]: 3805974b6f
2024-03-27 10:09:10 +11:00
Hans Goudey f2c5cae3d8 Cleanup: Remove unused RNA function call functions
These functions appear to have been unused for the last 15 years.
They are quite complex with the var_args handling, and may get in
the way of some other cleanups in the area.
2024-03-26 18:12:21 -04:00
Hans Goudey e1c54d5a24 Fix: Windows build error after recent cleanup commit 2024-03-26 16:20:40 -04:00
Hans Goudey cd76d06f95 Cleanup: Use boolean instead of int 2024-03-26 16:04:03 -04:00
Hans Goudey c72d6100ba Cleanup: Remove unrelated change added in previous commit
WIP change unrelated to anything else. Sorry for the noise!
2024-03-26 16:00:00 -04:00
Hans Goudey 48e4576162 Cleanup: Remove unnecessary keywords from C++ headers 2024-03-26 15:58:39 -04:00
Hans Goudey 265bfdb019 Cleanup: Resolve allocation size warning in Hook modifier RNA
GCC seems to complain about a possible signed to unsigned conversion
in combination with allocation and copying here.
2024-03-26 15:43:12 -04:00
Hans Goudey 0cdd429b44 Cleanup: Use newer API for creating IDProperties in most places
There are still a few places that are more complicated where the replacement
to `IDP_New` isn't obvious, but this commit replaces most uses of the ugly
`IDPropertyTemplate` usage.
2024-03-26 15:39:39 -04:00
Hans Goudey e0567eadbd Cleanup: Use FunctionRef for IDProperty iteration callback
Avoid the need for a seaprate user_data argument.
2024-03-26 15:39:39 -04:00
Clément Foucault 2a600b4a83 EEVEE-Next: Shadow: Limit view per shadow map projection
This limits the number of tilemaps per LOD that can be fed to avoid the
easy to hit "Too many shadow updates" (#119757).

This allows for a max 64 tilemaps to be updated at once at their lowest
requested LOD (so ~10.6667 point lights if every faces of the punctual
shadow map is needed, but likely more in practice).

Unfortunately this is still quite low and will surely be hit quite soon
with directional shadow added to it. One idea to workaround this would
be to time slice the update of some lights, but this opens a whole can
of worms that I'm not ready to open for now so I created #119890 for
future reference.

Some notes, most lights seems to request around 3 LODs. It might help
to allow requesting at least 2 LODs if we are rendering since volumes
might want lower LOD available for volumes.

I added a very simplistic heuristic that also lowers the max tilemaps
when transforming, animation playback or navigating the 3D view to
improve the responsiveness of the engine. Note that this doesn't
only lowers the resolution to the minimum requested one. So it should
be good enough in most cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/119889
2024-03-26 20:33:31 +01:00
Sean Kim 627ec2666b Cleanup: Add doxygen and restructure paint_hide.cc
This PR restructures the flow of `paint_hide.cc` and groups the
existing functions into newly added doxygen blocks.

Pull Request: https://projects.blender.org/blender/blender/pulls/119929
2024-03-26 20:19:54 +01:00
Guillermo Venegas 8b6a21c122 IO: Use FileHandlers in the View 3d
Use File Handlers to handle file drag-n-drop in the View 3d. Drop-boxes
still remain since they handle Texture ID drag-n-drop.

This will add-ons to handle drag-n-drop for images and movies while
still providing access to Blender's native support since File Handlers
let users choose which to invoke if there's multiple configured.

Pull Request: https://projects.blender.org/blender/blender/pulls/117728
2024-03-26 20:01:08 +01:00
Sean Kim 5a1bab39d2 Cleanup: Remove modal definition for PAINT_OT_visibility_invert
This PR removes the modal callback for `PAINT_OT_visibility_invert`.
It does not use the provided data, nor is the `modal` function
invoked by a corresponding `invoke`.

Pull Request: https://projects.blender.org/blender/blender/pulls/119930
2024-03-26 19:43:06 +01:00
Hans Goudey efee753e8f Cleanup: Move BKE_idprop.h to C++ 2024-03-26 13:07:04 -04:00
Hans Goudey f41ab9abc1 Cleanup: Combine BKE_idprop C and C++ headers
In preparation for moving the whole BKE_idprop.h to C++.
To keep the git history intact we remove the newer smaller file.
2024-03-26 13:07:04 -04:00
Sean Kim 881178895b Sculpt: Add fast solver option for trim operations
This PR introduces the ability for users to switch between boolean
solvers while using the sculpt *Trim* tools (*Box Trim* & *Lasso Trim*)
much like the mesh boolean modifier and geometry node. Because the
*Exact* solver has performance issues with larger meshes, the *Fast*
solver is set to be the default.

In my very rough timing tests on my laptop on a mesh with **1.7m**
vertices, a *Trim* operation with the *Fast* solver finishes in roughly
20 seconds as opposed to still being in progress after five minutes
with the *Exact* solver.

Addresses part of #84229

Pull Request: https://projects.blender.org/blender/blender/pulls/119699
2024-03-26 17:25:06 +01:00
Hans Goudey b4b74c8da6 Cleanup: Simplify object data iteration in shade smooth operator
Use a Set instead of the `LIB_TAG_DOIT` flag.
2024-03-26 11:37:05 -04:00
Falk David f8ef2b3e78 Curves: Add `simplify_curve_attribute` function
Compute an index masks of points to remove to simplify the curve attribute using the Ramer-Douglas-Peucker algorithm.

The Ramer-Douglas-Peucker algorithm finds a set of points in a polyline to remove so that the overall shape of the polyline is similar. How similar can be controlled by the distance `epsilon`.

The function takes a `GSpan` so it can be used with any attribute (that has a type `float`, `float2`, or `float3`).

Pull Request: https://projects.blender.org/blender/blender/pulls/118560
2024-03-26 15:28:11 +01:00
Aras Pranckevicius 3663c8147c Vulkan: implement support for compressed textures
Textures that are GPU-compressed already (in practice: from DDS files
that are DXT1/DXT3/DXT5 compressed) now can stay GPU compressed
in Vulkan, similar to how that works on OpenGL.

Additionally, fixed lack of mipmaps in Vulkan textures. The textures
were created with mipmaps (good), the sampler too (good), but
the vulkan image view was always saying "yo, this is mip 0 only"
because mip range variables were never set to anything than zero.

Pull Request: https://projects.blender.org/blender/blender/pulls/119866
2024-03-26 14:49:53 +01:00
Jacques Lucke 4cdc62044e BLI: fix fixed-width-int to string conversion 2024-03-26 14:25:33 +01:00
Sergey Sharybin d3504a6bab Fix #119907: Active curve vertex/spline not visualizing properly
A regression caused by 7a2d04a5c4.

The offending commit made it so selection tag does not imply parameters
update, which also avoids transitive re-evaluation of the curve geometry.
However, the active curve index is stored on a Curve, and curve modifier
stack creates a copy of the curve to hold the evaluation results, which
makes it so evaluated curve object does not intrinsically share the active
spline index.

This change makes it so changes in selection triggers geometry evaluation
on curves, matching the behavior prior to the offending commit.

AN ideal fix would somehow avoid such geometry re-evaluation, but it would
be a bigger change, not suitable for possible corrective release.

Potential candidate for 4.1.1.

Pull Request: https://projects.blender.org/blender/blender/pulls/119918
2024-03-26 13:58:55 +01:00
Campbell Barton 9c3eceb8c8 BKE_reports: only print a single newline after each report
Printing reports was printing 2x newlines afterwards.

This caused a blank line to be printed when any operator reported info.
2024-03-26 23:00:59 +11:00
Jeroen Bakker e811785f37 Vulkan: to_string for used vulkan types
Every vulkan installation has a vk.xml file containing the vulkan specification
in a machine readable fasion.

This PR uses the vk.xml to generate to_string functions for data types blender uses.
When updating to a new specification or when changing features/extensions we
should re-generate the to_string functions.

The generator is implemented in `vk_to_string.py`.

Pull Request: https://projects.blender.org/blender/blender/pulls/119880
2024-03-26 11:35:16 +01:00
Omar Emara df9b3d35a2 Fix: Compositor retains old images
The compositor does not correctly free, wrap, or allocate images. That's
because the resetting mechanism didn't reset all members. This patch
rests all members and only retains the important ones.
2024-03-26 12:32:36 +02:00
Sietse Brouwer a02b429324 Fix: GPv3: Layer settings not copied when duplicating a layer
Pull Request: https://projects.blender.org/blender/blender/pulls/119821
2024-03-26 11:01:00 +01:00
Sietse Brouwer ab84f9eaf0 Fix: GPv3: The 'Use Masks' switch is always enabled for new layers 2024-03-26 10:59:08 +01:00
Sietse Brouwer 76c164e0ad Fix: GPv3: Blend mode not initialized when adding a new layer 2024-03-26 10:59:08 +01:00
Philipp Oeser b8bd762714 Fix #112618: many Outliner operators crash running without a region
This could happen when e.g. overriding context with just the area.

Now add poll functions that check for an active region when running
operators that require a region.

The fix is similar to 72688791dc

Alternatively, we could have a fix similar to a8892c7264 (getting the
correct region from the area), this would require less setup by
scripters, however for some operators the usage of the region is a
little further down the line, so implementation would be a bit more
involved. Also: for some of the operators, this would have to be done in
both `invoke` and `exec` (so would be more duplicate code changes).

Pull Request: https://projects.blender.org/blender/blender/pulls/119696
2024-03-26 09:30:47 +01:00
Campbell Barton 155dae94d7 Cleanup: code-comments, use doxygen formatting & spelling corrections
Also move some function doc-strings from the implementation
to their declarations.
2024-03-26 17:55:20 +11:00
Omar Emara 6d7b4e049e Compositor: Refactor backdrop offset
This patch refactors the backdrop offset to be stored as a float instead
of an int and to be stored in the image runtime structure instead of the
image itself.

Pull Request: https://projects.blender.org/blender/blender/pulls/119877
2024-03-26 07:49:33 +01:00
Campbell Barton 666ec966b9 Docs: improve code-comments for setup_app_data 2024-03-26 15:49:38 +11:00
Campbell Barton 099ff1a953 Cleanup: various non-functional C++ changes 2024-03-26 15:29:11 +11:00
Hans Goudey fc0d8ba012 Cleanup: Remove C++ ifdef checks in C++ headers
Pull Request: https://projects.blender.org/blender/blender/pulls/119900
2024-03-26 04:56:03 +01:00
Hans Goudey 893130e6fe Refactor: Remove unnecessary C wrapper for GPUBatch class
Similar to fe76d8c946

Pull Request: https://projects.blender.org/blender/blender/pulls/119898
2024-03-26 03:06:25 +01:00
Jacques Lucke 7314c86869 BLI: add fixed width integer type
This is intended to be used in the new exact mesh boolean algorithm by @howardt.
The new `BLI_fixed_width_int.hh` header provides types like `Int256` and
`UInt256` which are like e.g. `uint64_t` but with higher precision. The code
supports many different integer sizes.

The following operations are supported:
* Addition
* Subtraction
* Multiplication
* Comparisons
* Negation
* Conversion to and from other number types
* Conversion to and from string (based on `GMP`)

Division is not implemented. It could be implemented, but it's more complex and
is not required for the new mesh boolean algorithm.

Some alternatives to having a custom implementation have been discussed in
https://devtalk.blender.org/t/fixed-length-multiprecision-arithmetic/29189/.

Generally, the implementation is fairly straight forward. The main complexity is
the addition/multiplication algorithm which isn't too complicated. It's nice to
have control over this part as it allows us to optimize the code more if
necessary. Also, from what I understand, we might be able to benefit from some
special cases like multiplying a large integer with a smaller one.

I tried some different ways to optimize this already, but so far the normal
compiler optimization turned out to work best. Not sure if the same is true on
windows though, as it doesn't have native support for an `int128` which helps
the compiler understand what I'm doing. Alternatives I tried so far are using
intrinsics directly (mainly `_addcarry_u64` and similar), writing inline
assembly manually and copying the assembly output from the compiler. I assume
the assembly implementation didn't help for me because it prohibited other
compiler optimizations.

Pull Request: https://projects.blender.org/blender/blender/pulls/119528
2024-03-25 23:39:42 +01:00
Hans Goudey 1681e55114 Geometry Nodes: Add 8-bit integer attribute type to store attribute node
We already expose two other types that don't have a directly
corresponding socket type-- float2 and byte colors. This also solves
the inability to write to the nurbs_order attribute in geometry nodes.

Fixes #119843

Pull Request: https://projects.blender.org/blender/blender/pulls/119879
2024-03-25 23:04:11 +01:00
Hans Goudey ef22826a3c Cleanup: Remove non-creatable option for builtin attributes
This was necessary when attributes were stored embedded in legacy
structs like `MPoly`. Nowadays that isn't the case anymore, and there
doesn't seem to be a reason to restrict the creation of attributes.
2024-03-25 17:05:39 -04:00
Hans Goudey a6d4845899 Merge branch 'blender-v4.1-release' 2024-03-25 16:58:33 -04:00
Hans Goudey ccb416322c UI: Add XYZ labels to Set Curve Normal node vector input 2024-03-25 16:58:29 -04:00
Hans Goudey aa9bfc1b2a Fix: Uninitialized attribute memory read after recent commit
update_on_change_ shouldn't be called when creating an attribute but
not setting the array values. In that case it is UB to not set the values
elsewhere anyway, and that will cause its own update tag.
2024-03-25 16:58:21 -04:00
Hans Goudey 40a5e739e2 Fix #119873: Bake node crash with instanced light objects
4d0936c7d7 explicitly avoids turning non-geometry object
instances into geometry instances. This code is called to prepare
geometry sets for baking, and baking currently assumes that the baked
instances are always geometry sets.

To fix this, just check the instance type and serialize an empty
geometry set for the crashing object instance case. Compared to before
the crash causing commit, there is no change in behavior, since that
would have created empty geometry sets too.

Pull Request: https://projects.blender.org/blender/blender/pulls/119892
2024-03-25 21:42:07 +01:00
Hans Goudey 04bcd17dc8 Cleanup: Remove unnecessary builtin attribute provider logic
All builtin attributes are now stored as named attributes, so the old
code path from where they were stored with non-generic types can be
removed. The stored type and attribute type don't have to be tracked
separately anymore either.
2024-03-25 16:01:36 -04:00
Hans Goudey 11afa15361 Revert "Fix #119508: Missing update after "Shade Flat" operator"
This reverts commit 130701763b.

73cc27b988 made this unnecessary.
2024-03-25 15:50:27 -04:00
Hans Goudey 73cc27b988 Fix #119886: Set curve node missing normals update tag
The change to use generic "capture field on geometry" utilities for this
node and other nodes like it means `AttributeWriter` with its update
tagging isn't being used anymore, the attribute is just being created
with the new values (for some cases anyway). To fix this, call the
attribute provider's update function when creating the attribute too.
This was noted as useful in 130701763b too.

The initialization of curve and point cloud runtime structs is moved
because they now have to be allocated before any attributes are added.
2024-03-25 15:49:25 -04:00
Sergey Sharybin 565dc1f22b Merge branch 'blender-v4.1-release' 2024-03-25 18:15:05 +01:00
Sergey Sharybin 6c74d4af15 Fix #118555: Occasional incorrect compositor result with relative transform
In the tiled compositor ensure_delta() can be called from multiple threads,
but without any threading synchronization. This worked fine when the node
only supported absolute transform: multiple threads would do the same work
and assign delta to the same values.

With the addition of relative transform in #115947 a code which adjusts
previously calculated delta was added, leading to possible double-applying
relative transform.

The solution is to avoid multiple threads modifying the same data by using
a double-locked check.

This issue does not happen in 4.2 (main branch) because it switched to full
frame compositor, which works differently.

Pull Request: https://projects.blender.org/blender/blender/pulls/119883
2024-03-25 18:13:38 +01:00
Thomas Dinges 26caa18173 Release: Bump to 4.1 release 2024-03-25 18:08:02 +01:00
Sybren A. Stüvel 5ff8738dce Cleanup: Anim, reduce indentation in ANIM_animdata_filter
Return early if possible, reducing cognitive complexity.

No functional changes.
2024-03-25 15:26:27 +01:00
Jacques Lucke 6b5a97170c Geometry Nodes: allow overriding bake settings on overridden object
Previously, the bake settings in geometry nodes were not
editable even though they were stored on the overridden
object (instead of the not-overridden but linked node tree).

Pull Request: https://projects.blender.org/blender/blender/pulls/119874
2024-03-25 14:58:45 +01:00
Charles Wardlaw 23fab6b6a6 Fix #99114: USD: Cache file operators now recognize USD as well as Alembic
USD files are now findable from the cachefile.open() and
cachefile.layer_add() operators.  Removed the ".abc" appending when
looking for a file for the first time, as it no longer makes sense.

Pull Request: https://projects.blender.org/blender/blender/pulls/118685
2024-03-25 14:50:59 +01:00
Hans Goudey aede88be85 Fix: Curves NURBS order attribute validate incorrect clamp 2024-03-25 09:28:53 -04:00
Omar Emara fa3e47523e Compositor: Port GLSL SMAA to CPU compositor
This patch ports the GLSL SMAA library to the CPU compositor in order to
unify the anti-aliasing behavior between the CPU and GPU compositor.
Additionally, the SMAA texture generator was removed since it is now
unused.

Previously, we used an external C++ library for SMAA anti-aliasing,
which is itself a port of the GLSL SMAA library. However, the code
structure and results of the library were different, which made it quite
difficult to match results between CPU and GPU, hence the decision to
port the library ourselves.

The port was performed through a complete copy of the library to C++,
retaining the same function and variable names, even if they are
different from Blender's naming conversions. The necessary code changes
were done to make it work in C++, including manually doing swizzling
which changes the code structure a bit.

Even after porting the library, there were still major differences
between CPU and GPU, due to different arithmetic precision. To fix this
some of the bilinear samplers used in branches and selections were
carefully changed to use point samplers to avoid discontinuities around
branches, also resulting in a nice performance improvement. Some slight
differences still exist due to different bilinear interpolation, but
they shall be looked into later once we have a baseline implementation.

The new implementation is slower than the existing implementation, most
likely due to the liberal use of bilinear interpolation, since it is
quite cheap on GPUs and the code even does more work to use bilinear
interpolation to avoid multiple texture fetches, except this causes a
slow down on CPUs. Some of those were alleviated as mentioned in the
previous section, but we can probably look into optimizing it further.

Pull Request: https://projects.blender.org/blender/blender/pulls/119414
2024-03-25 14:21:00 +01:00
Omar Emara 4971b144a4 Compositor: Unify sRGB to Linear between CPU and GPU
This patch unifies the sRGB to Linear color space conversion between the
CPU and GPU compositors. This is because CPU uses an optimized path that
produces values that are very slightly off. To fix this, for the GPU, we
do the conversion CPU side instead of doing it in a shader. Since images
are cached, the performance implications are not significant.

Another added benefit is that we no longer get differences due to the
order of alpha pre-multiplication and sRGB conversion, demonstrated in
#114305. And we no longer require any preprocessing of the images.

This patch adds some new utilities to the Image Buffer module to assign
float, byte, and compressed buffers along with their color spaces. It
also adds an ownership flag to compressed data. Those were added as a
way to facilitate the implementation.

Pull Request: https://projects.blender.org/blender/blender/pulls/118624
2024-03-25 14:09:54 +01:00
Pratik Borhade 209db414e0 Fix #119860: Undo crash in asset browser poll function
`asset_lib` is null when calling undo in active file browser space.
This causes crash in `asset undo poll`. So exit out of the poll function
when active file space is filebrowser.

Pull Request: https://projects.blender.org/blender/blender/pulls/119870
2024-03-25 14:00:38 +01:00
Pratik Borhade f6190dcf9f Merge branch 'blender-v4.1-release' 2024-03-25 18:28:23 +05:30
Pratik Borhade 436b9a5aae Fix #119862: poly build crash when adding first vertex in empty geometry
object_index is not found (-1) when all mesh data is deleted hence it
crashes when accessing base from the vector at index -1.
So skip the further execution to prevent crash.

Pull Request: https://projects.blender.org/blender/blender/pulls/119865
2024-03-25 13:55:57 +01:00
Germano Cavalcante f66cb1e635 UI: rename 'Snap With' and 'Snap To' to 'Snap Base' and 'Snap Target'
Since the `Set Snap Base` feature has been implemented, it would be
convenient to reflect the use of the term `Snap Base` in other areas in
the UI.

Pull Request: https://projects.blender.org/blender/blender/pulls/119723
2024-03-25 13:35:52 +01:00
Hans Goudey b1c85fa78c Fix: Python import error for GPUVertBuf
Caused by fe76d8c946
2024-03-25 08:10:48 -04:00
Campbell Barton ab93a426a0 Fix assert from recent cleanup
Change from [0] didn't account for edit-meshes without faces.

[0]: 3805974b6f
2024-03-25 22:28:53 +11:00
Pratik Borhade 2e8259e4d4 GPv3: Clean loose points in draw mode menu
Include `clean loose` operator in draw mode menu.
And move this operator inside `Cleanup menu` (same as GPv2)

Pull Request: https://projects.blender.org/blender/blender/pulls/119782
2024-03-25 12:17:03 +01:00
Aras Pranckevicius 26337b9fb4 Metal: implement support for compressed textures
Noticed lack of it via #119793. Now DDS images using BC1/BC2/BC3
(aka DXT1/DXT3/DXT5) formats can keep on being GPU compressed
on Metal too, just like e.g. on OpenGL.

Pull Request: https://projects.blender.org/blender/blender/pulls/119835
2024-03-25 11:40:20 +01:00
Sergey Sharybin 7e2d54e786 Fix: Assert when exiting Metal rendered viewport
This commit fixes the following assert:
  mtl_command_buffer.mm:165, submit(), at 'MTLBackend::get()->is_inside_render_boundary()'

It happens when toggling rendered state of viewport on macOS, and is
caused by incorrect order of setting active GPU context to null and
calling GPU_render_end.

This change makes the flow of GPU_render_{beign, end} and GPU context
activation closer to what it is in the draw manager's functions
DRW_render_context_{enable, disable}.

Pull Request: https://projects.blender.org/blender/blender/pulls/119868
2024-03-25 11:28:28 +01:00
Sybren A. Stüvel 8f015d3bfc Modeling: Merge Vertices, correct spelling of report
Fix the "Merge Vertices" report, replacing "vertice(s)" with either
"vertex" or "vertices". The singular "vertice" is not a word in English,
and thus the regular "append (s)" approach is incorrect.

Pull Request: https://projects.blender.org/blender/blender/pulls/119863
2024-03-25 10:18:13 +01:00
Lukas Stockner 05a9f96446 Fix: Add missing callback reset in RE_InitRenderCB
This caused an ASan abort while looking into #101993.

From what I can tell, the issue is that when you click the render button on
the Render Layer node, RENDER_OT_render sets the callback. Then, when you
hit F12 later, it reuses the Render from before, including the callback,
but the corresponding handle has been freed already.
2024-03-25 01:38:55 +01:00
Harley Acheson b545770f5c UI: Adjustments to Minimum Area Sizes
When areas are dragged very small we want the (visual) vertical minimum
to equal header height, and the horizontal minimum to be equal to the
Properties nav area width. This PR just makes these adjust correctly
with changes of resolution scale and line width.

Pull Request: https://projects.blender.org/blender/blender/pulls/119848
2024-03-24 19:40:18 +01:00
Hans Goudey b54d9875ba Fix: Another Metal build error after recent refactor
Sorry for the noise, I misread the output from the PR build.
2024-03-24 13:24:03 -04:00
Hans Goudey aa87b747c5 Fix: Additional macOS metal build error 2024-03-24 12:37:36 -04:00
Hans Goudey e201b5e553 Fix: Debug build error after previous commit 2024-03-24 12:17:44 -04:00
Hans Goudey fe76d8c946 Refactor: Remove unnecessary C wrappers for vertex and index buffers
Now that all relevant code is C++, the indirection from the C struct
`GPUVertBuf` to the C++ `blender::gpu::VertBuf` class just adds
complexity and necessitates a wrapper API, making more cleanups like
use of RAII or other C++ types more difficult.

This commit replaces the C wrapper structs with direct use of the
vertex and index buffer base classes. In C++ we can choose which parts
of a class are private, so we don't risk exposing too many
implementation details here.

Pull Request: https://projects.blender.org/blender/blender/pulls/119825
2024-03-24 16:38:30 +01:00
Hans Goudey 84c6ead74b Refactor: Remove unnecessary curves GPU evaluation caches
Currently we have a cache for all combinations of "strand/strip" and
the four subdivision levels. Recomputing this data should be very fast
and doesn't require re-uploading data from the CPU. Because they are
scene settings, they will be the same for all render engines too, so we
won't have a case where we're constantly requesting different values.

The extra caches just complicate code, so better to remove them. Now
the final evaluated cache remembers the settings it was created with,
and it's cleared if they are changed.

Pull Request: https://projects.blender.org/blender/blender/pulls/119804
2024-03-24 16:33:12 +01:00
Casey Bianco-Davis cb453a5846 Fix: Debug crash upon entering edit mode.
Any valid object gets added to `object_data` so we should check if it is not empty rather then is empty.

Pull Request: https://projects.blender.org/blender/blender/pulls/119839
2024-03-24 13:11:01 +01:00
Iliya Katueshenock 9123451427 Cleanup: BLI: Redundant dereference
Redundant dereference of array element.
This code is not used currently, but i noticed issue
while using this in my branch.

Pull Request: https://projects.blender.org/blender/blender/pulls/119842
2024-03-24 11:07:00 +01:00
John Swenson af0c42e266 Fix #118260: VSE scene strip wireframe display
The issue is that a draw call in the sequencer does not have any
knowledge of the viewport's wireframe opacity and threshold settings,
defaulting both to 0.

A similar issue #86956 implemented a quick hack to fix grease pencil
shading in VSE, so I opted to do the same here. In the future, a better
solution could be implemented to preserve the entire v3d.overlay.

I should note that I made `wireframe_threshold = 0.5f` to match the
default value given in `versioning_280.cc` but if this works better
as `1.0f` instead let me know.

Pull Request: https://projects.blender.org/blender/blender/pulls/119811
2024-03-24 08:52:47 +01:00
Hans Goudey 3805974b6f Refactor: Use C++ array for edit mesh looptris
Pull Request: https://projects.blender.org/blender/blender/pulls/119829
2024-03-23 17:43:38 +01:00
Hans Goudey 3ce8c74a57 Cleanup: Fix outdated comments about Mesh data 2024-03-23 11:47:07 -04:00
Hans Goudey 374b80b84a Cleanup: Miscellaneous cleanups to newly C++ headers 2024-03-23 10:10:52 -04:00
Hans Goudey 1dc16f909d Cleanup: Move GPU Python headers to C++ 2024-03-23 10:06:45 -04:00
Hans Goudey a54c9b9e36 Cleanup: Move eevee_private.h to C++ 2024-03-23 09:59:23 -04:00
Hans Goudey 5cd1237594 Cleanup: Miscellaneous cleanups to newly C++ headers
Pull Request: https://projects.blender.org/blender/blender/pulls/119824
2024-03-23 14:52:00 +01:00
Hans Goudey a099061feb Cleanup: Move remaining draw headers to C++ 2024-03-23 14:51:59 +01:00
Clément Foucault 4d502ab51d EEVEE-Next: Refactor light data packing
This allows to use unions on the C++ side and safe type
casting on the GPU side.

The type casting functions are statically verified at
compile time in C++.

This PR doesn't change the size of the light struct
but removes the need of packing floats in the `object_mat`.
The matrix will be changed to a `float4x3` in another PR
and will reduce the struct by 16 bytes.

This remove the need for the light parameters macros and
reveals the padding members that could be used for future
features for each type.

After this, all accesses to light type dependent data in
the shaders should be done using:
- `LightLocalData light_local_data_get(LightData light)`
- `LightSpotData light_spot_data_get(LightData light)`
- `LightAreaData light_area_data_get(LightData light)`
- `LightSunData light_sun_data_get(LightData light)`

Note that these functions are simple passthrough for Metal
since it supports `union` (but enforce for error checking
if option is enabled).

The error check on GPU is a bit costly so it is disabled
by default.

Pull Request: https://projects.blender.org/blender/blender/pulls/119713
2024-03-23 08:16:12 +01:00
Bastien Montagne c7afb06ed0 Fix (unreported) some old files having regular IDs flagged as embedded.
It is unknown why/how this can happen, but there are some files out there
that have e.g. Objects flagged as embedded data... See e.g. the
`(Anim) Hero p23 for 2.blend` file from our cloud gallery
(https://cloud.blender.org/p/gallery/5b642e25bf419c1042056fc6).

Not much to be done, but add another checking pass at the end of
readfile process to fix these.
2024-03-23 12:55:57 +09:00
Bastien Montagne 7643bd7d89 Fix (unreported) broken GPv3 conversion code using one node socket for both input and output.
This is explicitely forbidden by an assert since 067daec270 a few days
ago, but somehow this GPv3 usage was missed then.
2024-03-23 12:02:41 +09:00
Bastien Montagne 4d973d3cf3 GPv3: Optional automatic conversion of legacy GP objects on fileload.
This adds a new exprimental option to automatically convert GP legacy
data to GPv3 one.

It supports also linking and appending cases. Conversion also happens
when opening a file linking GP legacy data saved by an older .blendfile.

Pull Request: https://projects.blender.org/blender/blender/pulls/118705
2024-03-23 03:28:57 +01:00
Hans Goudey 8b514bccd1 Cleanup: Move remaining GPU headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/119807
2024-03-23 01:24:18 +01:00
Harley Acheson 9eb275e6eb UI: Correction to Weight of 3D Viewport Overlay Text
Currently the overlay text, like stats for example, are drawing with
the widget_label font style size but using widget's weight. This is
just because UI_fontstyle_set is not called. Without this call we can
get a jiggling of the overlay text if these two styles differ in
weight. This PR also makes an (unnoticeable) correction to the font id
used in fontstyle_set_ex. uiFontStyle's uifont_id is not always the
same id as regular font ids, but here they are confused.

Pull Request: https://projects.blender.org/blender/blender/pulls/119808
2024-03-22 21:28:55 +01:00
Brecht Van Lommel 704e62d9d7 Merge branch 'blender-v4.1-release' 2024-03-22 21:08:15 +01:00
Brecht Van Lommel 64bfe49164 Fix: RNA warning regarding description ending in period
Ref #109157
2024-03-22 20:59:15 +01:00
Brecht Van Lommel b0b0510dbf Refactor: Access paint brush through accessor function
This will be used for brush assets in the future.

Ref #119801
2024-03-22 20:54:09 +01:00
Richard Antalik bee70e0c03 Fix #119465: Incorrect color when changing VSE colorspace
Cached strip images were not invalidated, which caused, that these
images were kept in memory in incorrect colorspace.

Code readability was improved a bit and clarifying comments were added
to avoid confusion about what is the code supposed to do.

Pull Request: https://projects.blender.org/blender/blender/pulls/119475
2024-03-22 20:11:51 +01:00
Richard Antalik 3f4d924298 Fix #118633: View limiting does not work if VSE is uninitialized
This happened, because function returned early if `Editing` was nullptr.
However it is needed only for timeline boundbox, which is already initialized
for case where there are no strips.

Pull Request: https://projects.blender.org/blender/blender/pulls/118864
2024-03-22 20:10:53 +01:00
Hans Goudey 561dfb4022 Cleanup: Simplify naming in curves draw cache, other simplifications
- Avoid unnecessary redundancy in function and variable names
- Use more consistent variable names in some places
- Avoid duplicate null checks and incorrect "ensure" naming
- Use const in a few places
- Pass more specific arguments besides just the curves
- Remove unnecessary namespace specification
2024-03-22 14:52:22 -04:00
Miguel Pozo def5f86cae Fix: EEVEE-Next: Material compilation
Move pcg functions to eevee_sampling_lib.
Including gpu_shader_common libs in engine code results in double  includes.
2024-03-22 18:58:12 +01:00
Harley Acheson cfce96dafe Changes needed because of removal of a1, a1 from uibut 2024-03-22 10:31:02 -07:00
Harley Acheson 5d136692e6 Merge branch 'blender-v4.1-release' 2024-03-22 10:27:38 -07:00
Harley Acheson 986e4a8b7f Fix #119384: Outliner Edit Mode Toggle When Data is Shared
This report includes a file that demonstrates a crash when ctrl-
clicking the "dot" icon to add to the objects in edit mode. This is
because the object has a mesh shared with another object that is
already in edit mode. This PR allows editing only one object at a
time between objects that share data.

Pull Request: https://projects.blender.org/blender/blender/pulls/119704
2024-03-22 18:26:29 +01:00
Hans Goudey 00e1b2256b Merge branch 'blender-v4.1-release' 2024-03-22 12:28:51 -04:00
Hans Goudey ed2cdc6583 Cleanup: Remove unused curves eval cache variable 2024-03-22 12:25:24 -04:00
Hans Goudey 7f4a4fa605 Fix #119787: Curves viewport attribute drawing crash
Caused by 1cca960677.

That commit stated that creating the final subdivided attribute didn't
free the "proc" attribute buffer that contains the data from the Curves
control points. However that wasn't the case, given the call to
`GPU_VERTBUF_DISCARD_SAFE` in that function. That caused a crash when
the overlay engine and EEVEE both wanted to access the VBO and it was
discarded the second time. To fix that, only regenerate the
`proc_attributes_buf` when it doesn't already exist.

This matches the "ensure" behavior that already exists for the
`cache.final[subdiv].attributes_buf` buffer, so conceptually it
seems fine.

Pull Request: https://projects.blender.org/blender/blender/pulls/119795
2024-03-22 17:19:50 +01:00
Guillermo Venegas 7fabf0d896 Fix #119778: Crash in popovers that do not support refreshing
When creating popover with `UI_popover_begin` the popover block
is created just once without a region and since `UI_popover_begin` blocks
are not support refreshing, layout panels may not be compatible
in this kind of popover since open/close state cannot be refreshed either.

Only `UILayout.popover(...)` popovers are supported to have layout panels.

Pull Request: https://projects.blender.org/blender/blender/pulls/119796
2024-03-22 17:09:02 +01:00
Sybren A. Stüvel aafe045fa0 Refactor: Anim, context function for active/editable/selectable actions
Just some simplification with early `return` / `continue` to reduce
indentation and cognitive complexity.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/119794
2024-03-22 16:49:12 +01:00
Jeroen Bakker 463856e6c6 GPU: Remove print statement when frame capturing
When frame capturing cannot be start an error is printed to the console.
Most of the time the issue is that you're not running from within a frame
capturing environment. For example not from your IDE/GPU debugger.

The print statement is often just not that useful. Especially when
running the `WITH_GPU_DRAW_TESTS` where it floods the console.

Pull Request: https://projects.blender.org/blender/blender/pulls/119783
2024-03-22 16:27:52 +01:00
Hans Goudey 3039ea02c6 Refactor: Simplify undo object list creation, use C++ Vector
Replace the use of the `LIB_TAG_DOIT` flag which cwas used to
only process each object data ID once with a Set. Return the objects
or bases in a Vector. Now we only iterate over the view layers bases
once instead of three times.

Pull Request: https://projects.blender.org/blender/blender/pulls/119788
2024-03-22 16:24:30 +01:00
Julian Eisel b1db1702c6 Cleanup: Deduplicate UI list filtering checks
Followup to 303014bfac.
2024-03-22 16:04:03 +01:00
Sybren A. Stüvel 9f0cc7fe64 Anim: Bone subdivision, ensure bone names are sequential
Ensure that subdividing "Bone" results in a chain "Bone", "Bone.001",
"Bone.002", etc.

Before this commit the order would be "Bone", "Bone.004", "Bone.003",
etc.

This might break add-ons that assume to know the bone names before the
actual subdivision happens. This would always have been fragile, as
there may, for example, already have been a "Bone.001"; in that case
subdividing "Bone" would result in "Bone", "Bone.002", etc. Instead, the
parent-child chain should be followed.

Pull Request: https://projects.blender.org/blender/blender/pulls/119775
2024-03-22 15:26:22 +01:00
Sybren A. Stüvel ce8a032ac2 Anim: fix bug in name uniqueness check for editbones
Fix the name uniqueness check for editbones. The function can receive a
"bone to ignore", which would not be properly ignored. If it was found
earlier in `armature->edbo` than another bone with the same name, the
name would incorrectly be marked as unique.

This issue only occurred when a "bone to ignore" was passed to the
uniqueness check. This never actually happens in the current code, but
that's going to change soon.
2024-03-22 15:21:36 +01:00
Christoph Lendenfeld 62f140e048 Anim: Add Sharpness to Ease operator
This PR extends the existing `Ease` operator with a sharpness property.

This means it has two parameters:
* Curve Bend: Define which key to favor. At 0 it's exactly between the two keys.
* Sharpness: Higher values make the change more abrupt.

During modal operation it is possible to switch the slider between those two by pressing `TAB`.

Pull Request: https://projects.blender.org/blender/blender/pulls/117287
2024-03-22 13:22:35 +01:00
Christoph Lendenfeld 646f9bcebe Refactor: Remove bAction argument from insert_keyframe
No functional changes intended.

The `insert_keyframe` function had a `bAction` argument that could be
a `nullptr`. If it was a `nullptr` it would be queried from the `ID`.

However in all cases where it is passed it is also gotten from the `ID`, making
the argument redundant.

This PR removes the argument to simplify the function.

Pull Request: https://projects.blender.org/blender/blender/pulls/119742
2024-03-22 13:18:32 +01:00
Julian Eisel d470b65f6d Merge branch 'blender-v4.1-release' 2024-03-22 12:28:46 +01:00
Julian Eisel 303014bfac Fix #108078: Crash when inverting results in pose library sidebar
a958ae36e8 introduced support for UI lists to reference items that would
never be shown, regardless of filter settings. This was to skip assets
in the asset view template that were not of the requested type. UI list
sorting code wasn't updated to account for such items that should be
entirely ignored.

Pull Request: https://projects.blender.org/blender/blender/pulls/109157
2024-03-22 12:25:39 +01:00
Aras Pranckevicius 480f2f5bdd Cleanup: Remove unused AviCodecData
Non-ffmpeg movie support was removed in #118409, but I did not
notice that AviCodecData is now not needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/119777
2024-03-22 12:17:49 +01:00
Christoph Lendenfeld 24b4461be3 Anim: restrict keylist creation for NLA drawing code
When previewing an action in the NLA, the drawing code would
calculate the Keylist for the whole action regardless of what is shown.
This patch limits the keylist creation to only do it for the viewport range
increasing performance in the case when less than the whole action is visible.

whole F-Curve visible
* Before 60ms
* After 60ms

zoomed in
* Before 60ms
* After 1.6ms

Pull Request: https://projects.blender.org/blender/blender/pulls/119470
2024-03-22 12:09:39 +01:00
Pablo Vazquez 703435680d UI: Use icon for View in Graph Editor menu item
Use the Graph Editor icon for the "View in Graph Editor" operators,
to make a connection with the entry in the list of editors and the
View menu in the Dope Sheet.

Only use icon on the first item of the section, according to the HIG.
2024-03-22 12:01:29 +01:00
Omar Emara ba3f37ac6b Cleanup: Remove unused function 2024-03-22 12:43:09 +02:00
Campbell Barton b057e7f36d Extensions: improve the default value for the extensions module
By default a URL would be used for the module name of new remote repos,
the '.' characters were removed, joining words together.

Even though this often isn't user visible, it is used for extension
directory names, command-line access & may show up in error messages.
2024-03-22 19:37:08 +11:00
Leon Schittek 3d867af642 Fix #115899: Prevent transparent gaps on nodes
Add some padding to the different shapes used to draw nodes to
prevent transparent gaps between them.
Also improve positoning of the node's outline.

Pull Request: https://projects.blender.org/blender/blender/pulls/119001
2024-03-22 09:15:00 +01:00
Campbell Barton 01f8e20681 Cleanup: remove return value from ED_object_add_generic_get_opts
This was never false, many callers already ignored the return value.
2024-03-22 19:12:27 +11:00
Campbell Barton 1d9ed41560 Cleanup: minor edits to code-comments 2024-03-22 19:12:27 +11:00
Leon Schittek 5acf2984d4 Node Editor: Improve padding around buttons and sockets
Make the padding that is added above and below buttons and sockets
more consistent across nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/118972
2024-03-22 09:09:47 +01:00
Omar Emara ac7309f95e Compositor: Add Float2 data type
This patch adds the Float2 data type to the MemoryBuffer class.

Needed by #119414.

Pull Request: https://projects.blender.org/blender/blender/pulls/119738
2024-03-22 08:51:24 +01:00
Campbell Barton 02681bd44d UI: support layout panels in popovers
Make use of UI_popup_dummy_panel_set so layout panels can be used.
2024-03-22 17:36:45 +11:00
Campbell Barton 44defbd2c7 Extensions: add BLENDER_USER_EXTENSIONS user directory
Replace: `{BLENDER_RESOURCE_PATH_USER}/extensions`
With:    `{BLENDER_USER_EXTENSIONS}`

This follows BLENDER_USER_CONFIG & BLENDER_USER_SCRIPTS conventions.
Reading the environment variable and accessible via
`bpy.utils.user_resource('SCRIPTS')`
2024-03-22 16:08:25 +11:00
Campbell Barton 6bfc8612bf Cleanup: remove BLENDER_USER_AUTOSAVE
This was only used on WIN32 when the temporary directory didn't exist.
When the check was added [0] this made some sense because it relied on
`U.tempdir` existing, since then additional checks have been added to
ensure a temporary directory can be used. Further, this fall-back
location isn't documented in the user manual.

[0]: 615db01b01
2024-03-22 16:08:25 +11:00
Campbell Barton e4b7f4d884 Suppress noisy color-management prints when using --command 2024-03-22 16:08:25 +11:00
Aaron Carlisle 02578117cd Merge branch 'blender-v4.1-release' 2024-03-21 23:48:14 -04:00
Hans Goudey c61ecf1f40 Cleanup: Move Mesh edit_mesh pointer to runtime data
The edit mesh is never saved to files, so it should be in the runtime struct.

Pull Request: https://projects.blender.org/blender/blender/pulls/119766
2024-03-21 23:18:49 +01:00
Hans Goudey b9ef66693a Fix #119754: Edit mode modifier deform data copy crash
Caused by ddcfc46ee6.

That commit assumed that the cage mesh always had the deformed
position and normal data. But that isn't true, as shown in the example
in the report. To fix the bug, simplify things, and make the goal clearer,
just copy the struct directly.

Pull Request: https://projects.blender.org/blender/blender/pulls/119755
2024-03-21 21:22:51 +01:00
Hans Goudey 575a5c0502 Fix #119744: Regression: Geometry Nodes: Default input not working
Caused by 25a10c211f.

The socket_type field for socket declarations wasn't set for declarations
created from the node group interface DNA tree structure. Arguably the
socket types should be set by the constructors, but setting it in one more
place isn't bad either, and is a simple fix for now.
2024-03-21 13:18:43 -04:00
Hans Goudey 040ff38fcd Fix: ID namemap assert in auto smooth versioning code
When "moving" the new node group to the same library as the object, its
original name has to be cleared from the name-map as well. That's
because there is a separate name-map for each library. I had this in
the original PR, but incorrectly removed this because I thought it was
unnecessary.

Pull Request: https://projects.blender.org/blender/blender/pulls/119747
2024-03-21 17:26:45 +01:00
Omar Emara d8a89aa972 Compositor: Add MemoryBuffer constructor from size
This patch adds a new MemoryBuffer constructor from width and heights.
Useful for temporary allocations where we don't care about the area.
2024-03-21 17:35:19 +02:00
Omar Emara f6657db713 Compositor: Add utility for nearest interpolation
This patch adds a utility function for nearest interpolation with
clamped boundaries and normalized coordinates to the MemoryBuffer class.
Similar to the GLSL texture() function.
2024-03-21 17:26:33 +02:00
casey bianco-davis 20b614ab8e GPv3: Fill texture coordinates system
This is implements the system texture coordinates for GPv3.

This pull request adds:
- System for storing and viewing texture coordinates.
- Texture coordinates are convert when covering from legacy to GPv3,
   (Tested with object and layer transformation)
- Textures are set to the drawing plane.

Pull Request: https://projects.blender.org/blender/blender/pulls/119303
2024-03-21 16:07:18 +01:00
JonasDichelle 8812be59a4 Compositor: Make Hue Correct node wrap
Compositor: Make Hue Correct node wrap

This patch makes the Hue Correct node as well as the Hue Correct VSE
modifiers to wrap, such that no discontinuities occur for the red hue.
Since it now wraps, the default curve preset now exempts the last point
of the curve.

A new CUMA_USE_WRAPPING flag was added to specify wrapping for curve
maps. The implementation works by adding two virtual points before and
after the terminal points in the curve map, such that their handles
match, and would then produce a continues curve.

This is a breaking change, since existing curves were also adjusted
using versioning. However, the change will not be significant, since in
most realistic cases, the terminal points will be close to each other,
and even with wrapping, the connection will be very sharp, almost
matching the old behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/117114
2024-03-21 15:35:02 +01:00
Christoph Lendenfeld 6a55a126e9 Anim: Only sort FCurves that need it
Before this PR the sorting function would receive all FCurves from
the `anim_data` ListBase and sort them + recalculate the handles.

Considering we are already checking
IF an `FCurve` needs sorting we might as well use
that and limit the sorting to FCurves that actually need it.
Doing that gives the following performance uplift.

| - | Before | After |
| - | - | - |
| Moving 1 key only | 109ms | 0.72ms |
| Moving 1 key of each FCurve | ~2000ms | ~2000ms |

Pull Request: https://projects.blender.org/blender/blender/pulls/119735
2024-03-21 15:11:19 +01:00
Omar Emara 2906ea9785 BLI: Add nearest interpolation with clamped boundary
This patch adds clamped boundaries variants of the nearest interpolation
functions in the BLI module. The naming convention used by the bilinear
functions were followed.

Needed by #119414.

Pull Request: https://projects.blender.org/blender/blender/pulls/119732
2024-03-21 13:22:10 +01:00
laurynas e2bdaf8ec7 Fix #119686: curves editmode handles are displayed in sculptmode
Curves cage overlay for sculpt mode restored to prior #119053 state.

Pull Request: https://projects.blender.org/blender/blender/pulls/119717
2024-03-21 12:24:29 +01:00
Philipp Oeser 6db5cf09e0 Merge branch 'blender-v4.1-release' 2024-03-21 11:53:31 +01:00
Philipp Oeser 5fa1915d47 Fix #119715: Curve sculpt puff brush causes hairs to move erratically
Caused by 98bf7a8d7a / ff7b8f3412

Since the `curve_weights` array was created uninitialized, and the above
commits were doing `math::max_inplace` on the uninitialized data, this
could end up with garbage values.

Now initialize the array properly to prevent this.

Pull Request: https://projects.blender.org/blender/blender/pulls/119730
2024-03-21 11:52:31 +01:00
Christoph Lendenfeld adef64db06 Refactor: BeztMap struct
No functional changes.

The `BeztMap` struct is used when sorting Keyframes during transformations
in the Graph Editor.

Things that were changed:
* Removed unneeded `newIndex`. This was just the index of the
`BeztMap` in the array, which we already have since we iterate with a for loop.
* Access the `BezTriple` array by index instead of pointer offsets.
This makes it a bit easier to see what's happening.
* Renamed struct members to clarify their use.
* Remove forward declaration of certain variables (e.g. loop counter vars)

Pull Request: https://projects.blender.org/blender/blender/pulls/119733
2024-03-21 11:50:51 +01:00
Philipp Oeser 475865ddb7 Merge branch 'blender-v4.1-release' 2024-03-21 11:13:23 +01:00