Commit Graph

102022 Commits

Author SHA1 Message Date
Christoph Lendenfeld
2b30d26ae9 Refactor: resolution_scale in graph_draw.cc
Recent patches added a variable `resolution_scale`
This variable defines how many points on the x or y axis to add.
However I find the name confusing.

Instead of that, change it to `pixels_per_unit`
and move the `points_per_pixel` factor
to `calculate_bezt_draw_resolution`

no functional changes

Pull Request: https://projects.blender.org/blender/blender/pulls/111037
2023-08-17 14:25:16 +02:00
Pratik Borhade
594dceda7f Fix #89479: Unable to select hierarchies of multiple objects from outliner
`select hierarchy` is treated in similar way as we're selecting single element from outliner.
When `object_select_hierarchy_fn` is called for the first time, we clear select flag for all elements
in `outliner_item_select`. This causes issue when `select hierarchy` is called for multiple elements.
So fix is to not touch select and activate flags when `OL_ITEM_RECURSIVE` flag is set.

This also fixes the hierarchy selection when "sync select" is OFF.

Old Differential Revision: https://archive.blender.org/developer/D16804

Pull Request: https://projects.blender.org/blender/blender/pulls/104737
2023-08-17 13:23:46 +02:00
Sergey Sharybin
33718b2d75 Fix #111165: Regression: Blender Crashes On Scene Switch
Fix missing depsgraph tag in the "Link Objects to Scene" operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/111214
2023-08-17 11:31:59 +02:00
Jeroen Bakker
53396816e4 Vulkan: Make Polyline Shaders Vulkan Compatible
Splitting interface stages based on the interpolation of its
attributes.

Then naming convention that have been used:

* use `interp` as instance name when using smooth interpolation
* use `interp_noperspective` when using no perpective interpolation
* use `interp_flat` when using flat interpolation

The same suffix will be added to the struct names.
The naming convention will be added to the GLSL code style and
applied to other shaders as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/111210
2023-08-17 11:31:10 +02:00
Bastien Montagne
a99cccaff8 Fix (unreported) WM 'foreach_id' code skipping unpinned_scene pointer.
Previous code would not process that ID pointer in case the
`workspace_hook` pointer was null.
2023-08-17 10:57:58 +02:00
Jeroen Bakker
826ebccb42 Cleanup: Make format 2023-08-17 10:53:53 +02:00
Jeroen Bakker
074f10470c Vulkan: Add Workaround for Mixed Interpolation Attributes
shaderc generates an error when a struct containing an int type
isn't qualified as flat. We work around this issue by changing the
interpolation mode to flat during code generation.

Pull Request: https://projects.blender.org/blender/blender/pulls/111211
2023-08-17 10:53:05 +02:00
Christoph Lendenfeld
bb8766ef01 Animation: Match Slope slider
It blends selected keys to the slope of neighboring ones.
It is used to push the segment closer to the values of the next or previous pose.

Co-authored-by: Ares Deveaux <aresdevo@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/110567
2023-08-17 10:28:46 +02:00
Sybren A. Stüvel
0e2875ede9 Prevent crash when color management is turned off
Prevent a segmentation fault when the viewport is set to 'Material Preview'
mode, drawing textures, and Blender built with `WITH_OPENCOLORIO=OFF`.

Most `IMB_colormanagement_...` functions assume that the `colorspace`
pointer can be `nullptr`, but the internal function
`colormanage_ensure_srgb_scene_linear_info()` does not, causing a crash.

Since this check can be done in multiple places, I picked one that seems
consistent with the rest of the code.

Pull Request: https://projects.blender.org/blender/blender/pulls/111144
2023-08-17 10:21:09 +02:00
Jeroen Bakker
f44447a628 Vulkan: Use Correct Interpolation Qualifier in Stage Interfaces
This PR cleans up the Stage Interface code generation and use the
correct interpolation qualifier. This is a cleanup/fix before we can
start converting shaders stage interfaces to be compatible with vulkan.

Ref: #111138 for more information about vulkan compatibility
Pull Request: https://projects.blender.org/blender/blender/pulls/111207
2023-08-17 09:40:34 +02:00
Jeroen Bakker
6f9c3b1bd5 Vulkan: Report Incompatible Shaders
A difference was detected between stage interfaces between OpenGL and Vulkan
that are not compatible with our current API.

**OpenGL**

