Commit Graph

105623 Commits

Author SHA1 Message Date
Brecht Van Lommel
71474da5fd Fix RNG memory leak on various error conditions
This memory leak shows up in the flaky blendfile_versioning test, and
this may help fix it.
2024-01-02 17:21:30 +01:00
Sybren A. Stüvel
cd8f1853ed Anim: replace bone_collection.find_index() with .index property
Replace the RNA function `bone_collection.find_index()` with a read-only
property `.index`. The functionality is the same, just exposed to RNA
differently.

Note that this property still does an array scan, and thus has complexity
`O(n)` in the number of bone collections. Since this number is relatively
small, this shouldn't be a problem.
2024-01-02 16:55:55 +01:00
Sybren A. Stüvel
631da7a475 WM: document some options of the bpy.ops.wm.read_homefile operator
Add documentation for `bpy.ops.wm.read_homefile` options
`use_factory_startup` and `use_empty`.
2024-01-02 16:55:55 +01:00
Brecht Van Lommel
1f3ce2a311 Build: changes to macOS build flags to fix linker warnings
* Different fix for Mantaflow linker warnings that works with new OpenVDB.
* Use new linker for arm64 as it no longer produces warnings with latest
  Xcode. Still use the old one for x86_64 as some warnings remain.
* Fix wrong x86_64 build target in deps builder.

For the upcoming 4.1 libraries.

Ref #113157

Pull Request: https://projects.blender.org/blender/blender/pulls/116708
2024-01-02 16:22:48 +01:00
Michael Kowalski
c6d61e8586 USD: Support armature and shape key export
New functionality to export armatures and shape keys as USD
skeletons and blend shapes.

Added "Armature", "Only Deform Bones" and "Shape Key" USD export options.

Added USDArmatureWriter class.

Extended USDMeshWriter to write skinned meshes for binding
with skeletons and 'neutral' meshes with blend shape targets.
Specifically, when exporting an armature, a skinned mesh is written
in its pre-modified rest position.  When exporting to blend shapes,
a mesh with shape keys is saved with its vertices in the shape key
basis shape position.

Added USDHierarchyIterator::process_usd_skel() function to
finish processing skeleton and blend shape export after the
writer instances completed writing.  This is necessary because
some of the export operations require processing multiple prims
at once.

Extended USDTransformWriter::do_write() to write transforms
sparsely, to avoid saving redundant transform values when exporting
armatures.

Added a create_skel_roots() function, called on the stage at the
end of the export.  This function attempts to ensure that skinned
prims and skeletons are encapsulated under SkelRoot primitives,
which is required in USD for correct skinning behavior.

When exporting blend shape animations for multiple meshes bound
to a single skeleton, we need to merge the blend shape time samples
of the different meshes into a single animation primitive at the end
of the export.  This requires some tricky book keeping, where the weight
time samples for a given mesh are initially saved by the mesh writer to a
temporary attribute on the mesh and are later copied to the animation
primitive as one of the final steps.

When writing blend shapes and skinned meshes, the pre-modified mesh
is exported.  This is to ensure that the number of blend shape offsets
matches the number of points, and so that the skinned mesh is saved in
its rest position.

Because the pre-modified mesh must be exported, modifiers in addition
to Armature modifiers will not be applied.  This still allows the round trip
UsdSkel -> Blender -> UsdSkel, but some additional setup might be
required to export to UsdSkel when there are multiple modifiers (for
example, applying mirroring modifiers that precede the armature
modifier).

Exporting bendy bones or absolute shape keys isn't currently
supported.

Co-authored-by: Charles Wardlaw <charleswardlaw@noreply.localhost>
Pull Request: https://projects.blender.org/blender/blender/pulls/111931
2024-01-02 15:51:39 +01:00
Brecht Van Lommel
4190a61020 Cleanup: move CMake test utility functions into testing.cmake
Combining functions from macros.cmake and Modules/GTestTesting.cmake.
It was unusual to have Blender specific code in the Modules folder.
2024-01-02 15:34:52 +01:00
Sybren A. Stüvel
9f38c6e887 Anim: Add bone_collection.parent accessor to RNA
Add a read-only property `bone_collection.parent` to RNA that returns
the parent bone collection.

This performs two scans of the array (one to find the bone collection's
index, and the other to find the parent index). This might look bad, but
as long as `Object.children` still loops, in Python, over all of
`bpy.data.objects`, this should also be acceptable.
2024-01-02 12:49:04 +01:00
Clément Foucault
86d008d112 Metal: Fix missing new line characters
This broke compilation of some shaders
2024-01-01 11:29:04 +13:00
Clément Foucault
1c96d0d861 Metal: Improve shader logging
This adds some `#line` directive between the
source file injection so that the log parser knowns
which file the errors originated from.

