Commit Graph

105839 Commits

Author SHA1 Message Date
Jacques Lucke
8896446f7e Python: add Python API for layout panels
This adds a Python API for layout panels that have been introduced in #113584.
Two new methods on `UILayout` are added:
* `.panel(idname, text="...", default_closed=False) -> Optional[UILayout]`
* `.panel_prop(owner, prop_name, text="...") -> Optional[UILayout]`

Both create a panel and return `None` if the panel is collapsed. The difference lies
in how the open-close-state is stored. The first method internally manages the
open-close-state based on the provided identifier. The second one allows for
providing a boolean property that stores whether the panel is open. This is useful
when creating a dynamic of panels and when it is difficult to create a unique idname.

For the `.panel(...)` method, a new internal map on `Panel` is created which keeps
track of all the panel states based on the idname. Currently, there is no mechanism
for freeing any elements once they have been added to the map. This is unlikely to
cause a problem anytime soon, but we might need some kind of garbage collection
in the future.

```python
import bpy
from bpy.props import BoolProperty

class LayoutDemoPanel(bpy.types.Panel):
    bl_label = "Layout Panel Demo"
    bl_idname = "SCENE_PT_layout_panel"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"

    def draw(self, context):
        layout = self.layout
        scene = context.scene

        layout.label(text="Before")

        if panel := layout.panel("my_panel_id", text="Hello World", default_closed=False):
            panel.label(text="Success")

        if panel := layout.panel_prop(scene, "show_demo_panel", text="My Panel"):
            panel.prop(scene, "frame_start")
            panel.prop(scene, "frame_end")

        layout.label(text="After")

bpy.utils.register_class(LayoutDemoPanel)
bpy.types.Scene.show_demo_panel = BoolProperty(default=False)
```

Pull Request: https://projects.blender.org/blender/blender/pulls/116949
2024-01-11 19:08:45 +01:00
Nate Rupsis
d499710218 Fix #115978: FCurve extrapolation ignored in NLA.
The fix in 9da88301ef forgot to add the `NLASTRIP_FLAG_NO_TIME_MAP` flag, and thus FCurve extrapolation on actions is ignored.

Pull Request: https://projects.blender.org/blender/blender/pulls/116382
2024-01-11 11:49:54 -06:00
Hans Goudey
6438d0ad1f Cleanup: Grammar in comments 2024-01-11 11:01:50 -05:00
Miguel Pozo
2bbf65f6e5 Fix #116985: Workbench: Skip volume depth test in Wireframe mode 2024-01-11 16:35:44 +01:00
Sergey Sharybin
c78a0f3aa6 Fix #114692: Sculpt on certain modifiers does not update normals
Caused bu 5af8b839cf.

This solution tags both mesh positions and normals for update when
drawing happens from the modifier stack evaluation result.

This is needed because the sculpt session modifies original mesh
positions, and the modifier stack is not guaranteed to modify them
further (and hence tag normals for update).

Pull Request: https://projects.blender.org/blender/blender/pulls/117033
2024-01-11 16:15:35 +01:00
Sergey Sharybin
fd3669c3db Fix #115214: Incorrect vertex paint with image texture
The issue is caused by 087612c042 which changed type of
vpd->paintcol from byte to float. Some of the code was
expecting it to be byte, and did C-style cast to a pointer
of uchar.

This is a minimalistic fix, which makes it so the
paint_and_tex_color_alpha() operates on proper types and
avoids reading from the result color before overriding the
value.

Pull Request: https://projects.blender.org/blender/blender/pulls/117030
2024-01-11 16:10:24 +01:00
georgiy.m.markelov@gmail.com
9a7ea993d0 Hydra: Support legacy hair particle curves
Ref #110765