In OpenGL an stage interface struct can have different interpolation qualifiers
per attribute.

```glsl
struct MyStageInterface {
    smooth vec4 color;
    flat int face_flag;
};
layout(..) MyStageInterface interp;
```

**Vulkan**

In vulkan the interpolation qualifier isn't supported on attribute
level and needs to be added to the struct.

```glsl
struct MyStageInterface {
    vec4 color;
};
struct MyStageInterface_flat {
    int face_flag;
};
layout(..) smooth MyStageInterface interp;
layout(..) flat MyStageInterface_flat interp_flat;
```

This patch reports shaders that are incompatible with Vulkan so they can be
patched. Report is only done in debug mode and when using the vulkan backend.
After all shaders are patched an error will be raised so developers will
known immediately when incompatibility are created.

Making the shaders compatible and adding the error will be done in future
patches.

**Python**

Via Python gpu module (gpu.types.GPUShaderCreateInfo) it isn't possible
to construct an incompatible shader as instance names cannot be set
via the API. So this isn't a breaking change.

Pull Request: https://projects.blender.org/blender/blender/pulls/111138
2023-08-17 08:59:03 +02:00
Campbell Barton
b1b20bea7b Fix Shader::print_log not handling warnings
Severity::Error was checked twice.
2023-08-17 16:53:08 +10:00
Jeroen Bakker
bbe4f6cf74 Fix: Compilation Error When Compiling with Vulkan
This PR fixes an compilation error where sstream used to be included
on a higher level, but has been removed and we need to include them
where they are actually used.

This wasn't detected as most developers don't have the vulkan backend
active.

Pull Request: https://projects.blender.org/blender/blender/pulls/111203
2023-08-17 08:24:29 +02:00
Campbell Barton
c713c70781 CMake: quiet uninitialized warnings 2023-08-17 11:53:56 +10:00
Harley Acheson
d102536b1a Fix #93685: Allow Outliner Drag to Other Windows
Allow dragging items from Outliner to other windows. Disables EdgePan
operator when entering new window. Canceling the drop redraws target
area and resets all modal cursors. But this does not fix incorrect
mouse cursor during operations on the remote target window.

Pull Request: https://projects.blender.org/blender/blender/pulls/105196
2023-08-17 00:48:32 +02:00
Aaron Carlisle
3ea7117ed1 PyAPI Docs: Fix generation after recent node RNA changes
This commit allows both `rna_enum_` and `rna_node_`to be used for enum prefixes

This also fixes one enum by adding `rna_` to the prefix.

Together these changes fix the API documentation generation.
2023-08-16 17:37:41 -04:00
Harley Acheson
0e977a38bc Cleanup: Make format
Formatting changes resulting from Make Format
2023-08-16 14:15:54 -07:00
Guillermo Venegas
84718feb4b Fix potential leaks using SHGetKnownFolderPath
Documentation for `SHGetKnownFolderPath` remarks that the `PWSTR`
parameter should always be freed with `CoTaskMemFree`  even if it
succeeds or not.

Pull Request: https://projects.blender.org/blender/blender/pulls/111128
2023-08-16 23:10:00 +02:00
Harley Acheson
0c7496f74d UI: Increase Color Picker Size
Increase the Color Picker Size by 33%

Pull Request: https://projects.blender.org/blender/blender/pulls/111153
2023-08-16 22:59:14 +02:00
RedMser
f1e7fe5492 UI: Windows "Quick Access" items to File Browser System List
On the Windows platform add any Explorer "Quick Access" items to the
bottom of the File Browser "System" List in the sidebar.

Co-authored-by: Harley Acheson <harley.acheson@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/108431
2023-08-16 22:36:06 +02:00
Brecht Van Lommel
b0424a7cbd Fix #111180: crash adding AOV/light output node with shader node previews
Only happened when the experimental option is enabled.
2023-08-16 18:43:23 +02:00
Bastien Montagne
f1e64781a8 Core: foreach_id: Tweak handling of scene collection in LayerCollection.
Unfortunately, relying only on the 'embedded' flag of the collection ID
pointer to detect the LayerCollection of a Scene embedded collection is
not enough, since this info may not always be available.

So add an extra explicit 'is_master' to the recursive code processing
all LayerCollections ID pointerrs, and double-check with an assert that
this info is coherent with the Collection's embedded flag, when
possible.
2023-08-16 18:23:15 +02:00
Bastien Montagne
28305c2c73 Refactor: Properly formalize special versioning done after most of readfile code.
In a few cases (IPO conversion, Proxy conversion, ...), versioning
implies creating or removing IDs, and/or needs access to the whole Main
data-base.