This is then followed by a scan over the combined
source to find out the real row number.

This needed some changes in the `Shader::plint_log`
to skip lines to avoid outputing redundant information.
2024-01-01 00:43:09 +13:00
Clément Foucault
1e7a2fe483 GPU: Fix wrong error lines in tests
This was caused by the addition of the
license headers. This is not very
important but allow debugging failling
tests.
2024-01-01 00:34:29 +13:00
Clément Foucault
f639a6fd03 EEVEE-Next: Replace gl_LocalInvocationID by gl_LocalInvocationIndex
This saves some uneeded operations in many cases.
2023-12-31 20:13:28 +13:00
Clément Foucault
6e42b6e7c7 Fix: EEVEE-Next: Broken surfel cluster shader compilation
This was because of a missing flag.
2023-12-31 20:09:15 +13:00
Clément Foucault
fa5c9ae0b2 Metal: Remove warning about dummy attribute
This dummy attribute is never in an interface
and is there only to workaround the strict
requirement of a VBO in a GPUBatch.
2023-12-31 18:58:04 +13:00
Hans Goudey
854d7afa1e Cleanup: Use FunctionRef instead of std::function
This is clearer about the lack of need for ownership of callback
data and can be faster as well.
2023-12-30 20:16:03 -05:00
Jason Fielder
d721dcd767 Metal: Resolve texture atomic compilation issue
Resolves small issue with native texture
atomic support after addition of fallback path.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/116657
2023-12-31 01:07:47 +01:00
Hans Goudey
715c829290 Fix #116647: Sculpt smooth brushes ineffective with low strength
Logic mistake in ac15db443f.
2023-12-30 13:51:33 -05:00
Hans Goudey
255ac188a9 Fix #115400: "Face Sets from Visible" missing undo and redraw
Now that we only redraw (and push undo steps for) changed PBVH nodes,
we need to do that for the case where everything is visible and we
remove the face set attribute. Extract that to a separate function in
order to keep the optimization to only do work for changed PBVH nodes.
2023-12-30 12:36:29 -05:00
laurynas
6f5139cdca Fix: all curves drawn cyclic if "cyclic" attribute exists
All curves are drawn cyclic despite "Cyclic" state in redo panel if at
least one was created cyclic. Also patch adds support of "Cyclic" in
redo panel for "Poly" curves. It is ignored in "old curve" draw tool.

Pull Request: https://projects.blender.org/blender/blender/pulls/116638
2023-12-30 15:55:21 +01:00
Iliya Katueshenock
c428b5871c Fix #116614: Empty Point Cloud crash Points to Curves
Offset accumulation cause crash for empty domain. Simple fix as early return for is empty curve offset.

Pull Request: https://projects.blender.org/blender/blender/pulls/116640
2023-12-30 01:20:00 +01:00
Habib Gahbiche
d0c53b58bc Cleanup: Make format
Pull Request: https://projects.blender.org/blender/blender/pulls/116643
2023-12-30 01:01:15 +01:00
Clément Foucault
7d6b8737bf Fix #116623: GL/VK: Specialization constant error
Using defines leads to syntax errors. Use global
constants instead.
2023-12-30 11:09:15 +13:00
laurynas
719d1176f8 Fix #116019: Solidify Crease Inner not working with edge crease attribute
Prevents creation of redundant edge layer "crease_edge.001"

Pull Request: https://projects.blender.org/blender/blender/pulls/116491
2023-12-29 21:16:49 +01:00
Hans Goudey
2396d07f4e Fix #115857: UV project modifier crash with invalid name
Caused by 2a1ac6145a

If the attribute creation failed, the modifier would try to fill in a
null UV map. The combination of CustomData and attribute API functions
was a bit confusing, so restore the old behavior more explicitly using
just the attribute API (including the slightly weird "Float2" default
name. That could be changed later.)
2023-12-29 15:08:59 -05:00
Hans Goudey
7ed172336f Cleanup: Return attribute unique name string by value
Simplifies the code in this area, makes it work better with other C++
code. The max length argument isn't used anymore. But at that point we
wouldn't necessarily have a unique name anyway, which opens up for other
failures.
2023-12-29 15:08:59 -05:00
Habib Gahbiche
898c44bca1 Fullframe compositor: unify size inference with GPU compositor part 2
Followup to #114755. Initialize operation results explicitly if the input is constant. This patch unifies the size inference behavior of the following nodes/operation:
- Flip node
- Kuwahara (classic)
- Lens distortion
- Tonemap node

Pull Request: https://projects.blender.org/blender/blender/pulls/115733
2023-12-29 18:09:57 +01:00
Hans Goudey
8555c22ced Cleanup: Slightly improve virtual array docs 2023-12-29 10:51:26 -05:00
Pratik Borhade
6b0ecd9601 Fix #116581: DoF Aperture Ratio for Camera has incorrect softmin value
Horizotal blur is achieved when ratio is `< 1` but it's not possible
to slide below 1. So make softmin=hardmin (0.01) to give more control
in user interface.

