Temporary directory handling had a logical error, assuming the
"session" temporary directory was owned and created by Blender
and could be recursively removed on exit.
However, it's possible creating the session sub-directory fails,
in that case the temporary directory was used for the "session".
This meant setting `C:\` as the temporary directory in the preferences
would attempt to recursively remove `C:\` on exit.
Resolve with the following changes:
- Only perform a recursive removal on the temporary directory
if a session sub-directory was created.
- If the creating the user-preferences temporary "session" sub-directory
fails fall back to the systems temporary directory and try to
create the "session" directory there.
Previously this was only done if the preference path didn't exist.
The preferences path was still used if it existed but couldn't be
written to.
Include a test to ensure this is working as expected.
Ref !144042
Add two sets of options to the IO Report class that allows tests to
control the verbosity of output.
- Add `Report.context_lines` controlling how many lines of context the
diff uses when there are failures (3 by default)
- Add `Report.side_to_print_single_line` (5 by default) and
`Report.side_to_print_multi_line` (3 by default) controlling how many
items are written out
The first option helps when a failure in the test might not produce
enough lines of output to know which object is affected. The second set
of options allows individual tests to ensure more values are taken into
consideration for test validation.
They are exposed as class variables due to all the inner methods using
them being static.
Pull Request: https://projects.blender.org/blender/blender/pulls/143922
When adding a shape key, set its blend value to 1.0 / 100%.
There is no practical use case where user wants to add shape key but
not work on it. New shape keys at value 0 have no purpose. Adding
shape key should be interpreted by Blender as user wanting to
sculpt/model on it. Also, being at 1.0 initially doesn't change
anything visually, because key isn't edited yet and it doesn't deform
mesh.
The default value of the shape key is also set to 1.0. When using
right-click to reset values, user most often wants to return to 1
(which is "correct" state of deformation without multiplication)
rather than 0 (which is no deformation at all).
Co-authored-by: Sybren A. Stüvel <sybren@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/133399
Add a new package `scripts/modules/_bpy_internal/http`, containing
classes to download files via HTTP.
The code is intentionally put into the `_bpy_internal` package, as I
don't intend it to be the end-all-be-all of downloaders for general
use in add-ons. It's been written to support the Remote Asset Library
project (#134495), where it will be used to download JSON files (to
get the list of assets on the server) as well as the asset files
themselves.
The module consists of several parts. The main ones are:
`class ConditionalDownloader`
: File downloader, which downloads a URL to a file on disk.
It supports conditional requests via `ETag`/`If-None-Match` and
`Last-Modified`/`If-Modified-Since` HTTP headers (RFC 7273, section 3.
Precondition Header Fields). A `304 Not Modified` response is
treated as a succesful download.
Metadata of the request (the response length in bytes, and the above
headers) are stored on disk, in a location that is determined by the
user of the class. Probably in the future it would be nice to have a
single sqlite database for this (there's a TODO in the code about
this).
The downloader uses the Requests library, and manages its own HTTP
session object. This way it can handle TCP/IP connection reuse,
automatically retry failing connections, and in the future
HTTP-level authentication.
`class BackgroundDownloader`
: Wrapper for a `ConditionalDownloader` that manages a background
process for the actual downloading.
It runs the downloader in a background process, while ensuring that
its reporters (see below) get called on the main process. This way
it's possible to do background downloading, while still receiving
progress reports in a modal operator, which in turn can directly
call Blender's Python API. Care was taken to [not use Python
threads][1]
`class DownloadReporter`
: Protocol class. Objects adhering to the protocol can be given to a
`ConditionalDownloader` or `BackgroundDownloader`. The protocol has
functions like `download_starts(…)`, `download_progress(…)`,
`download_error(…)`, which will be called by the downloader to
report on what it's doing.
I chose to make this a protocol, rather than an abstract superclass,
because then it's possible to make an Operator a DownloadReporter
without requiring multi-classing.
[1]: https://docs.blender.org/api/main/info_gotchas_threading.html
Pull Request: https://projects.blender.org/blender/blender/pulls/138327
Since we are removing `scene.use_nodes` in #143578, most developers
will have to update their python script by replacing `scene.node_tree`
by `scene.compositing_node_group` in order to create a new compositing
node tree anyways. So we remove `scene.node_tree`.
Note: `scene->nodetree` in `scene_blend_write()` is still being written
to the blend file, so forward compatibility is not affected by this PR.
Pull Request: https://projects.blender.org/blender/blender/pulls/143619
Use Nodes were removed in d88d4cc8 from the UI, but marked deprecated
in Python API. Since we decided to remove `world.use_nodes` and
`material.use_nodes` for the shader editor (instead of deprecating
them), we also remove `scene.use_nodes`.
This PR only replaces the deprecated `scene.node_tree` with
`scene.compositing_node_group` where necessary. #143619 will fully
remove `node_tree`
Pull Request: https://projects.blender.org/blender/blender/pulls/143578
**How to reproduce:**
1. Assign a node tree to the scene compositing node group in Python
2. Notice how the node tree has the wrong user count
Example:
```python
C.scene.compositing_node_group = \
D.node_groups.new("ntree", "CompositorNodeTree")
print(C.scene.compositing_node_group.users) # returns 0
```
Pull Request: https://projects.blender.org/blender/blender/pulls/143577
Previously code that was reading Strip data assumed that seqbasep
and channels members would stay at fixed offsets within a struct,
forever into the future. Fix this by inferring their offsets from
the file SDNA data where needed.
Actual Strip DNA layout is not changed in this commit yet.
Co-authored-by: Sergey Sharybin <sergey@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/142940
This includes a new list structure type and socket shape, a node
to create lists, a node to retrieve values from lists, and a node to
retrieve the length of lists. It also implements multi-function support
so that function nodes work on lists.
There are three nodes included in this PR.
- **List** Creates a list of elements with a given size. The values
are computed with a field that can use the index as an input.
- **Get List Item** A field node that retrieves an element from a
a list at a given index. The index input is dynamic, so if the input
is a list, the output will be a list too.
- **List Length** Just gives the length of a list.
When a function node is used with multiple list inputs, the shorter
lists are repeated to extend it to the length of the longest.
The list nodes and structure type are hidden behind an experimental
feature until we can be sure they're useful for an actual use case.
Pull Request: https://projects.blender.org/blender/blender/pulls/140679
Add the new Curves datablock type to the IO report. This was created
for the new hair system but is more generally used for any type of curve
generated within geometry nodes.
The report itself is mostly just a dump of all available attributes for
the object.
Pull Request: https://projects.blender.org/blender/blender/pulls/142925
HDR video files are properly read into Blender, and can be rendered out
of Blender.
HDR video reading / decoding:
- Two flavors of HDR are recognized, based on color related video
metadata: "PQ" (Rec.2100 Perceptual Quantizer, aka SMPTE 2084) and
"HLG" (Rec.2100 Hybrid-Log-Gamma, aka ARIB STD B67). Both are read
effectively into floating point images, and their color space
transformations are done through OpenColorIO.
- The OCIO config shipped in Blender has been extended to contain
Rec.2100-PQ and Rec.2100-HLG color spaces.
- Note that if you already had a HDR video in sequencer or movie clip,
it would have looked "incorrect" previously, and it will continue to
look incorrect, since it already has "wrong" color space assigned to
it. Either re-add it (which should assign the correct color space),
or manually change the color space to PQ or HLG one as needed.
HDR video writing / encoding"
- For H.265 and AV1 the video encoding options now display the HDR mode.
Similar to reading, there are PQ and HLG HDR mode options.
- Reference white is assumed to be 100 nits.
- YUV uses "full" ("PC/jpeg") color range.
- No mastering display metadata is written into the video file, since
generally that information is not known inside Blender.
More details and screenshots in the PR.
Co-authored-by: Sergey Sharybin <sergey@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/120033
This rename creates separation between USD primvars/Blender geometry
attributes - which are not controlled with this setting - and the
concept of USD attributes+userProperties/Blender custom object
properties - that this option deals with.
Ref #134012
Pull Request: https://projects.blender.org/blender/blender/pulls/142301
Reordering layer nodes by drag-drop, move up/down, add new etc. swaps
layer attributes with wrong layers. This is due to mistake in map
`new_by_old_map`. Values of this map is used as indices in src array.
And keys are indices of dst array. Expected behavior is to copy attribute from
old position (`layer_i_old`) of src array to new position (`layer_i_new`) of
dst array. See: `array_utils::gather`.
Noticed during !141772.
Pull Request: https://projects.blender.org/blender/blender/pulls/141935
This fixes 4 bugs all conspiring to make the referenced SubD scenario
quite broken:
- When manually creating a MeshSequenceCache, the reading of edge and
vertex crease data was skipped. Fixed by reading crease data inside
the common `read_mesh` method.
- When importing an Alembic with animated edge or vertex crease data, a
MeshSequenceCache modifier was not being added to the object. This was
due to not checking the relevant crease properties and required adding
a specialized `has_animations` function.
- When importing animated vertex crease data, a duplicate `vertex_crease`
attribute would be created, breaking the animation. Fixed by using the
attribute API rather than custom data.
- The MeshSequenceCache scenario would call into the Alembic Mesh reader
which ended up referencing deallocated stack memory for the
ImportSettings. In release builds this would cause sporadic failures
because the value of `blender_archive_version_prior_44` would be
random. There was already a very old TODO for this and we finally
really needed to address it.
A new test was added which exports animated creases on two meshes and
re-imports them back in. It verifies that each mesh gets a
MeshSequenceCache modifier added and also ensures the values of the
creases are correct for all frames.
Pull Request: https://projects.blender.org/blender/blender/pulls/141646
Some parts of the UI (e.g., the boolean node) had renamed the 'fast'
solver to be the 'float' solver, since with the advent of the manifold
solver, it is no longer really right to characterize the float one
as the (sole) fast one. This commit finishes the job.
It does have the effect of changing the string needed within the
Python API to select the float solver, so this is a (minor)
API-breaking change.
All GPU backends now support NanoVDB, using our own kernel side code
that is easily portable. This simplifies kernel and device code.
Volume bounds are now built from the NanoVDB grid instead of OpenVDB,
to avoid having to keep around the OpenVDB grid after loading.
While this reduces memory usage, it does have a performance impact,
particularly for the Cubic filter. That will be addressed by
another commit.
Pull Request: https://projects.blender.org/blender/blender/pulls/132908
This commit fixes a issue where GPU compositor tests would always run
with the default GPU backend, Metal for macOS, and OpenGL
for other operating systems.
Now tests correctly run on the defined GPU backend, allowing Vulkan
GPU compositor tests to correctly run with the Vulkan GPU backend.
Pull Request: https://projects.blender.org/blender/blender/pulls/141447
This is a basic armature deformation test for #141535 using Lattices instead of
Mesh as the target object type. Lattice deformation was briefly broken, which is
caught by this test.
The test adds the general-purpose `unit_test_compare` function to lattice object
data. It only compares lattice point counts and positions for now, more data can
be added later if necessary.
The `MeshTest` class did not support lattice object types yet, so needed some
changes. The Curves case was already supported, but only by full conversion to
mesh data, without actually using the `unit_test_compare` function specific for
curves geometry. This is unchanged, because applying constructive modifiers on
curves does not work. If it were not for this limitation the test could do
actual curves comparisons now.
For lattice support the `MeshTest` class comparison function has been
generalized to all supported object data types. It runs the appropriate
`unit_test_compare` api function and validation where supported (only meshes at
this point).
Pull Request: https://projects.blender.org/blender/blender/pulls/141546
The mesh importer was only checking for animated positions, velocities,
and primvars when determining if a cache modifier needed to be used.
Extend this to crease values (and normals) too.
The added test ensures a base level of coverage here.
Related to: #141633
Pull Request: https://projects.blender.org/blender/blender/pulls/141643
Adds a new file for testing the Multires Apply Base operator.
This is not included with the other modifier tests as it is a bit of an
exception - the modifier is not applied at the end for comparison
between the expected result and actual result.
Pull Request: https://projects.blender.org/blender/blender/pulls/141571
**Problem Description**
Blender's current mesh data layout often lacks spatial coherence,
causing performance bottlenecks during BVH construction for sculpting
and painting operations. Each time a BVH is built, the system must
recompute spatial partitioning and vertex groupings from scratch,
leading to redundant calculations and suboptimal memory access patterns.
**Proposed Solution**
This patch implements pre-computed spatial organization of mesh data
through a new `mesh_apply_spatial_organization()` function that:
- Reorders vertices and faces based on spatial locality using recursive
spatial partitioning.
- Stores pre-computed MeshGroup hierarchies in MeshRuntime for reuse.
- Enables the BVH system to bypass expensive spatial computation when
pre-organized data is available.
This approach separates the expensive spatial computation from more
frequent BVH rebuilds, providing sustained performance improvements
across multiple sculpting operations.
**Limitations**
- Requires manual invocation (occurs automatically only during remesh
operations).
- Additional memory overhead for storing MeshGroup metadata.
- One-time computational cost during initial organization.
- Spatial group references are not yet stored in files.
**User Interface**
The feature is accessible via a new "Reorder Mesh Spatially" operator in
the Mesh Data Properties panel under the Geometry Data section. Users
can invoke it manually when needed, or it will be applied automatically
during quadriflow and voxel remesh operations. The operator provides
feedback confirming successful spatial reordering.
Pull Request: https://projects.blender.org/blender/blender/pulls/139536
This commit adds a test for the situation in which a AOV pass is used
on a object with a fully or semi-transparent material, either using the
transparent BSDF directly, or mixing it with some other material.
Pull Request: https://projects.blender.org/blender/blender/pulls/141068
This commit moves Curves and Grease Pencil to use `AttributeStorage`
instead of `CustomData`, except for vertex groups. This PR mostly
involves extending the changes from the above commit for point clouds
to generalize to other geometry types.
This is mostly straightforward, though a couple non-trivial places of
note are the joining of Grease Pencil objects (`merge_attributes`), the
"default render fallback" UV for curves objects which was previously
unused at the UI level and just ended up being the first attribute, and
the `update_curve_types()` call in the curves versioning function.
Similar to:
- fa03c53d4a
- f74e304b00
Part of #122398.
Pull Request: https://projects.blender.org/blender/blender/pulls/140936
The issue was that the depsgraph was not rebuilt, thus
the driver node still stuck around. This then crashed when the
depsgraph evaluated.
The reason why this wasn't caught in the unit tests, was because the
depsgraph was not updated between creating and removing the data.
Pull Request: https://projects.blender.org/blender/blender/pulls/141272
Test for armature deform modifier settings that are not yet covered by other tests:
- Vertex Group vs. Envelope deformation and both combined.
- Vertex group masking ('vertex_group' setting of the modifier)
- Inverted vertex group masking
- Preserve Volume (dual quaternions)
- Vertex Group/Envelope influence mixing (bone option)
- B-Bone deformation
- Multi-modifier mixing
Each case has a new test/expected mesh pair in the modifiers test.
Pull Request: https://projects.blender.org/blender/blender/pulls/141054