So far this was done ad-hoc by adding some code at the end of
`setup_app_data`.

This commit formalizes this process by adding a BLO call
(`BLO_read_do_version_after_setup`) that will encapsulate all such
complex versioning code.

NOTE: This commit does not address the existing issue that this
versioning code is never performmed when linking new data (outside of
the 'opening a blendfile' context). This topic would require its own
design task.

NOTE: This commit does not fix the few current evil cases of ID creation in
regular versioning code. This will be addressed separately.

Although this commit does modifies slightly some logic in this specific
versioning process, no behavioral changes are expected here.

Pull Request: https://projects.blender.org/blender/blender/pulls/111147
2023-08-16 16:21:59 +02:00
Falk David
b14a0ee57e Cleanup: GPv3: Refactor usage of TreeNode
Some functionality of `Layer`s and `LayerGroup`s can be shared. This is why the `TreeNode` class exists. It encapsulates all the common methods both `Layer`s and `LayerGroup`s should have.

Up until now, the usage of `TreeNode` was not consistent and often the layers would just access the base c-struct directly.

This refactor makes it so that all of the functions affecting only the `TreeNode` are moved to the `TreeNode` class and only implemented there.

For example, renaming a layer is really just renaming the node. Therefor there shouldn't even be a `rename_layer` and `rename_layer_group` function. These were combined into a `rename_node` function.

Pull Request: https://projects.blender.org/blender/blender/pulls/111177
2023-08-16 16:18:26 +02:00
Bastien Montagne
dd647677b6 Fix (unreported) Scene foreach_id callback skipping some NULL ID pointers.
Not sure how bad that was in practice, was likely harmless. But
foreach_id logic should never decide to not process an ID pointer
because its value is NULL. Callback code is expected to handle NULL
pointers appropriately.
2023-08-16 15:04:33 +02:00
Pratik Borhade
338e4ef090 Fix: GPv3 layer renaming when name is unchanged
When old and new names of layers/groups are same, garbage string is
displayed. This is because `oldname` char pointer is referenced to
`node.name`. After function execution, `oldname` memory is freed in
`interface_handler` (see `after.rename_orig`), thus displays garbage
string.
Fix is to copy the content of `oldname` instead of referencing it.

Pull Request: https://projects.blender.org/blender/blender/pulls/111173
2023-08-16 14:48:46 +02:00
Omar Emara
85a3f61150 BLI: Add 2D transformation matrix decomposition
This patch adds support for 2D transformation matrix decomposition into
translation, rotation, and scale.

Pull Request: https://projects.blender.org/blender/blender/pulls/111178
2023-08-16 14:47:14 +02:00
Aras Pranckevicius
2f060706a4 Cleanup: fewer BLI_color.hh et al includes
Include counts of some headers while making full blender build:
- BLI_color.hh 1771 -> 1718
- BLI_math_color.h 1828 -> 1783
- BLI_math_vector.hh 496 -> 405
- BLI_index_mask.hh 1341 -> 1267
- BLI_task.hh 958 -> 903
- BLI_generic_virtual_array.hh 509 -> 435
- IMB_colormanagement.h 437 -> 130
- GPU_texture.h 806 -> 780
- FN_multi_function.hh 331 -> 257

Note: DNA_node_tree_interface_types.h needs color include only
for the currently unused (but soon to be used) socket_color function.
Future step is to figure out how to include
DNA_node_tree_interface_types.h less.

Pull Request: #111113
2023-08-16 14:48:53 +03:00
Campbell Barton
92c4756d02 Fix replacement of "Blender Foundation" in recent header change
The recent change to header copyrights [0] unintentionally changed
"Blender Foundation" to "Blender Authors" for the WIN32 file path
which blender is installed into.

Revert lines changed that aren't related to copyright text.

[0]: e955c94ed3
2023-08-16 21:21:55 +10:00
Sergey Sharybin
efb2406262 Fix #111165: Regression: Blender Crashes On Scene Switch
The root of the issue is a missing recalculation tag after
changing collection content.

