Commit Graph

337 Commits

Author SHA1 Message Date
Jacques Lucke
26d2c7af0d Nodes: remove field inference test
This test can't easily be updated because it relies on the old socket shape
design before #144119. Parts of it could be done from scratch again, but
most of this stuff is also tested by the new structure type inferencing test
in `bl_node_structure_type_inference.py`.

Pull Request: https://projects.blender.org/blender/blender/pulls/144185
2025-08-08 09:18:46 +02:00
Campbell Barton
87c4f47312 Fix #139585: Blender could erase OS root
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
2025-08-06 23:13:58 +00:00
Sybren A. Stüvel
3d40246e94 Python: add HTTP file downloader
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
2025-08-01 12:27:56 +02:00
Habib Gahbiche
5783c600dc Fix: wrong user count for compositing node tree
**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
2025-07-30 13:18:47 +02:00
Aras Pranckevicius
bedf19f1ca Cleanup: No longer require VSE Strip struct memory layout to never change
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
2025-07-24 20:37:16 +02:00
Hans Goudey
4f372d64d4 Geometry Nodes: Initial very basic list support
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
2025-07-24 16:16:40 +02:00
Habib Gahbiche
25d4ac38b1 Tests: Compositor: add UI test case for undo
Support the compositor in UI tests and add an undo test case involving
a compositing node tree.

Pull Request: https://projects.blender.org/blender/blender/pulls/140595
2025-07-24 11:41:46 +02:00
Jacques Lucke
a57709ca25 Fix #142828: broken socket usage inference for some nodes
The issue was an oversight in f7f18cd0c7.

This patch also adds some unit tests that would have caught this error.

Pull Request: https://projects.blender.org/blender/blender/pulls/143026
2025-07-24 08:13:34 +02:00
Aras Pranckevicius
d89c9c5155 Video: HDR video input/output support
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
2025-07-21 19:26:07 +02:00
Sean Kim
e6b3c2b026 Tests: Add UI test for selecting brush via brush popover
This commit adds a test to ensure that the asset shelf popup works as
expected inside Sculpt Mode.

Related to #141235

Pull Request: https://projects.blender.org/blender/blender/pulls/141250
2025-07-15 02:09:48 +02:00
Sean Kim
92e9a6d9f1 Tests: Add Multires Apply Base test
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
2025-07-08 22:17:36 +02:00
Hans Goudey
68759af516 Attributes: Use AttributeStorage for curves and Grease Pencil
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
2025-07-01 16:30:00 +02:00
Ian Yoo
c189f2f3ce Compositor Tests: Reorganize folders to match node groupings
This addresses issue #120949 to move compositor tests to reflect the
grouping used when adding a new node.

This PR only moves the relevant single tests and their renders into
matching directories. Folders such as 'multi-node setups' and
'pixel nodes' were not changed.

Pull Request: https://projects.blender.org/blender/blender/pulls/139757
2025-06-26 17:26:59 +02:00
Sean Kim
bf483ae2eb Merge branch 'blender-v4.5-release' 2025-06-23 10:23:17 -07:00
Sean Kim
7274fdb377 Fix #140556: Mask filter operations behave incorrectly on dense meshes
Mistake in 57c4e9dd2c

Pull Request: https://projects.blender.org/blender/blender/pulls/140570
2025-06-23 19:22:33 +02:00
Jacques Lucke
f0c7e52ff2 Core: extract blendfile_header.py as common utility for parsing .blend files
This new file can parse the file header (first few bytes) as well as the block
headers.

Right now, this is used by two places:
* `blendfile.py` which is used by `blend2json.py`
* `blend_render_info.py`

This new module is shipped with Blender because it's needed for
`blend_render_info.py` which is shipped with Blender too. This makes using it in
`blendfile.py` (which is not shipped with Blender) a bit more annoying. However,
this is already not ideal, because e.g. `blend2json` also has to add to
`sys.path` already to be able to import `blendfile.py`.

This new file could also be used by blender-asset-tracer (BAT).

The new `BlendFileHeader` and `BlockHeader` types may be subclassed by code
using it, because it wants to store additional derived data (`blendfile.py` and
BAT need this).

New tests have been added that check that the file and block header is parsed
correctly for different kinds of .blend files.

Pull Request: https://projects.blender.org/blender/blender/pulls/140341
2025-06-23 12:53:55 +02:00
Bastien Montagne
da4eda148b Tests: Add basic save & reload to the 'versioning' tests.
This should allow us to catch significantly more 'sneaky' issues with
writefile and versioning codes in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/140735
2025-06-21 14:06:43 +02:00
Jacques Lucke
1bb49edf7f Geometry Nodes: add structure type inferencing tests
The way these tests work is similar to the existing field inferencing tests.
There is a .blend file that is opened and then we check the inferred structure
types from Python. A new `NodeSocket.inferred_structure_type` property is added
to be able to access this information. Other then the field inferencing tests,
this patch does not directly check the socket shapes, which are not always
exactly determined by the inferred structure type.