Co-authored-by: Bogdan Nagirniak <bodyan@gmail.com>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/114197
2024-01-11 15:44:26 +01:00
Sybren A. Stüvel
15c7c77967 Anim: fix assertion when un-assigning bone collection parent
When using `bone_collection.parent = None` in Python, debug builds would
hit an assertion. This is now fixed.
2024-01-11 14:37:11 +01:00
Sybren A. Stüvel
649eec7774 Fix #116061: BoneCollection ID property user count handling incorrect
Ensure that `armature_free_data(ID *id)` (the `IDTypeInfo::free_data`
function) does not decrement user counts for ID properties of type 'pointer'.
2024-01-11 14:37:11 +01:00
Jacques Lucke
6c9d77be3b Cleanup: replace raw function pointer with FunctionRef 2024-01-11 14:17:13 +01:00
Jeroen Bakker
69ac64df54 GPU: Shader Builder CMake Fixes
This PR cleans up shader builder CMake files and fixes vulkan includes
that could not be found on all platforms.

* Reduce code duplication
* Use private var for MANIFEST on windows
* Add system includes when compiling

Pull Request: https://projects.blender.org/blender/blender/pulls/115889
2024-01-11 13:42:17 +01:00
Jeroen Bakker
6e17b9c640 Vulkan: Fix: DEPTH_COMPONENT24
Tests for DEPTH_COMPONENT24 crash, so add an implementation to support it.

Co-authored-by: vnapdv <kaz380@hotmail.co.jp>
Pull Request: https://projects.blender.org/blender/blender/pulls/117026
2024-01-11 12:55:33 +01:00
Jeroen Bakker
cd8218d9e4 Vulkan: Fix Image Range Validation Error
Co-authored-by: vnapdv <kaz380@hotmail.co.jp>
Pull Request: https://projects.blender.org/blender/blender/pulls/117024
2024-01-11 12:47:11 +01:00
Pratik Borhade
8ce2bacaf9 Fix #116996: Problem linking to reroute nodes
Cause by d19e7cbb5a
Skip reroute node case when cursor is over header

Pull Request: https://projects.blender.org/blender/blender/pulls/117014
2024-01-11 12:18:54 +01:00
Jeroen Bakker
6e26249671 Vulkan: Fix vkCmdCopyBufferToImage validation error
Fixes validation error {0xbd041cbe}VUID-VkBufferImageCopy-aspectMask-00212.

Co-authored-by: vnapdv <kaz380@hotmail.co.jp>
Pull Request: https://projects.blender.org/blender/blender/pulls/117021
2024-01-11 11:47:45 +01:00
Jeroen Bakker
46a79ba5a2 Vulkan: Fix Samplers Extend mode
Patch provided by @vnapdv

Pull Request: https://projects.blender.org/blender/blender/pulls/117020
2024-01-11 11:41:35 +01:00
Jeroen Bakker
72d6ca3aff Vulkan: Fix Anisotropic Filtering Validation Error
When anisotropic filtering is enabled on a sampler its value must be
between 1 and 16. In blender it is possible to set a value lower than 1.
0 actually means that anisotropic filtering is disabled in Blender.
This would trigger a validation error in Vulkan.

Pull Request: https://projects.blender.org/blender/blender/pulls/117018
2024-01-11 11:12:35 +01:00
Jacques Lucke
a94146b82c Cleanup: move BKE_pointcloud.h to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/116990
2024-01-11 10:54:47 +01:00
Andrew Oates
2e48712508 Fix #115829: Add Metal <-> OpenGL fallbacks for userpref
Starting with Blender 4.0, Blender refuses to load a userpref.blend file
that had been generated on a macoOS machine, exiting immediately with an
unsupported GPU error.  This is because when the userdef was written on
the macOS machine (assuming a recent version), it has gpu_backend set to
GPU_BACKEND_METAL (which is rejected).  The same is true in reverse.

Prior to commit cdb8a8929c there was a runtime fallback such
that the setting for Metal backend would be ignored on non-Metal
platforms.

This adds a check in blo_do_versions_userdef() for if gpu_backend is set
to an unsupported backend; if so, it is set to a default supported value
for the current platform (Metal on macOS, OpenGL otherwise).  This
replaces the current versioning check, as this isn't strictly related to
versioning.  The new logic handles the narrower versioning case (a macOS
user upgrading to 4.0+ with a userprefs selecting OpenGL) as well.

