Commit Graph

105811 Commits

Author SHA1 Message Date
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
Clément Foucault
20ccaa9d67 Fix: EEVEE-Next: HiZ: Wrong specialization constant default value 2024-01-10 22:46:43 +13:00
Clément Foucault
baa7f15476 Cleanup: EEVEE-Next: Remove unused random noise in lightprobe_eval
This is not needed as we want a noiseless evaluation.
2024-01-10 22:46:43 +13:00
Clément Foucault
01eef7dc56 EEVEE-Next: Enable subgroup optimization on Metal
This doesn't seem to offer a lot of benefit but it is the
way it should be.

Other area could make use of this later and the
implementation could be supported at the gpu module level.
2024-01-10 22:46:42 +13:00
Clément Foucault
93b3553697 EEVEE-Next: Remove sampling_lib from ray_generate_lib
Avoid top level dependency.
2024-01-10 22:46:42 +13:00
Clément Foucault
b24591baed EEVEE-Next: Split lightprobe volume eval to its own file
Simple cleanup to reduce dependencies in code.
2024-01-10 22:46:42 +13:00
Aras Pranckevicius
19b33496b2 Tests: add IMB_transform tests
Related to PR #116628, ensure the behavior is covered by tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/116959
2024-01-10 08:56:25 +01:00
Pratik Borhade
edd9b377dd Fix #116924: Sculpt undo crash and missing update
Crash is due to accessing higher index of 0 sized array. Fix this by
changing the size of vector.
Missing update seems to be due to wrong PBVH node flags and typo.

Pull Request: https://projects.blender.org/blender/blender/pulls/116935
2024-01-10 08:23:25 +01:00
Campbell Barton
5b9dcbdb8c Cleanup: remove use of scoped defer to ensure memory is freed
Using a single free call is simple and reduces the generated code side.
2024-01-10 14:21:04 +11:00
Campbell Barton
15843b46ab Fix #116854: context.property access crashes when properties have no ID
Missing checks in [0] which didn't account for UI properties without an
ID or failure to create the property path.

[0]: 6ba0346797
2024-01-10 13:46:22 +11:00
Campbell Barton
60e74d1ef7 UV: restore axis alignment support for Smart UV Project
Regression from porting "Smart UV Project" from Python to C
[0] which removed UV island alignment support.

Restore support by adding X/Y aligned rotation to UV pack. Vertical axis
alignment is the default for smart project matching previous behavior.

Resolves #116355.

[0]: 850234c1b1
2024-01-10 12:31:38 +11:00
Campbell Barton
7dce0d7768 Cleanup: suppress invalid warning from GCC 2024-01-10 10:10:47 +11:00
Campbell Barton
65b82c617a Cleanup: use colon after doxygen parameters 2024-01-10 10:04:14 +11:00
Campbell Barton
7020b33e14 Cleanup: remove outdated comment 2024-01-10 10:04:13 +11:00
Campbell Barton
e1f04aee4b PyAPI: remove code for Python 3.10 2024-01-10 10:04:10 +11:00
Campbell Barton
4d9063739c Cleanup: use RNA_STACK_ARRAY define, avoid extra loop 2024-01-10 10:01:40 +11:00
Campbell Barton
edfc566ab9 Unbreak debug build 2024-01-10 10:00:38 +11:00
Thomas Barlow
904b572487 Fix #116807: Crash for large multidimensional bpy property default value
The functions for creating bpy vector properties used fixed size
`default_value` arrays on the stack. The array was not large enough to
store all the default values for larger multidimensional properties,
which would write past the end of the array and start corrupting the
stack, leading to crashes.

The maximum total length of a bpy vector property is 32768 (32x32x32)
which is a little large of an array to be putting on the stack, so the
`default_value` array now uses `blender::Array` and allocates additional
memory if the number of `default_value` elements exceeds its inline
buffer size of 64.

To simplify allocating arrays of the correct size,
#bpy_prop_array_length_parse now fills in `array_len_info->len_total`
when parsing a sequence.