Pull Request: https://projects.blender.org/blender/blender/pulls/116625
2023-12-29 13:09:35 +01:00
Alexander Gavrilov
34b04b625c Anim: fix bone collection custom property copying on armature join
The armature join operation should preserve custom properties,
as described in the comment in the code. Previously this was
achieved by reusing the collection instances from the armature
being joined, but it was changed to create a new instance. However,
property copying was not implemented, which breaks Rigify.

This fix adds property copying behavior back.

Pull Request: https://projects.blender.org/blender/blender/pulls/116626
2023-12-29 12:30:01 +01:00
Clément Foucault
b7a7c2ac00 EEVEE-Next: Add lightweight deferred indirect lighting
This adds option to bypass the raytracing pipeline
entirely and use a cheaper evaluation option.

This reuse the same evaluation as the Blended materials.

This exhibits some artifacts on Apple hardware due to
synchronization issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/116622
2023-12-29 08:34:19 +01:00
Hans Goudey
bd51bb7623 Sculpt: Avoid expensive mask access in remaining cases
In the last couple places, avoid retrieving the mask attribute per
vertex. Use existing attribute data pointers instead. This also avoids
function calls and branches for every vertex, since there is no PBVH
type switch at the lowest level of the loop anymore.
2023-12-28 16:49:31 -05:00
Hans Goudey
27582ddb93 Fix #116532: Cloth filter performance issue from mask attribute access
The cloth filter accesses the vertex mask for every length constraint.
Previously that used a cached pointer, but that was removed, and then
the access was changed to use the attribute API, which is slower since
it isn't designed to be accessed for every element. The solution is
to just let the PBVH type abstraction "leak" when accessing mask data.
2023-12-28 16:49:31 -05:00
Hans Goudey
70ae6f5d41 Cleanup: Sculpt: Add utility to duplicate mask data
Avoid the `PBVHVertRef` abstraction which is unnecesarily costly for
such a simple thing as copying data. Instead we can use abstractions
specific to each PBVH type (currently only `VArray` for meshes).
2023-12-28 16:49:31 -05:00
Hans Goudey
a52887abb0 Cleanup: Improve sculpt variable name 2023-12-28 16:49:31 -05:00
Hans Goudey
ac15db443f Cleanup: Sculpt: Split mask and position smooth brushes
Previously they shared the same implementation with a check per vertex
for whether to smooth the mask or the positions. Though it adds a bit
of duplication for now, everything else becomes simpler if the brush
implementations are split.
2023-12-28 16:49:31 -05:00
Hans Goudey
97d0b52779 Cleanup: Move sculpt cloth simulation struct to sculpt header
This didn't need to be publicly available. Also rename the structs
and enums to avoid redundancy with the C++ namespace.
2023-12-28 16:49:31 -05:00
Hans Goudey
9daa6d8115 Cleanup: Remove unnecessary namespace specification 2023-12-28 16:49:31 -05:00
Clément Foucault
d206907d76 EEVEE-Next: Add debug scopes
Allows selectively capturing section of the
render process. More scopes can be added later.
2023-12-29 10:44:13 +13:00
Michael Kowalski
ea89e11e01 USD: import scenegraph instances.
Added support for importing USD instanceable primitives into Blender
as collection instances.

Added a new USDInstanceReader class for importing USD
instances as Blender objects that instance collections containing
prototype data.

Extended the USDStageReader to read USD prototype prims into
collections that are instanced on the objects created by the instance
readers.

Removed the "Import Instance Proxies" import option.

Importing instances is enabled with a new "Scene Instancing" import
option, which is true by default.  If this option is off, instances will be
imported as copies (which is the functionality previously enabled by
the "Import Instance Proxies" option).

Removed calls to UsdSkelBindingAPI::Apply() in the skeleton and
blend shape import code, as these calls were unnecessary and were
generating errors when importing instance prototypes with UsdSkel
data.

Nested instancing and animated prototypes are supported.

Pull Request: https://projects.blender.org/blender/blender/pulls/115076
2023-12-28 19:08:23 +01:00
Sybren A. Stüvel
d1923eeadc Anim: remove debug print
Remove accidentally-committed debug print.

No actual functional changes.
2023-12-28 18:49:23 +01:00
Sybren A. Stüvel
129fb2eab8 Anim: make bone collections hierarchical
Make it possible to nest bone collections. The data structure on the
armature is still a flat array. It is organised as follows:

- Sibling collections (i.e. ones with the same parent) are stored
  sequentially in the array.