This should be future-proof for other GPU backends, as it only overrides
in the case of an unsupported value.  The logic could be generalized in
the future, perhaps.

Co-authored-by: Andrew Oates <andrew@andrewoates.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/116861
2024-01-11 09:30:34 +01:00
Campbell Barton
e904432a1f Fix #117015: Crash with subsurf mesh & loose edges in edit-mode
The result of bm_original_edge_get() was missing a null check,
all other callers check for null.
2024-01-11 18:19:20 +11:00
Campbell Barton
7a4f7a1d51 Cleanup: spelling in comments, comment blocks 2024-01-11 16:46:46 +11:00
Campbell Barton
d2c392dec6 Docs: add doc-strings for modifier mapping flags & edit-mesh cage 2024-01-11 14:07:36 +11:00
Campbell Barton
0c89e2d60e Fix #115169: Loop Cut overlay broken with Mirror Bisect Modifier
Oversight in [0] which assumed the cage meshes vertices were aligned
with the edit-mesh vertices which isn't always the case.

Check the cage mesh only has deformations applied before using it.

[0]: 29a338811c
2024-01-11 12:44:14 +11:00
Campbell Barton
d0359d066d UI: context menu support for changing menu & panel shortcuts
While the shortcuts would be shown for menus & panels,
there was no way to edit them from the context menu.

This was reported as a bug since moving "Undo History" from an operator
to a menu meant it was no longer possible to assign a shortcut from
the context menu.

Resolves: #97431.
2024-01-11 11:18:57 +11:00
Thomas Wilshaw
f79425fe82 Fix #116988: TIFF ignores compression type None
When saving an image as TIFF with compression type None, explicitly set
the OIIO ImageSpec attribute "compression" to "none" as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/117005
2024-01-11 00:56:40 +01:00
Brecht Van Lommel
eb747c5d20 Fix: invalid memory access in Hydra world and material export 2024-01-10 20:54:40 +01:00
Harley Acheson
4e0d604035 Fix #116950: Redraw Issues in Open Recent Previews
When drawing tooltips that include images the blend mode must be left
with GPU_BLEND_NONE, otherwise can interfere with later drawing. Also
slight refactor in that buttons with a custom tooltip function get a
"ui_tooltip_data_from-*" function like the other types.

Pull Request: https://projects.blender.org/blender/blender/pulls/117001
2024-01-10 20:34:52 +01:00
Brecht Van Lommel
7271f303fe Cleanup: make format 2024-01-10 20:34:30 +01:00
Thomas Barlow
2b9aa55a03 RNA: Remove bitmask from BoolAttributeValue.value
Bool attributes are treated as contiguous arrays of `bool` rather than
using a bitmask.

Using a bitmask also disables raw array access, and with raw array
access, the property is faster to access through the Python API with
bpy_rna.cc#foreach_getset.

Pull Request: https://projects.blender.org/blender/blender/pulls/116997
2024-01-10 20:30:19 +01:00
Dyvine57
eca14d5b40 Nodes: add int and bool to shader nodegroups
These are handled as floats by Cycles and EEVEE.

Pull Request: https://projects.blender.org/blender/blender/pulls/115026
2024-01-10 20:09:37 +01:00
Hans Goudey
ba4d7fc2d9 Cleanup: Continue loop to corner rename in some mesh code
Change mesh normals code and mesh topology map functions.
2024-01-10 13:12:22 -05:00
Harley Acheson
5680ea2986 Refactor: "Warning" -> "Confirm" for Custom Confirmations
As suggested by Campbell, this changes structure, variable, and
callback names to use "confirm" terminology rather than "warning"
for code related to custom confirmations.