Pull Request: https://projects.blender.org/blender/blender/pulls/111175
2023-08-16 12:22:55 +02:00
Chao Li
27eb6d48d3 GPv3: Select box grease pencil frames
Adapt the `ACTION_OT_select_leftright`, `ACTION_OT_select_box` and `ACTION_OT_select_column` operators to take into account grease pencil layer channels. These operators call `actkeys_select_leftright`, `box_select_elem`, and `markers_selectkeys_between`, respectively. In these three functions, grease pencil layer channels are considered now. This resolves #110522.

Pull Request: https://projects.blender.org/blender/blender/pulls/110939
2023-08-16 11:44:15 +02:00
Alaska
007b7d0353 Shaders: Change IOR soft minimum to 1.0 in Principled BSDF
Pull Request: https://projects.blender.org/blender/blender/pulls/111158
2023-08-16 10:17:57 +02:00
Aras Pranckevicius
acbd952abf Cleanup: fewer iostreams related includes from BLI/BKE headers
Including <iostream> or similar headers is quite expensive, since it
also pulls in things like <locale> and so on. In many BLI headers,
iostreams are only used to implement some sort of "debug print",
or an operator<< for ostream.

Change some of the commonly used places to instead include <iosfwd>,
which is the standard way of forward-declaring iostreams related
classes, and move the actual debug-print / operator<< implementations
into .cc files.

This is not done for templated classes though (it would be possible
to provide explicit operator<< instantiations somewhere in the
source file, but that would lead to hard-to-figure-out linker error
whenever someone would add a different template type). There, where
possible, I changed from full <iostream> include to only the needed
<ostream> part.

For Span<T>, I just removed print_as_lines since it's not used by
anything. It could be moved into a .cc file using a similar approach
as above if needed.

Doing full blender build changes include counts this way:
- <iostream> 1986 -> 978
- <sstream> 2880 -> 925

It does not affect the total build time much though, mostly because
towards the end of it there's just several CPU cores finishing
compiling OpenVDB related source files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111046
2023-08-16 09:51:37 +02:00
Iliya Katueshenock
f50da4040f Fix #111142: bl_static_type is empty for node groups and custom nodes
Caused by f18c45eb69.
Functions `node_type_base` and `node_type_base_custom`
are the same, but last one have been missed in the cleanup.

Pull Request: https://projects.blender.org/blender/blender/pulls/111154
2023-08-16 09:29:46 +02:00
Harley Acheson
a70953242d Cleanup: Calm Warning
Unreferenced variable introduced in 5741a5d433
2023-08-15 17:21:02 -07:00
Harley Acheson
5741a5d433 UI: Allow Eyedropper Outside of Blender
This adds a new Ghost function, GHOST_GetPixelAtCursor, that allows
picking colors from outside of Blender windows. This only has an
implementation for the Windows platform, but this should allow other
platforms to also do so if possible.

Pull Request: https://projects.blender.org/blender/blender/pulls/105324
2023-08-16 01:14:36 +02:00
Almaz-Shinbay
077db81638 Outliner: Port linked object elements to new tree-element code design
No user visible changes expected.

Part of #96713, continuation of work started in 249e4df110 and 2e221de4ce.
Refer to these for a motivation and design overview.

Adds a new class for linked object elements.

Pull Request: https://projects.blender.org/blender/blender/pulls/111130
2023-08-15 22:44:40 +02:00
Sybren A. Stüvel
86085bcb9c Mem: avoid offsetting nullptr
Fix an UBSAN warning about undefined behavior, by preventing additions
to `nullptr`:

```
blender/source/blender/blenlib/intern/BLI_memiter.c:136:42: runtime error:
applying non-zero offset 48 to null pointer
```

No functional changes.
2023-08-15 18:01:11 +02:00
Hoshinova
0702c24a36 Nodes: Add Lacunarity and Normalize inputs to Noise node
This PR adds the Lacunarity and Normalize inputs to the Noise node
similar to the Voronoi node.

The Lacunarity input controls the scale factor by which each
successive Perlin noise octave is scaled. Which was previously hard
coded to a factor of 2.

The Noise node normalizes its output to the [0, 1] range by default.
The Normalize option makes it possible for the user to disable that.
To keep the behavior consistent with past versions it is enabled by
default.

To make the aforementioned normalization control easer to implement,
the fractal noise code now accumulates signed noise and remaps the
final sum, as opposed to accumulating positive [0, 1] noise.