- Each bone collection keep track of the number of children, and the
  index of the first child.
- Root collections (i.e. ones without parent) are stored as the first
  elements in the array.
- The number of root collections is stored on the Armature.

This commit also contains the following:

- Replaced the flat UIList of bone collections with a tree view.
- Updated the M/Shift+M operators (move/assign to collection) to work
  with hierarchical bone collections.
- Updated RNA interface to expose only root collections at
  `armature.collections`. All collections are available on
  `armature.collections.all`, and children at `bonecollection.children`.
- Library override support. Only new roots + their subtrees can be added
  via overrides.

See https://projects.blender.org/blender/blender/issues/115934

Co-authored with @nathanvegdahl and @nrupsis.

Pull Request: https://projects.blender.org/blender/blender/pulls/115945
2023-12-28 18:14:55 +01:00
Sybren A. Stüvel
423ddac25f Cleanup: Anim, clarify comment in rna_def_armature
Instead of `Collections`, describe a section as `Collection Properties`.
Otherwise it's ambiguous whether it's about that or specifically bone
collections.

No functional changes.
2023-12-28 15:58:04 +01:00
Sybren A. Stüvel
a582755321 Anim: Remove OPTYPE_REGISTER flag from some bone collection operators
Remove the `OPTYPE_REGISTER` flag, to ensure the operators do not pop up
their redo panel. The flag is removed where the operator properties are
set by Python code, instead of chosen by the user. For example, it doesn't
make much sense to change which bone collection is used by the operator by
typing the name of another bone collection.

This could be revisited when Blender supports "nested enum" properties,
to make it possible to choose an item in an entire hierarchy.
2023-12-28 15:57:43 +01:00
Sybren A. Stüvel
c019ad2cfe Refactor: rename bonecoll_find_index and move to namespace
Rename `bonecoll_find_index` to `armature_bonecoll_find_index` (because
it takes a `bArmature*` parameter), and move it from a static function into
the `blender::animrig` namespace. It will be used externally in upcoming
commits.

No functional changes.
2023-12-28 15:57:41 +01:00
Sybren A. Stüvel
00efe024fd Cleanup: Anim, document ANIM_armature_bonecoll_move_to_index more
Just some added documentation for `ANIM_armature_bonecoll_move_to_index()`.

No functional changes.
2023-12-28 14:39:54 +01:00
Sybren A. Stüvel
33576de0f6 Cleanup: Anim, reformatting
Just some code reformatting.

No functional changes.
2023-12-28 14:38:51 +01:00
Sybren A. Stüvel
1ff3b546f5 Cleanup: Anim, document bonecoll_ensure_name_unique
Document an assumption of the `bonecoll_ensure_name_unique()` function.

No functional changes.
2023-12-28 14:37:31 +01:00
Sybren A. Stüvel
6aa1a869c6 Refactor: Anim, move refresh of active bone collection to own function
Move some of the functionality of `ANIM_armature_runtime_refresh()` into
a function of its own (`ANIM_armature_bonecoll_active_runtime_refresh()`).
It will be called from another place as well in upcoming commits.

No functional changes.
2023-12-28 14:36:05 +01:00
Clément Foucault
553b1b6f1f Cleanup: EEVEE-Next: Change bind_resource syntax
This is just for making it clearer we bind to what
pass we are binding.

Pull Request: https://projects.blender.org/blender/blender/pulls/116597
2023-12-28 10:19:20 +01:00
Omar Emara
dc082f432a Fix #116522: Compositor incorrectly extrapolates values
The GPU compositor incorrectly extrapolates values of RGBA curves node.
That's because the code introduces a half-pixel offset to the color
values since they will be used to sample the curve maps. Those same
values are then used for extrapolation, which shouldn't take the
half-pixel value into account.

This patch fixes that by computing sampler coordinate in a separate
step.

Pull Request: https://projects.blender.org/blender/blender/pulls/116586
2023-12-28 09:25:11 +01:00
Jason Fielder
335d3a1b75 GPU: Add Shader specialization constant API
Adds API to allow usage of specialization constants in shaders.
Specialization constants are dynamic runtime constants which can
be compiled into a shader pipeline state object (PSO) to improve
runtime performance by reducing shader complexity through
shader compiler constant-folding.

This API allows specialization constant values to be specified
along with a default value if no constant value has been declared.
Each GPU backend is then responsible for caching PSO permutations
against the current specialization configuration.

This patch adds support for specialization constants in the
Metal backend and provides a generalised high-level solution
which can be adopted by other graphics APIs supporting
this feature.

Authored by Apple: Michael Parkin-White
Authored by Blender: Clément Foucault (files in gpu/test folder)

Pull Request: https://projects.blender.org/blender/blender/pulls/115193
2023-12-28 05:34:38 +01:00