Pull Request: https://projects.blender.org/blender/blender/pulls/116992
2024-01-10 18:41:42 +01:00
Omar Emara
cbb738191e Compositor: Redesign Sun Beams node for CPU
This patch ports the new GPU implementation of the Sun Beams node to the
CPU compositor. Introduced in 9e358fcd44.
2024-01-10 19:36:52 +02:00
Miguel Pozo
c08ba9b0bd FIx: EEVEE-Next: Forward SSS shader compilation 2024-01-10 18:35:00 +01:00
Michael Kowalski
e57c17ea6e Fix #93052: USD import: wrong varying interpolation conversion
Change to map the USD "varying" interpolation type to Blender's
"Corner" domain type when importing mesh attributes.  This fixes
value count mismatch errors when importing USD attributes with
varying interpolation.

Note that, for meshes, "varying" and "faceVarying" interpolation
are essentially the same in practice.

Pull Request: https://projects.blender.org/blender/blender/pulls/116955
2024-01-10 18:33:09 +01:00
Falk David
6f66e6e3ba GPv3: Python API: Add materials collection property
This adds the `object.data.materials` collection property to access the grease pencil materials.
2024-01-10 18:32:27 +01:00
Thomas Barlow
992ec6487b RNA: Add missing raw types for DNA types
RNA raw types were missing for the int8_t, uchar (uint8_t),
ushort (uint16_t), int64_t and uint64_t DNA types types.

This adds the missing RNA raw types for all DNA types that can have
raw access.

Functional Changes

Properties with one of the new unsigned raw types will raise a Python
OverflowError in foreach_getset when attempting to read a negative
integer from bpy_prop_collection.foreach_set(). This is similar to the
existing behaviour of providing a Python int which is too large to
represent as a C long. The existing foreach_getset code will print
the OverflowError and then raise a TypeError instead.

CPython's signed integer parsing functions accept numeric types that are
not the Python int instances by calling their __index__() method.
CPython's unsigned integer parsing functions, however, only accept
Python int instances. To make foreach_getset accept the same
numeric types for unsigned raw types as it already accepts for signed
raw types, the unsigned integer parsing functions in py_capi_utils.h
have been updated to also call the __index__() method when given an
argument which is not a Python int instance.

Because the new unsigned integer parsing in foreach_getset is using
the PyC_ family of functions, which perform their own overflow checks,
the existing signed integer parsing has also been updated to use the
PyC_ family of functions for signed integer parsing. Previously,
OverflowError would only have been raised when the parsed integer was
too large to fit in a C long. With this patch, OverflowError will be
raised whenever the parsed integer is too large to fit in the property's
raw type. Integer properties already have well-defined maximum and
minimum values which should fit within the property's raw type, and enum
properties have a fixed number of values they can take depending on
their items. The bigger change here, is that setting bool properties
which use PROP_RAW_BOOLEAN will now only accept 0/False and
1/True.

Now that PROP_RAW_CHAR parsing is using PyC_Long_AsU8,
signed char buffers ("b" format) have been updated to no longer be
considered compatible with PROP_RAW_CHAR, matching the behaviour of
the other unsigned types only being considered compatible with unsigned
buffer formats.

The int64_t and uint64_t types can currently only be used by bool
properties (see IS_DNATYPE_BOOLEAN_COMPAT and the other macros in
RNA_define.hh), but bool properties only have raw access when they do
not use a bitmask and it doesn't make much sense to use an entire 64
bits just for a single bool property, so PROP_RAW_INT64 and
PROP_RAW_UINT64 are expected to be unused.

Performance Changes

Providing raw types allows for faster access through
rna_access.cc#rna_raw_access, especially when a buffer compatible with
the property's raw type is passed through from
bpy_rna.cc#foreach_getset.

Before this patch, the bpy.types.Keyframe.handle_left_type property
did not have raw access, so foreach_getset would fall back to
PROP_RAW_INT being the compatible type and then use the slower loop in
rna_raw_access.