Pull Request: https://projects.blender.org/blender/blender/pulls/116811
2024-01-09 22:40:13 +01:00
Hans Goudey
46f9b7f222 Fix #116961: UV project modifier always adds attribute
Caused by 2396d07f4e
2024-01-09 16:32:53 -05:00
Hans Goudey
339275507d Cleanup: Use math vector types in delaunay triangulation code
Rather than defining a separate vector type just for use here.
2024-01-09 16:21:31 -05:00
Jacques Lucke
2be41131fa Fix: memory leak
Previously, the `ZoneBuildInfo` values were never destructed. That worked, because
it rarely contained any allocations. This changed in b6f8e1396b.
2024-01-09 22:10:11 +01:00
Richard Antalik
f37b2d1907 VSE: Hide retiming keys, when retiming is reset
This prevents making new keys without user input by
`SEQ_retiming_data_ensure()`.
2024-01-09 20:41:49 +01:00
Richard Antalik
3bb6fa9391 VSE: Don't draw unused properties in redo panel
Property `delete_data` was drawn in redo panel, when retiming key is
deleted, but this property is useful only when deleting strips.
2024-01-09 20:37:19 +01:00
Bastien Montagne
f88595e428 RNA/BPY API: Add clear_liboverride option to ID.make_local.
This function had the exacyt same behavior as the 'UI' operators, make
local invoqued on a linked liboverride would make the data local, but
would not clear the liboverride data from it. User then needs to call
this operation again if they want to remove that liboverride data.

The new `clear_liboverride` parameter to `ID.make_local` forces always
clearing any liboverride data, and allows to make a linked liboverride
fully local with a single call.

This option is kept disabled by default, to ensure default behavior
remains unchanged.
2024-01-09 19:49:18 +01:00
Hans Goudey
e6da277918 Fix #116504: Node group assets in "Instance" catalog show twice
That name was missing from the builtin menus list
2024-01-09 13:44:11 -05:00
Falk David
1b65faddd0 Cleanup: GPv3: Require layer when retrieving a drawing
This cleanup changes the `layer` parameter in `get_drawing_at` and `get_editable_drawing_at` to a reference.
This makes it clear that the layer is required for this function.
2024-01-09 18:34:36 +01:00
Lukas Tönne
7981b35064 Fix #114582: Replace unknown node types with an 'undefined' node
When loading an unknown node type from a newer Blender version, the node
storage data cannot be properly loaded. Re-saving the file will then
crash if saving with the same node type idname, since new Blender
versions cannot find the expected storage data.

Loading in older versions should replace unknown node types with a dummy
"Undefined" node that will get loaded as NodeTypeUndefined in newer
versions as well. Custom node types are exempted from this since they
store all data as generic ID properties and can always be fully
serialized.

This is a revised version of the initial attempt in #114803.
Doing the node type fix in the after-linking stage ensures that
versioning code can change outdated node types which might otherwise get
removed by this type check.

Pull Request: https://projects.blender.org/blender/blender/pulls/116908
2024-01-09 18:29:33 +01:00
Iliya Katueshenock
b6f8e1396b Geometry Nodes: refactor indices for zone socket mapping
This simplifies the code that creates the zone socket mappings at the cost of
slightly more memory per zone, which is not significant.

Previously, `IndexRange` was used where it now uses `Vector<int>`.

Pull Request: https://projects.blender.org/blender/blender/pulls/116939
2024-01-09 18:16:43 +01:00
Hans Goudey
9704d5e468 BLI: Add "numbers" math header, decouple C API
Adds a header that defines the same constants as the C++ 20
<numbers> header.

Benefits:
- Decouple our C++ and C math APIs
- Avoid using macros everywhere, nicer syntax
- Less header parsing during compilation
- Can be replaced by `std::numbers` with C++ 20

Downsides:
- There are fewer numbers defined in the C++ standard header
- Maybe we should just wait until we can use C++ 20

Pull Request: https://projects.blender.org/blender/blender/pulls/116805
2024-01-09 18:05:12 +01:00