This also fixes a few issues I found while adding the tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/140520
2025-06-18 08:39:01 +02:00
Bastien Montagne
e28a714245 Merge branch 'blender-v4.5-release' 2025-06-16 16:31:38 +02:00
Bastien Montagne
b6cccca661 BMesh: Python: Add minimal API test for bmesh.
Hopefully will avoid critical failures like #140451 in the future.
2025-06-16 16:18:41 +02:00
Clément Foucault
4fe75da973 EEVEE: Remove all remaining reference of EEVEE next
This changes the engine identifier back to `BLENDER_EEVEE`.

We keep the `BLENDER_EEVEE_NEXT` identifier around for
versioning reasons (have to detect when it is the active
engine of a older file).

This also rename a bunch of pannels that were using `next`
in their name.

This is a breaking change for Addons compatibility.

Pull Request: https://projects.blender.org/blender/blender/pulls/140282
2025-06-13 12:36:14 +02:00
Sean Kim
187d27b2ec Merge branch 'blender-v4.5-release' 2025-06-12 11:28:37 -07:00
Sean Kim
f77b1e871d Tests: Add UI tests that verify loading all default workspaces
While individual modes have UI tests related to undo, this new set of
tests in this new file is intended to be a set of very broad sanity
tests that catch the most egregious errors that cause crashing on start
up, whether due to python errors, UI rendering issues, or otherwise.

Running these tests takes approximately 4 seconds currently as it adds
and verifies the loading of each of the workspaces available "out of
the box" to a blender user.

Pull Request: https://projects.blender.org/blender/blender/pulls/139318
2025-06-12 20:27:38 +02:00
Sean Kim
c8e5043999 Merge branch 'blender-v4.5-release' 2025-06-11 21:27:13 -07:00
Sean Kim
98739b6b53 Tests: Add Sculpt tests that verify each brush strength curve preset
This commit adds 9 tests that check each of the default brush curve
strength preset options to ensure that none of them cause NaN
propagation. In total this takes approximately 0.7s to run to run.

By design, these tests are very broad and are not a replacement for
other testing, but they should help in reducing the chance of potential
regressions.

Related to #140162

Pull Request: https://projects.blender.org/blender/blender/pulls/140242
2025-06-12 06:26:05 +02:00
Aras Pranckevicius
5ad6d42c83 IO: Remove Collada import/export
Removes Collada import/export (has been deprecated since 4.2).

Pull Request: https://projects.blender.org/blender/blender/pulls/139337
2025-06-06 08:38:57 +02:00
Alaska
e71a1bbf70 Tests: Allow OptiX to run tests in the OSL folder
In the render test suite there is an OSL folder that contains tests that
need OSL to function.

Previously due to some missed logic, the OptiX OSL test suite would not run
tests in that folder because part of the test code assumed that if you aren't
testing on a CPU, then your device doesn't support OSL.

This commit fixes this issue.

Along with this change, some logic was changed in preparation for allowing
OptiX OSL camera tests to run without OSL shading enabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/139433
2025-06-03 14:46:32 +02:00
Sean Kim
de454c3329 Tests: Add dyntopo brush stroke and toggle undo test
Tests that mixing dyntopo and normal mesh sculpting works as well as
manually toggling dyntopo on and off while undoing / redoing.

Pull Request: https://projects.blender.org/blender/blender/pulls/139315
2025-05-27 17:44:28 +02:00
Sean Kim
f6abef2aaf Tests: Add undo test for Sculpt trim tool
For Sculpt Undo, certain operators will modify the topology count of the
mesh. These operators are handled separately from normal brush strokes,
and so having tests for an operator that uses this functionality is
beneficial in detecting regressions.

Pull Request: https://projects.blender.org/blender/blender/pulls/139249
2025-05-22 05:48:07 +02:00
Alaska
1c1e2f1371 Fix: Render test failures when building without fluid modifier
When building Blender WITH_MOD_FLUID=OFF, the OpenVDB render tests
would fail as some of them make use of the WITH_MOD_FLUID features.

This commit fixes this by disabling OpenVDB render tests unless
WITH_MOD_FLUID is active.