With this patch, the bpy.types.Keyframe.handle_left_type property has
raw access with the PROP_RAW_UINT8 type. Using a buffer compatible
with this raw type can use the faster memcpy loop in
rna_raw_access. Using a Python list will iterate the list into an
array whose type matches PROP_RAW_UINT8, which will also use the
faster memcpy loop in #rna_raw_access.

Pull Request: https://projects.blender.org/blender/blender/pulls/115761
RNA raw types were missing for the int8_t, uchar (uint8_t),
ushort (uint16_t), int64_t and uint64_t DNA types types.

This adds the missing RNA raw types for all DNA types that can have
raw access.

Functional Changes

Properties with one of the new unsigned raw types will raise a Python
OverflowError in foreach_getset when attempting to read a negative
integer from bpy_prop_collection.foreach_set(). This is similar to the
existing behaviour of providing a Python int which is too large to
represent as a C long. The existing foreach_getset code will print
the OverflowError and then raise a TypeError instead.

CPython's signed integer parsing functions accept numeric types that are
not the Python int instances by calling their __index__() method.
CPython's unsigned integer parsing functions, however, only accept
Python int instances. To make foreach_getset accept the same
numeric types for unsigned raw types as it already accepts for signed
raw types, the unsigned integer parsing functions in py_capi_utils.h
have been updated to also call the __index__() method when given an
argument which is not a Python int instance.

Because the new unsigned integer parsing in foreach_getset is using
the PyC_ family of functions, which perform their own overflow checks,
the existing signed integer parsing has also been updated to use the
PyC_ family of functions for signed integer parsing. Previously,
OverflowError would only have been raised when the parsed integer was
too large to fit in a C long. With this patch, OverflowError will be
raised whenever the parsed integer is too large to fit in the property's
raw type. Integer properties already have well-defined maximum and
minimum values which should fit within the property's raw type, and enum
properties have a fixed number of values they can take depending on
their items. The bigger change here, is that setting bool properties
which use PROP_RAW_BOOLEAN will now only accept 0/False and
1/True.

Now that PROP_RAW_CHAR parsing is using PyC_Long_AsU8,
signed char buffers ("b" format) have been updated to no longer be
considered compatible with PROP_RAW_CHAR, matching the behaviour of
the other unsigned types only being considered compatible with unsigned
buffer formats.

The int64_t and uint64_t types can currently only be used by bool
properties (see IS_DNATYPE_BOOLEAN_COMPAT and the other macros in
RNA_define.hh), but bool properties only have raw access when they do
not use a bitmask and it doesn't make much sense to use an entire 64
bits just for a single bool property, so PROP_RAW_INT64 and
PROP_RAW_UINT64 are expected to be unused.

Performance Changes

Providing raw types allows for faster access through
rna_access.cc#rna_raw_access, especially when a buffer compatible with
the property's raw type is passed through from
bpy_rna.cc#foreach_getset.

Before this patch, the bpy.types.Keyframe.handle_left_type property
did not have raw access, so foreach_getset would fall back to
PROP_RAW_INT being the compatible type and then use the slower loop in
rna_raw_access.

With this patch, the bpy.types.Keyframe.handle_left_type property has
raw access with the PROP_RAW_UINT8 type. Using a buffer compatible
with this raw type can use the faster memcpy loop in
rna_raw_access. Using a Python list will iterate the list into an
array whose type matches PROP_RAW_UINT8, which will also use the
faster memcpy loop in #rna_raw_access.

Pull Request: https://projects.blender.org/blender/blender/pulls/115761
2024-01-10 18:19:24 +01:00
Brecht Van Lommel
5cc0c0671e Fix: build error when not using unity build 2024-01-10 18:06:28 +01:00
Miguel Pozo
31d8a6514f Fix: EEVEE(Legacy): Broken dielectric material shading
sss_radius r and g are already used for occlussion workarounds.
Use only sss_radius.b for flagging sss as disabled.
Regression from 2942147079.
2024-01-10 17:59:20 +01:00
Miguel Pozo
f2bc8108ef Fix #116964: EEVEE(Legacy): Crash during render
Fix shader compilation.
Update and add missing functions pre-declaration.
2024-01-10 17:55:29 +01:00
Hans Goudey
66dc0ebf2e Fix #104926: Object Info node doesn't give negative scale
The previous behavior was giving a completely negated scale
if any of the object's original scale values was negative. Restore that
behavior here.