Pull Request: https://projects.blender.org/blender/blender/pulls/110839
2023-08-15 17:38:45 +02:00
Falk David
969de5135a GPv3: Re-evaluate on frame change
This makes it so the `GreasePencil` geometry gets updated on a time
change.
The frame at which the object gets evaluated is stored in runtime as
`eval_frame`. This is for example used to calculate the bounding box
of the geometry as well as invalidating the batch cache for different
frames.

Pull Request: https://projects.blender.org/blender/blender/pulls/111137
2023-08-15 17:31:11 +02:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Bastien Montagne
f188d6709f LibOverride: keep some anim data from liboverride when it exists in both IDs.
So far when an anim data had to be created in liboverride (because none
existed in reference ID), and reference ID got an anim data added later,
that reference anim data would simply replace the one from the
liboverride, completely losing all animation-related work done so far in
the liboverride.

This commit fixes that, by adding some custom handling of anim data when
there is a liboverride operation defined on the `animation_data` RNA
property itself.

It then behaves as if everything that is overridable in the existing
liboverride was defined as overrides (and therefore kept), while
everything else is replaced by the reference animdata:
* Action and temp action are kept.
* Settings (extend mode, etc.) are kept.
* Active NLA track and strip are kept, and tracks and strips from the
  liboverride are added at the end of the list of these from the
  reference data.

Note that this behavior is only expected to happen once, on the first
call to 'apply overrides' after anim data has been added to the reference
linked ID. After that, since both IDs have animdata, there should be no
liboverride property defined for the `animation_data` property itself,
but only for paths leading inside that animdata struct.

Implements #110067.
2023-08-15 16:05:25 +02:00
Bastien Montagne
257f21d494 Cleanup: Move Compositor versioning code from Scene's 'lib_link' to actual versioning code.
Not sure when that versioning was added, but nowadays there are the
'after_linking` versioning handlers for that kind of case.
2023-08-15 15:54:21 +02:00
Jeroen Bakker
616e0c8c1d Vulkan: Set Geometry Shader Capability
Vulkan already used geometry stages, but it wasn't set as backend
capability. This resulted that the shader builder didn't validate
shaders that uses geometry stages.

Pull Request: https://projects.blender.org/blender/blender/pulls/111139
2023-08-15 15:53:56 +02:00
Jeroen Bakker
d20f26aeb6 Fix: Memory Reserve Issue in Vulkan/Std140
This PR solves a memory reserve issue when a nvec3 was followed by
a int, bool, float.

Also adds a debug_print method to the push constants for checking
the structure against data in renderdoc.

Pull Request: https://projects.blender.org/blender/blender/pulls/111109
2023-08-15 14:16:26 +02:00
Jeroen Bakker
ab3ae2be4d Fix: Vulkan Use Resource After Free
When immediate mode is used with a temp texture the
draw command was executed after the texture was freed.

This PR ensures that the draw command is executed before
the texture is freed.

Pull Request: https://projects.blender.org/blender/blender/pulls/111111
2023-08-15 14:15:46 +02:00
Jeroen Bakker
dd4ab50065 GPU: Add Dummy Backend For Unsupported Platforms
With the introduction of metal and vulkan we use a different
GPU backend selection which broke the dialog box for unsupported
platforms.

Blender asserted and segfaulted before the dialog was being shown
to the user.

This patch solves this by introducing a dummy GPU backend in case no
GPU backend was supported by OpenGL, Metal and Vulkan Backend.

It also adds the showMessageBox to GHOST_SystemCocoa.

Related to #110335

Pull Request: https://projects.blender.org/blender/blender/pulls/110919
2023-08-15 14:15:12 +02:00
Bastien Montagne
4b98c0aa24 Cleanup: Remove 'read_data' code from Scene's paint 'link_lib' code.
Changes to internal private data of an ID has _nothing_ to do into its
'lib_link' reading code (unless in the extremely rare case where it
would have hard dependency on its ID having valid ID pointers).

In that case, `BKE_paint_runtime_init` was already called in
`BKE_paint_blend_read_data` anyway, so the only actual change was
setting `p->paint_cursor`... *sigh*
2023-08-15 12:02:37 +02:00
Jeroen Bakker
b3ca211bf4 Cleanup: Code formatting 2023-08-15 07:43:03 +02:00
Clément Foucault
dd9a92785a Metal: Fix incorrect texture 2D array read
Authored by Apple: Michael Parkin-White
2023-08-14 23:32:44 +02:00