Pull Request: https://projects.blender.org/blender/blender/pulls/138728
2025-05-13 05:07:45 +02:00
Jacques Lucke
18365a88bd Geometry Nodes: initial Import node regression tests
This adds some basic tests for the Import OBJ/STL/PLY nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/138700
2025-05-10 07:24:33 +02:00
Sergey Sharybin
bbfc97ad6f Move tests/data and assets to the main repository
This change moves the tests data files and publish folder of assets
repository to the main blender.git repository as LFS files.

The goal of this change is to eliminate toil of modifying tests,
cherry-picking changes to LFS branches, adding tests as part of a
PR which brings new features or fixes.

More detailed explanation and conversation can be found in the
design task.

Ref #137215

Pull Request: https://projects.blender.org/blender/blender/pulls/137219
2025-05-05 15:10:22 +02:00
Clément Foucault
877abbe9f7 Cleanup: EEVEE: Remove next from EEVEE-Next from tests suite
It makes no sense to keep this suffix now that eevee-next is default.

Pull Request: https://projects.blender.org/blender/blender/pulls/138271
2025-05-01 17:54:22 +02:00
Jesse Yurkovich
ba60868477 USD: Animated camera property import
Imports in the following animated data from UsdGeomCameras:
- Focal length
- DOF distance
- DOF fstop
- Clip start, Clip end
- Tilt shift x, Tilt shift y
- Aperture sizes (with caveats)

Implementation wise, it's more complicated than I'd like due to needing
to read in both non-animated and animated data for each property. And
because I've tried to reduce the duplication of various transforms we
have to do on each value. E.g. scaling values by "tenth of scene units"
or the extraction of the USD clipping range from a GfVec2f into 2
separate properties, and 2 separate fcurves, in Blender etc. The current
approach was the best I could come up with so far.

Aperture sizes remain problematic for import, with animation data and
without, due to how Blender selects the largest sensor dimension to base
downstream calculations on and for which there's no concept in USD to
strictly dictate which dimension to use. Additionally, changing the
sensor size will impact the Tilt values as well. This means that if the
Aperture sizes are animated, we must also animate the tilt values; leads
to more fcurves being created than perhaps expected.

The `projection` attribute (perspective and orthographic) remains
unchanged (non animated only) due to differences in how USD<>Blender
interoperate with the Orthographic projection method. Note: Blender only
exports perspective cameras due to the same reason.

Pull Request: https://projects.blender.org/blender/blender/pulls/137487
2025-04-25 19:57:12 +02:00
Sean Kim
e27be7cfc6 CMake: Rename and expose 'USE_EXPERIMENTAL_TESTS' option
The `USE_EXPERIMENTAL_TESTS` variable was not exposed as an option, so
the two tests that use the option to check whether tests should be run
had to be manually enabled by changing `tests/python/CMakeLists.txt`.

This commit renames the variable to `WITH_TESTS_EXPERIMENTAL`, defaults
the option to `OFF`, and marks it as an advanced option.

Pull Request: https://projects.blender.org/blender/blender/pulls/133831
2025-04-24 06:11:30 +02:00
Clément Foucault
dde18802a5 GPU: Remove WITH_GPU_RENDER_TESTS_SILENT option
This was introduced during EEVEE-next developement
cycle to not make the buildbot fail because of EEVEE
render tests.

These have stabilized now and we can remove this option.

Pull Request: https://projects.blender.org/blender/blender/pulls/137545
2025-04-15 17:56:16 +02:00
Jacques Lucke
c11055c1cf Geometry Nodes: enable closure regression tests
Some special care had to be taken because these tests require an experimental
feature to be turned on to work.

Pull Request: https://projects.blender.org/blender/blender/pulls/137414
2025-04-13 13:55:23 +02:00
Sean Kim
898e6f3687 Paint: Ensure brushes are loaded when requested while in background mode
Depending on internal details of how Blender is run, attempting to load
elements from the asset library may either execute as synchronous &
blocking or asynchronously.

When executing a script in background mode, prior to this commit,
operators that are dependent on the asset system will not execute
correctly due to the loading not being complete.

Busy-waiting for this by repeatedly calling the operator over and over
again in python does not resolve. To match behavior of other operators
when called from python scripts such as the quadriflow remesh, this
commit changes the `brush.asset_activate` operator and dependent code to
force a blocking call instead of optionally using the wmJob background
abstraction system.

Related to #117399

Pull Request: https://projects.blender.org/blender/blender/pulls/134203
2025-04-10 22:09:06 +02:00
Brecht Van Lommel
4970bac061 Tests: Properly disable tests when data directory is missing
And clean up cmake output to be less verbose.
2025-04-07 16:29:14 +02:00
Campbell Barton
f48b4e3abf Cleanup: wrap long lines for CMake 2025-04-05 20:30:37 +11:00
Campbell Barton
f89cf19ba6 Cleanup: indentation for CMake files, strip trailing space 2025-04-02 03:01:59 +00:00
Christoph Lendenfeld
e4d3a52ed6 Anim: Unit Tests for baking code
No functional changes.