Pull Request: https://projects.blender.org/blender/blender/pulls/116989
2024-01-10 17:35:53 +01:00
laurynas
0d964f91a2 Curves: Add extrude operator
Adds extrude operator to new curves. Press key E in edit mode to invoke.
It works correctly on Bezier curves also, but result is weird as there is no
way to control Bezier handles interactively. Currently operator works the
same way as in old curves.

Algorithm idea is same as in https://archive.blender.org/developer/D15524

Pull Request: https://projects.blender.org/blender/blender/pulls/116354
2024-01-10 17:26:54 +01:00
Miguel Pozo
bbf1e506f8 Fix: EEVEE: Fix crash on start
Add missing function pre-declaration.
Partially fixes issue ##116964.
(Render no longer crashes, but shading is broken)
2024-01-10 16:30:50 +01:00
Miguel Pozo
0681d79611 Fix: EEVEE-Next: Crash on start
Regression from 93b3553697
eevee_sampling_lib is still needed for sample_cylinder
2024-01-10 15:53:37 +01:00
Jacques Lucke
522f9c9834 Volumes: improve tree access token api
There was one functional issue with the previous API which was its
use in `VolumeGrid<T>::grid_for_write(tree_token)`. The issue was
that the tree token had to be received before the grid is accessed.
However, this `grid_for_write` method might create a copy of the
`VolumeGridData` internally and if it does, the passed in `tree_token`
corresponds to the wrong tree.

The solution is to output the token as part of the method. This has two
additional benefits:
* The API is more safe, because one can't pass an r-value into the methods
  anymore. This generally shouldn't be done, because the token should
  live at least as long as the OpenVDB tree is used and shouldn't be freed
  immediatly.
* The API is a bit simpler, because it's not necessary to call the
  `VolumeGrid.tree_access_token()` method anymore.
2024-01-10 15:20:29 +01:00
YimingWu
991902cb28 GPv3: Subdivide operator
Subdiv operator for GP3 implemented using the new curves and array APIs.

Compared to the old one, this implementation added a "keep_shape" property
so we could take advantage of the improved `smooth_curve_attribute()` function.

Pull Request: https://projects.blender.org/blender/blender/pulls/116740
2024-01-10 15:16:30 +01:00
Omar Emara
9e358fcd44 Compositor: Redesign Sun Beams node
This patch redesigns the Sun Beams node. The old implementation produces
unexpected results with an arbitrary alpha channel, due to the use of a
step count normalization instead of a weighted normalization. The
quality is also questionable due to the use of nearest neighbour
interpolation as well as a low resolution integration.

This patches redesign the node to be a simple line integration towards
the source, limited by the maximum ray length. The sampling resolution
covers the entire path of the integration and the image is sampled using
bilinear filtering, producing smoother results. No alpha is introduced.

Pull Request: https://projects.blender.org/blender/blender/pulls/116787
2024-01-10 14:30:58 +01:00
laurynas
70fe812ef1 Curves: Add "As NURBS" option to draw tool
Add an option to output curves as NURBS instead of Bezier. The same
fitting algorithms are used. The only difference is that the drawing
result is a NURBS curve with Bezier knot mode, instead of a native
Blender Bezier curve.

Pull Request: https://projects.blender.org/blender/blender/pulls/116696
2024-01-10 13:59:59 +01:00
Campbell Barton
d9d9b12e79 Fix error in mirror modifier UI only checking X axis bisect 2024-01-10 23:45:07 +11:00
Campbell Barton
59dc67974a PyAPI: support returning non ID types when accessing Context.property
Previously accessing properties without an associated ID would return
None, even when the non-ID data was available.

Ref !116981
2024-01-10 23:43:29 +11:00