This PR begins to replace the use of Blender's "BLI_kdopbvh" BVH tree
for meshes with Embree. Embree is a much newer implementation and and
has much better performance characteristics. In particular, building
the BVH is over 5 times faster. Raycasting against the BVH and closest
point sampling is faster as well.
With the extensive usage of the old BVH API across Blender, it's
unrealistic to do a complete replacement in a single PR. This change
focuses on the triangle surface BVH, in cases where the replacement
is relatively obvious. The idea is that enough uses are covered so
that in most use cases only the Embree BVH will be needed.
Because Embree is an optional dependency, there also needs to be a
fallback to use the old API. If we ever wanted to remove the old BVH
implementation we could discuss making it a mandatory dependency.
Test results are different in a few cases because Embree chooses a
different triangle for the arbitrary choice of closest triangle on
either side of an edge. I also had to increase the threshold for the
hair dynamics test, where small differences in any intermediate values
are chaotically amplified.
Next steps are described in #161529.
This was investigated before in !108148.
Pull Request: https://projects.blender.org/blender/blender/pulls/156408
Replace the internal storage of skin radius and the "root" and "loose"
flags with generic attributes with names "skin_modifier_{radius/root/
loose}". File format backward and forward compatibility is maintained,
as is API compatibility. Overall this means the data should be
propagated in more places and supported in Geometry Nodes, node tools,
etc. One possible behavior change is that the default value is not
baked into the type anymore, but the existing operators used to create
the data maintain the old default.
Pull Request: https://projects.blender.org/blender/blender/pulls/162049
Restore the keymap completeness test which has been effectively
disabled since [0].
Address various issues that broke `bl_keymap_completeness.py`.
- Ensure the keymap is loaded in background mode.
- Identify key-maps by name, space & region types.
- Add special handling for tool fallback keymaps.
Ref !162440
[0]: d7d9320f09
Address a long standing limitation with undo: where edit-mode often
prevented edits in other areas from being tracked by undo.
Allows properties in the object/scene to be adjusted while in edit-mode
supporting undo for both edit-mode and global undo steps to co-exist.
Details:
- This works by encoding undo with a "hint"
that the change includes MEMFILE undo changes.
- This hint can be created from property edits -
where we know which kind of property is being edited.
- It can also be calculated before adding a generic undo step,
to check if other data needs a global undo step
(editing a scene or object while in edit-mode for e.g.).
- The undo system checks for this hint and adds a hidden "pre"
MEMFILE undo step in these cases
(the initial MEMFILE undo step is already done at times,
we make use of that).
- Eventually the mode-specific undo step creation can be skipped,
this has been left out as it's a larger change which impacts
each undo system.
- Added tests to support mixing edit-mode mesh and 3d text
with MEMFILE undo.
- When pushing undo steps a check for changes outside
the mode is performed (in parallel, per ID type),
in my own tests the ID scanning overhead is negligible,
even on heavy files.
Resolves: #50423, #75013, #153282.
Ref !161566
Reuse AUDASPACE readers between uncached Sample Sound Frequencies windows
instead of creating a new reader for every window.
Readers are acquired through a small cache associated with the current
`bSound` runtime generation. An RAII lease automatically returns readers after
use, while failed seek or read operations discard potentially invalid readers.
The cache retains at most two idle readers. When all cached readers are in use,
a new reader is created outside the cache lock instead of making concurrent
evaluations wait.
Cached samplers and their reader cache remain alive for evaluations already in
progress when a sound is reloaded or freed.
Previously, the blocklist for volume_instance was only applied to the
OpenGL backend for Intel Windows. While this issue was presumably fixed,
the same issue can also be seen sporadically for the Vulkan backend.
Until the issue has been investigated, it makes sense to blocklist both.
Pull Request: https://projects.blender.org/blender/blender/pulls/162411
Since direct/indirect linked status is now revalidated also after each
linkig operation (see c596762b20), some test expectations were not
correct anymore.
This introduces access tokens to Asset Libraries.
* The access tokens use the same Bearer Authentication as used by
extensions.
* This reset the token if "use_auth_token" is disabled. Actually it set
it to random values and then set it to null, to avoid it lingering in
memory. This could also be implemented for extensions repository.
Pull Request: https://projects.blender.org/blender/blender/pulls/162163
Caused by 8adba33029
When moving the backing of Mesh attributes to `AttributeStorage`,
handling external packed data was missed. This adds explicit support for
it for `CD_MDISPS` data when converting `Mesh` to and from `BMesh`.
Additionally, this fixes a number of issues when handling `.blend` files
that reference external `.btx` files.
* Loading external Multires data in background mode may have failed
previously if the depsgraph was not up-to-date, as the reading process
would unset the `MDisps` `totdisps` value, resulting in a failure when
reading 0 bytes of data
* Saving files to different directories could fail to rebase the
external filepath correctly, this is because the base filepath was
calculated from the `Main` of the owning ID, rather than the target
resulting filepath.
Pull Request: https://projects.blender.org/blender/blender/pulls/162110
Entering Edit Mode on a mesh with shape keys could copy the final
mesh component after it had already been shared with the edit cage.
The generic component copy did not preserve all
runtime state required by the Edit Mode BMesh wrapper.
The copied final result was subsequently handled by
`MeshRenderData` through the regular `MeshExtractType::Mesh` path,
as though it were an array-backed mesh.
Viewport extraction then attempted to access mesh arrays that
were not available and asserted in `Mesh::faces()`.
Assign the evaluated shape key before sharing the final mesh
component with either the explicit or fallback cage. In Object Mode,
retrieve the final mesh pointer after potential writable
access so copy-on-write cannot leave a stale pointer.
Also add an undo test that would have caught this regression.
Ref !161986
When a hide face set operation is performed in Sculpt Mode, the
`.hide_poly` values are eventually flushed to the `.hide_edge` and
`.hide_vert` attributes. If the mesh has loose elements, and these
attributes are newly created, it's possible that these attribute arrays
will miss initializing some values.
If these values are then used as part of rendering, we may invoke UB and
ultimately a crash.
To fix this, if the attributes are newly created, explicitly fill the
loose elements with the default value of `false`
Pull Request: https://projects.blender.org/blender/blender/pulls/162169
`BKE_main_merge_as_archive_library` would not properly propagate the new
library to embedded IDs, and would miss adding the direct/indirect tag
to all IDs.
Also enable the `link_after_import` related disabled test.
Pull Request: https://projects.blender.org/blender/blender/pulls/162354
The Sequencer Compositor modifier UI checked whether the node group had
at least one interface input before accessing the second input used for
the optional mask.
A node group with exactly one input therefore caused an out-of-bounds
access when an ID mask was assigned and the Strip Modifiers panel was
redrawn.
Require at least two interface inputs before validating the mask input.
Pull Request: https://projects.blender.org/blender/blender/pulls/162031
Activates all tools in the 3D view, sequencer, node editor and image
editor. This can help finding regressions in tool activation, drawing
code or other related code.
Note that the sequencer test fails on Windows AMD64 Intel buildbot
workers. This same failure is already present in another test and seems
related to either a driver issue or the GPU module.
Pull Request: https://projects.blender.org/blender/blender/pulls/161585
Since the same pixel gets used every sample,
the rounding error accumulates and biases the
result instead of averaging out, as we're using
a fixed offset.
Fix by dithering the rounding offset per
sample instead of using a fixed value.
Pull Request: https://projects.blender.org/blender/blender/pulls/161958
Add an initial set of Collection import tests, validating what's there
today and leaving room for what will soon be added/fixed.
Of note, the `test_link_after_import` test is disabled since the
recently committed bb67052433 is causing
asserts. Still debugging the root of the problem.
And the `test_import_multi` test is disabled because I'll need to rework
the Library handling to properly account for this case.
Pull Request: https://projects.blender.org/blender/blender/pulls/162252
Support 2D KDTree's as well as 3D, allowing KDTree's to be built
from 2D data, using 2D coordinates for lookups/searching.
- Add dimension keyword argument for new KDTree's.
- Add KDTree.dimension read-only accessor.
- Add `Doxygen` documentation.
- Update tests.
Ref !159342
This adds a `WindowManager::try_activate_rna_button` method for
activating RNA buttons with an specific state (only `Highlight`,
`WaitKeyEvent`,`NumEditing`, `TextEditing` are support by now) and
returns the center point of the button in window coordinates when
successfully activated (or just highlighted). Any other active button
would be deactivated when activating a button.
This also adds tests for text buttons interactions.
Note: `Ctrl + mouse wheel up/down` string value cycling was not tested
since is not supported in side panels.
Pull Request: https://projects.blender.org/blender/blender/pulls/152910
Add support for setting the minimal/until Blender versions for assets
with markers in the filename. This makes it possible to replace assets
for newer versions of Blender, while keeping the older versions around
for backward compatibility.
The minimal required version of Blender can be encoded in the filename
by using a `@bX_Y` marker, for example `filename@b5_3.blend` if the
assets in that file require Blender 5.3 or newer. This also has an
effect on the file `filename.blend` if it exists, as assets from that
file will get their 'until' field set to 5.3 as well.
A concrete example with three files:
- `filename.blend`: used on Blender versions older than 5.3.
- `filename@b5_3.blend`: used from 5.3 until 6.0 (exclusive).
- `filename@b6_0.blend`: used from 6.0 onward.
This naming scheme has the advantage that the `filename.blend` file
itself does not have to change (and thus does not need re-downloading)
when a successor is added to the library. The only thing that changes is
its asset listing.
Finer granularity than major & minor versions is not possible, so this
does not work to replace an asset between versions 5.3.0 and 5.3.1.
Blender 5.2 already supports the `min` and `until` fields that this
mechanism sets. This PR just adds the functionality to the listing
generator, so that Blender 5.3's generator can be used in a way that
hides incompatible assets from Blender 5.2.
The `min` field is set to the maximum of the marker and the version of
Blender that was used to write the file. So when a file
`filename@b5_3.blend` was written with Blender 5.4, it will still
require Blender 5.4. The generator will log a warning when this occurs.
In this example, the assets in `filename.blend` will be used until 5.3,
as per the marker in the filename.
Pull Request: https://projects.blender.org/blender/blender/pulls/161998
Avoid comparing against exact numbers for gesture based tools, as there
may be slight differences in the viewport based on movement and initial
positioning that make these test too flakey to compare for exact values.
Pull Request: https://projects.blender.org/blender/blender/pulls/161925
Text, metaball, and NURBS surface objects get converted to meshes as
part of depsgraph evaluation and will be detected as a "dupli" which
were then excluded for export; as otherwise we'd get double exports.
However, this exclusion needs to be more selective because such objects
would then be excluded incorrectly if they were inside an instanced
Collection or when instanced through point clouds. Only exclude them if
they are the same original object, preventing duplicate exports but
allowing true instancing to work.
Added new test which instances a Collection of these object types using
both collection instances and point instancing.
Pull Request: https://projects.blender.org/blender/blender/pulls/161710
The buffer was requested without `PyBUF_WRITABLE` so read-only buffers
were accepted (`bytes` for example), then written into by
`RNA_property_collection_raw_get`.
Request a writable buffer so read-only buffers fail the request and fall
back to the sequence path, will raise an exception
(assuming it is read-only too).
Ref !161723
RenderStats::infostr can legitimately be null for render-stat updates
that only refresh timing and UI information.
The Python render stats callback added in f7aeda7c0f forwarded this
null value to BKE_callback_exec_string, causing a crash during
animation rendering when a bpy.app.handlers.render_stats handler was
registered.
Skip Python callback dispatch when no render stats string is available.
This matches the existing behavior of the background render callback and
avoids generating an artificial empty-string event.
Pull Request: https://projects.blender.org/blender/blender/pulls/161786
Two simple tests for the dynamics assets. Also replace the specific
simulation test Python code with a test for a specific custom property
on the scene which tells the test code to run through the frame range
before applying modifiers.
Pull Request: https://projects.blender.org/blender/blender/pulls/159118
Particle Edit undo restored its mode by calling
`ED_object_particle_edit_mode_enter_ex()` directly.
When the undo step was decoded while Texture Paint was active, the
previous mode was not exited first. Since Particle Edit mode entry adds
its mode bit with `|=`, the object ended up with the invalid combined
mode `48` (`TEXTURE_PAINT | PARTICLE_EDIT`).
Exit the current mode through its normal lifecycle before restoring
Particle Edit, following the same pattern used by sculpt undo.
Files that were already saved with mode `48` crashed during editor
initialization because `object_mode_op_string()` returned `nullptr`.
Unsupported saved modes are now rejected safely, leaving the object in
Object Mode while preserving its particle and hair data so the file can
be resaved.
Pull Request: https://projects.blender.org/blender/blender/pulls/161542
Implement optional hardware raytraced shadows for the Workbench engine.
They can be enabled in the `Preferences > Viewport > Quality` settings.
The option will be shown as inactive if the current backend/GPU doesn't
support hardware ray queries (only Vulkan is supported ATM).
A new `gpu.capabilities.ray_query_support_get()` has been added to the
Python API to support this UI functionality.
The visual results are the same as the stencil shadows implementation,
but it provides a significant performance boost on modern hardware.
The raytracing functionality has been implemented in a fragment shader
that mimics the output of stencil-based implementation, so the render
pipeline stays mostly the same.
Co-authored by: Jeroen Bakker
Pull Request: https://projects.blender.org/blender/blender/pulls/161047
Through a convoluted logic the previous AnimData renaming code
basically did:
* For any given ID
* check all FCurves it uses directly for the rename string
(includes owned drivers)
* check all other AnimData in Main if the given ID is being used as
a driver target
When doing that in a loop for many IDs, things can slow down
considerably. The solution is to build a map of ID to the drivers using
it as a target beforehand.
That way, we only have to do loop main once to build the map and
can then reuse it to subsequent calls to the rename function
(which only looks at the given ID)
### Implementation
**Removed `BKE_animdata_fix_paths_rename`**:
Since this function doesn't check for driver targets by looping main,
it missed to rename them leaving invalid drivers behind. When renaming
anything that can be animated it is never correct to ignore driver
targets which is why I removed it. Replaced with calls to
`BKE_animdata_fix_paths`.
**Removed `BKE_animdata_fix_paths_rename_all_ex` and `BKE_animdata_fix_paths_rename_all`**:
This has been replaced with a combination of
`BKE_animdata_build_driver_target_map` and `BKE_animdata_fix_paths`.
By splitting this up we can get the performance
gains when doing many renames at once.
**Added `RNA_path_name_to_infix` and `RNA_path_number_to_infix`**:
The new functions no longer assume anything about the rename string
they are given. Instead the caller has to format the strings accordingly
which is done with this function.
Doing so removes a boolean argument from the API.
In order to get the un-escaped name (which is needed for drivers
targeting pose bones by name) I added `infix_to_name`. This function
is not public because it makes a few assumptions
about the structure of the given string.
**`driver_target_path_fix` no longer verifies the path**
RNA paths for drivers can contain a trailing number like `[0]` to
indicate the array index. For regular rna paths this is usually a
separate integer which is why such paths won't resolve. Verifying the
path would mean that driver targets are not correctly updated, as
confirmed by the unit test that was disabled.
This is now fixed and the unit test was enabled.
### Fixed Issues
Fixes#155262Fixes#159712
Fixes unreported: Drivers targeting VSE strips break if strip is renamed
Depending on the file, this is up to 27x times faster.
Part of #160849
Pull Request: https://projects.blender.org/blender/blender/pulls/160988
This adds code to convert animation from one rotation mode to another.
There are multiple ways to do the conversion:
* Using Ctrl+R in pose mode
* In the 3D viewport, open the "Object" or "Pose" menu, under
"Animation" there is a new entry "Convert Rotation Mode"
* Using the python API `convert_rotation_mode()` either on bones or
objects
**Important Behavior**
* The result of the operation is always a fully keyed rotation, even
if previously only a single channel was keyed. This is the only way
to ensure that the rotations line up.
* Interpolation may not match. In fact it is expected not to.
This is desired for animators for when they are running into gimbal
lock and they just want to try if a different rotation mode works better.
* In case interpolation *has to* match, there is an option to insert
keys on every frame before the conversion.
* key types are somewhat preserved. We assume that for any given
frame, all rotation keys are the same type.
* keys on all related actions are converted, that includes the NLA
Even though the animation data conversion could be triggered
automatically by changes to the rotation_mode RNA property, I chose not
to do that for a reason.
This may be set directly via python in an addon and we shouldn't
include the costly (and maybe unexpected) side effect of converting
animation.
This adds a new operator `anim.rotation_mode_convert` instead of
modifying the existing `pose.rotation_mode_set`.
Since the operator now works with objects as well, it's probably better
to move it out of the `pose` category.
`pose.rotation_mode_set` and `pose.convert_rotation` from rigify are
deprecated with a warning that pops up every time you execute them.
**Implementation**
The core of the changes are in `anim_convert.cc`.
* `convert_to_rotation_mode` is a high level function that converts
the rotation for a single transformable.
* `build_rotation_fcurve_map` and `convert_rotation_keys` are two
functions that work in concert. The first builds the data structure
to quickly find FCurves by their RNA path and the second consumes
that data to do the conversion.
* `bake_rotation_fcurves` utility function to bake FCurves before
converting their rotation.
This uses the `AnimTransformable` class to make this functionality
available to objects and bones at the same time.
When dealing with multiple transformables, we would need to iterate
the action for each to find the FCurves for it.
To avoid that I added `ChannelbagFCurveMap` which is created by
`build_rotation_fcurve_map`.
With that we can easily iterate iterate the FCurves of each Channelbag
sorted by RNA path.
`KeyframeIterator`
Is a new helper class to iterate all frames with keys of N FCurves.
**Deprecates** the existing `POSE_OT_convert_rotation` operator and
removes it from the pose menu.
Resolves#149607Resolves#159131
Design: #137281
UI improvements will be handled in a separate PR: !159981
Pull Request: https://projects.blender.org/blender/blender/pulls/154309
Legacy texture evaluation falls back to the active tessface UV layer
when no UV map is explicitly specified.
After active and default UV map state moved to `Mesh`, legacy tessface
conversion still tried to copy the corresponding indices from corner
`CustomData`. This left the generated `CD_MTFACE` layers using index 0,
so textures with an empty UV map name could sample the wrong UV map.
Resolve the active and default UV map names from the mesh when
generating legacy tessface data, restoring the previous implicit
active-UV fallback.
Pull Request: https://projects.blender.org/blender/blender/pulls/161347
When a liquid mesh cache file was missing or failed to load,
`MANTA::readMesh()` returned without clearing mesh data from the
previously loaded frame.
The stale mesh nodes, triangles, and velocities could then be reused as
valid geometry. This made direct frame jumps inconsistently show either
an older liquid surface or the fluid domain bounds, depending on the
previous evaluation state.
Clear the previous mesh data when the requested cache is unavailable or
fails to load, allowing evaluation to correctly fall back to the domain
geometry.
Pull Request: https://projects.blender.org/blender/blender/pulls/161305
Add a new operator `Replace with duplicate Action`.
Similar to `Replace with new Action` this looks at the action
of the active object and replaces all users of that action with
a duplicate.
Pull Request: https://projects.blender.org/blender/blender/pulls/158258
A scene with 512 lights inside a box, to test that we handle scenes
with many lights correctly.
Disabled in Cycles due to high noise variance between platforms even at
high samples.
Pull Request: https://projects.blender.org/blender/blender/pulls/161009
These tests validate pie menu interactions triggered through simulated
keyboard + cursor drag events across several editors and modes.
This should help find plenty of regressions as it covers a lot of cases
touching many modules.
Covers pies in the 3D View, Graph Editor, Dope Sheet, Sequencer, NLA,
Image Editor, File Browser, Node Editor and Clip Editor.
Pull Request: https://projects.blender.org/blender/blender/pulls/160761
As the vulkan backend is now default, `get_gpu_device_vendor()` returns
the selected GPU for Vulkan. In the rare case that OpenGL uses a
different GPU, this causes render tests to use incorrect tolerances and
possibly fail. The PR adds the GPU backend argument to
`get_gpu_device_vendor()` to avoid this\*.
> \* this = confusing me
Pull Request: https://projects.blender.org/blender/blender/pulls/161255
This fixes two related issues:
1. System files could be replaced when downloading assets. A malicious
asset listing could be constructed that overwrites its own files when
specific assets are downloaded. This was dangerous, because the
listing downloader performs various safety checks while the asset
downloader doesn't (because it's not made for downloading the
listing). The asset downloader now refuses to download any file when
that would potentially overwrite a 'system file' (listing file, file
hash database, those kind of files).
2. Converting asset paths from the listing to a relative path, so they
can safely be concatenated to the local asset cache path, is now more
thorough. It now also properly handles Windows paths that are
drive-relative; these were considered 'relative' by Python's
PureWindowsPath.is_absolute(), but still can cause the downloaded
file to escape the path it is meant to be saved to.
Pull Request: https://projects.blender.org/blender/blender/pulls/161198
Use OpenGL for these tests for now, until we fix this in LLVM or OSL.
Initializing Vulkan is somehow affecting memory allocating so that the
LLVM JIT is not placing code and data sections within 4GB of each other,
which is a requirement on Windows.
Ref #152968
Pull Request: https://projects.blender.org/blender/blender/pulls/160984