This patch adds unit tests for the animation baking code in `anim_utils.py`.
It is by no means exhaustive but it is a start to figure out what this function
is actually doing.
With the usage of the legacy python API I was worried things might not work as
expected but all added tests pass.
Also, the tests document the current behavior without any attempt of declaring
that behavior as good or correct.

Pull Request: https://projects.blender.org/blender/blender/pulls/135583
2025-03-27 12:56:46 +01:00
Sean Kim
38870d17e6 Build: Allow UI tests to run locally on all platforms
This commit allows the `WITH_UI_TESTS` CMake option to be used on all
platforms, not only Linux. The existing functionality to use the Weston
compositor was moved into the `WITH_UI_TESTS_HEADLESS` option. When
these tests are run with only `WITH_UI_TESTS`, a visible instance of
Blender is opened up for testing.

Pull Request: https://projects.blender.org/blender/blender/pulls/135889
2025-03-14 22:27:50 +01:00
Sean Kim
956a0fad80 Sculpt: Expose location parameter for sculpt.mask_by_color
Currently, there is no way to call the sculpt.mask_by_color operator
from the python API without simulating mouse events. This makes writing
python tests harder than it needs to be.

This commit does the following:
* Adds an exec callback for the mask_by_color operator.
* Adds new `location` property, an int array defined in region space
  coordinates to represent the mouse location.
* Extracts logic into a helper function so that the `invoke` and `exec`
  paths are functionally equivalent.

Pull Request: https://projects.blender.org/blender/blender/pulls/134964
2025-02-26 01:28:24 +01:00
Sean Kim
8fef9214a7 Tests: Move sculpting render tests out of WITH_GPU_RENDER_TESTS
Adds a new CMake option so that these tests can be run independently of
other tests, and so that existing tests that use WITH_GPU_RENDER_TESTS
are not forced to run these sculpt tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/134893
2025-02-21 20:31:57 +01:00
Miguel Pozo
9f003ee722 Merge branch 'blender-v4.4-release' 2025-02-20 17:21:53 +01:00
Miguel Pozo
ba3749ad47 Overlay: Add tests
This adds support for Overlay tests.

There are some differences with how we handle tests for other engines:
- The renders are captured using `bpy.ops.render.opengl()`, but this
  won't work on our GPU build bots.
- A single blend file can run multiple tests by outputting a txt list
  with the test names.
- Each overlay test blend file requires a matching script file with
  the same name inside `tests/python/overlay/`.
- To reproduce a specific test state you can run
  `blender "(...)/tests/data/overlay/<test>.blend" -P "(...)/tests/python/overlay/<test>.py" -- --test <test-number>`.

Note:
The current test permutations are WIP, so reference images are not
committed to the data repo for now.

Pull Request: https://projects.blender.org/blender/blender/pulls/133879
2025-02-20 17:18:59 +01:00
Campbell Barton
5087246f39 Cleanup: strip trailing space, sort file lists 2025-02-16 20:42:16 +11:00
Habib Gahbiche
bf4af64809 Cleanup: Tests: remove unnecessary --gpu argument
Pull Request: https://projects.blender.org/blender/blender/pulls/134582
2025-02-14 18:02:31 +01:00
Habib Gahbiche
0db8710df7 Compositor: Regression tests for File Output Node
The patch adds a simple framework to test the File Output Node in the compositor. The main difference to the existing `render_test.py` framework is that multiple output images are supported. Edge cases such as empty output or too many outputs are supported as well.

Tests can be run like other compositor tests, e.g. `ctest -R compositor_cpu_file_output --verbose` or `BLENDER_TEST_UPDATE=1 ctest -R compositor_cpu_file_output` to update failing tests.

Sample output:
```
...
119: [ RUN      ] Running test single_color...
119: [  PASSED  ] Passed
119: [ RUN      ] Running test png_passes...
119: [  PASSED  ] Passed
119: [ RUN      ] Running test mixed...
119: [  FAILED  ] Test directory /home/guest/blender-git/blender/tests/data/compositor/file_output/mixed does not exist
119: [ RUN      ] Updating test mixed...
119: [ RUN      ] Running test no_files...
119: [  PASSED  ] Passed
...
```

Parent task: https://projects.blender.org/blender/blender/issues/125893

Pull Request: https://projects.blender.org/blender/blender/pulls/133663
2025-02-14 16:17:18 +01:00