Commit Graph

1164 Commits

Author SHA1 Message Date
Campbell Barton e3724d29ff Cleanup: autopep8 2022-04-26 15:03:04 +10:00
Campbell Barton bba757ef81 Cleanup: various minor changes
- Add missing doxy-section for Apply Parent Inverse Operator
- Use identity for None comparison in Python.
- Remove newline from operator doc-strings.
- Use '*' prefix multi-line C comment blocks.
- Separate filenames from doc-strings.
- Remove break after return.
2022-04-24 13:41:03 +10:00
Campbell Barton 65a1fcdaf7 Cleanup: run autopep8 on tests/performance/benchmark
This file was skipped by source/tools/utils/autopep8_clean.py
since it doesn't have a .py extension, running the autopep8 tool
recursively detects Python scripts without extensions.
2022-04-20 17:07:46 +10:00
Campbell Barton 3035235def Cleanup: run autopep8 on tests/ 2022-04-19 15:25:55 +10:00
Clément Foucault 1440074cac Tests: Change force disable render test messages to be warnings
These were easilly missable and took some effort to find why the test
were disabled.
2022-04-14 13:10:26 +02:00
Campbell Barton ee292a1d66 PyAPI: use keyword only arguments for Text.region_{from/to} string
This is the convention for most parts of Blender Python API.
2022-04-08 13:28:55 +10:00
Matheus Santos f49a736ff4 Text Editor: Get/Set region text API
Add the ability to get/set the selected text.

**Calling the new methods:**

- `bpy.data.texts["Text"].region_as_string()`
- `bpy.data.texts["Text"].region_from_string("Replacement")`
2022-04-07 15:17:04 +10:00
Olivier Maury 1fb0247497 Cycles: approximate shadow caustics using manifold next event estimation
This adds support for selective rendering of caustics in shadows of refractive
objects. Example uses are rendering of underwater caustics and eye caustics.

This is based on "Manifold Next Event Estimation", a method developed for
production rendering. The idea is to selectively enable shadow caustics on a
few objects in the scene where they have a big visual impact, without impacting
render performance for the rest of the scene.

The Shadow Caustic option must be manually enabled on light, caustic receiver
and caster objects. For such light paths, the Filter Glossy option will be
ignored and replaced by sharp caustics.

Currently this method has a various limitations:

* Only caustics in shadows of refractive objects work, which means no caustics
  from reflection or caustics that outside shadows. Only up to 4 refractive
  caustic bounces are supported.
* Caustic caster objects should have smooth normals.
* Not currently support for Metal GPU rendering.

In the future this method may be extended for more general caustics.

TECHNICAL DETAILS

This code adds manifold next event estimation through refractive surface(s) as a
new sampling technique for direct lighting, i.e. finding the point on the
refractive surface(s) along the path to a light sample, which satisfies Fermat's
principle for a given microfacet normal and the path's end points. This
technique involves walking on the "specular manifold" using a pseudo newton
solver. Such a manifold is defined by the specular constraint matrix from the
manifold exploration framework [2]. For each refractive interface, this
constraint is defined by enforcing that the generalized half-vector projection
onto the interface local tangent plane is null. The newton solver guides the
walk by linearizing the manifold locally before reprojecting the linear solution
onto the refractive surface. See paper [1] for more details about the technique
itself and [3] for the half-vector light transport formulation, from which it is
derived.

[1] Manifold Next Event Estimation
Johannes Hanika, Marc Droske, and Luca Fascione. 2015.
Comput. Graph. Forum 34, 4 (July 2015), 87–97.
https://jo.dreggn.org/home/2015_mnee.pdf

[2] Manifold exploration: a Markov Chain Monte Carlo technique for rendering
scenes with difficult specular transport Wenzel Jakob and Steve Marschner.
2012. ACM Trans. Graph. 31, 4, Article 58 (July 2012), 13 pages.
https://www.cs.cornell.edu/projects/manifolds-sg12/

[3] The Natural-Constraint Representation of the Path Space for Efficient
Light Transport Simulation. Anton S. Kaplanyan, Johannes Hanika, and Carsten
Dachsbacher. 2014. ACM Trans. Graph. 33, 4, Article 102 (July 2014), 13 pages.
https://cg.ivd.kit.edu/english/HSLT.php

The code for this samping technique was inserted at the light sampling stage
(direct lighting). If the walk is successful, it turns off path regularization
using a specialized flag in the path state (PATH_MNEE_SUCCESS). This flag tells
the integrator not to blur the brdf roughness further down the path (in a child
ray created from BSDF sampling). In addition, using a cascading mechanism of
flag values, we cull connections to caustic lights for this and children rays,
which should be resolved through MNEE.

This mechanism also cancels the MIS bsdf counter part at the casutic receiver
depth, in essence leaving MNEE as the only sampling technique from receivers
through refractive casters to caustic lights. This choice might not be optimal
when the light gets large wrt to the receiver, though this is usually not when
you want to use MNEE.

This connection culling strategy removes a fair amount of fireflies, at the cost
of introducing a slight bias. Because of the selective nature of the culling
mechanism, reflective caustics still benefit from the native path
regularization, which further removes fireflies on other surfaces (bouncing
light off casters).

Differential Revision: https://developer.blender.org/D13533
2022-04-01 17:45:39 +02:00
Campbell Barton 27fb63381e Fix T94121: PyAPI: ID property group returns wrong type with iter()
Regression in 265d97556a.
Where iterating directly on a property group failed, e.g.:
`iter(group)`, tests missed this since only `group.keys()`
was checked.
2022-03-11 10:26:27 +11:00
Campbell Barton 0a4fdcbb5f Cleanup: unused Python variables & imports 2022-03-04 11:07:37 +11:00
Campbell Barton 7e4c031328 Cleanup: remove all tweak events from key-map presets 2022-03-02 17:29:27 +11:00
Campbell Barton a4e8b3a9a9 Cleanup: remove check_deprecated.py
This was temporarily added back as the build-bot was running it.
2022-03-01 14:09:03 +11:00
Campbell Barton 81df323df4 Tests: disable file output for bl_keymap_validate.py
Left on by accident but should only be used when debugging output.
2022-02-24 17:43:36 +11:00
Campbell Barton 4addc1f31e Tests: temporarily add back tests/check_deprecated.py
The build-bot directly referenced this file and doesn't
have publically available configuration.

Add an empty file until this can be removed by the build scripts.
2022-02-23 12:30:54 +11:00
Campbell Barton 6bb4c0e498 GNUmakefile: rename test_depracted to check_deprecated
Also move this utility into the source/tools repo.
2022-02-23 00:00:32 +11:00
Campbell Barton 813895f713 Cleanup: use strict type checking for bl_keymap_validate 2022-02-21 12:21:47 +11:00
Campbell Barton 167c4c6962 Tests: add duplicate key-map test, also test multiple configurations
Duplicate key-map items (while harmless in most cases) may cause
unexpected behavior or point to mistakes in the key-map,
so best avoid these.
2022-02-21 12:03:56 +11:00
Campbell Barton 88b6e5571e License headers: use SPDX for remaining CMake find modules & gtests 2022-02-15 17:45:39 +11:00
Brecht Van Lommel e6f3bb984b Merge branch 'blender-v3.1-release' 2022-02-11 14:55:42 +01:00
Brecht Van Lommel 6175c569f9 Tests: enable full Cycles Metal device regression tests on buildbot
Now that all tests are passing. This does add about 5 minutes to the macOS
builds on buildbot.

Ref T92212
2022-02-11 14:35:10 +01:00
Campbell Barton 281ba8a063 File headers: add missing copyright, add MIT to SPDX licenses 2022-02-11 14:56:03 +11:00
Campbell Barton f7bbec290d File headers: add license to Python scripts 2022-02-11 14:30:21 +11:00
Campbell Barton 1df8a5f8fb File headers: use SPDX license for CMake files 2022-02-11 14:23:56 +11:00
Howard Trickey 4d29ec42bc Revert "Split Python OBJ importer and exporter, enabling only the importer."
This reverts commit ff9dc1986e.
2022-02-10 19:21:32 -05:00
Howard Trickey f39698de77 Revert "Split Python OBJ importer and exporter, enabling only the importer."
This reverts commit ff9dc1986e.
2022-02-10 18:29:29 -05:00
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00
Campbell Barton 312d6925c4 Cleanup: make file headers more consistent
Also some descriptive text into doc-strings.
2022-02-09 23:47:34 +11:00
Sebastian Parborg 623ff64a27 Fix T81541: Symmetrize Transform Constraint, Y rotational axis unexpected results
The case where Y rotation is mapped to Y rotation was not handled.
This is now fixed.

Also added an automated test to make sure that the symmetrize operator
functions as intended.

Reviewed By: Sybren

Differential Revision: http://developer.blender.org/D9214
2022-02-04 14:21:20 +01:00
Howard Trickey 3bcbbf8992 Split Python OBJ importer and exporter, enabling only the importer.
This is from patch D13988. It removes the "- New" from the menu of the
new obj exporter, changes the default addon to just io_import_obj,
and does the right versioning thing.
Also disables the python tests for the old python exporter.
2022-02-03 09:30:55 -05:00
Howard Trickey ff9dc1986e Split Python OBJ importer and exporter, enabling only the importer.
This is from patch D13988. It removes the "- New" from the menu of the
new obj exporter, changes the default addon to just io_import_obj,
and does the right versioning thing.
Also disables the python tests for the old python exporter.
2022-02-03 07:56:55 -05:00
Campbell Barton d82372aee3 Cleanup: spelling in comments 2022-02-02 13:53:46 +11:00
Campbell Barton ebd0e76088 Cleanup: indentation for CMake files
Also minor white-space & case changes.
2022-01-28 14:52:47 +11:00
Brecht Van Lommel 13f2df3c28 Fix/workaround failing Cycles tests on macOS after ray offset changes
Temporarily blacklist a few tests with overlapping objects as they seem to
give different results on this platform.
2022-01-26 18:52:56 +01:00
William Leeson 74afc86d4b Cycles: remove ray offsetting
Remove small ray offsets that were used to avoid self intersection, and leave
that to the newly added primitive object/prim comparison. These changes together
significantly reduce artifacts on small, large or far away objects.

The balance here is that overlapping primitives are not handled well and should
be avoided (though this was already an issue). The upside is that this is
something a user has control over, whereas the other artifacts had no good
manual solution in many cases.

There is a known issue where the Blender particle system generates overlapping
objects and in turn leads to render differences between CPU and GPU. This will
be addressed separately.

Differential Revision: https://developer.blender.org/D12954
2022-01-26 17:51:05 +01:00
Hans Goudey 5a0c5912a4 Tests: Enable new tests for geometry nodes extrude node
rB95981c9876483256b28
2022-01-24 13:55:32 -06:00
Kévin Dietrich 0a08ac2528 Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.

This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.

It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.

Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.

After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.

See differential page for tests files and demos.

Reviewed by: brecht, sybren

Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:51:04 +01:00
Brecht Van Lommel 8ae6995e98 Tests: show more precise numbers in benchmark charts 2022-01-14 15:17:22 +01:00
Brecht Van Lommel d53738396f Tests: skip some compositor tests when WITH_LIBMV=OFF 2022-01-13 10:41:34 +01:00
Brecht Van Lommel 29450a2af3 Build: remove usage of link_directories
We are now always using absolute paths for libraries, as recommended by the
CMake docs.

Followup to D9177.
2022-01-13 10:40:38 +01:00
Campbell Barton fe82b8d1e8 Docs: correct doc-string for bl_run_operators_event_simulate
The event() action swapped type/value arguments.
2022-01-11 09:13:25 +11:00
Brecht Van Lommel 1a27d20df3 Tests: disable all but one simple test for the Cycles Metal device
Until all tests are passing, this lets us run a basic test on the buildbot.

Ref T92212
2022-01-10 17:35:07 +01:00
Brecht Van Lommel 35b1e9fc3a Cycles: pointcloud rendering
This add support for rendering of the point cloud object in Blender, as a native
geometry type in Cycles that is more memory and time efficient than instancing
sphere meshes. This can be useful for rendering sand, water splashes, particles,
motion graphics, etc.

Points are currently always rendered as spheres, with backface culling. More
shapes are likely to be added later, but this is the most important one and can
be customized with shaders.

For CPU rendering the Embree primitive is used, for GPU there is our own
intersection code. Motion blur is suppored. Volumes inside points are not
currently supported.

Implemented with help from:
* Kévin Dietrich: Alembic procedural integration
* Patrick Mourse: OptiX integration
* Josh Whelchel: update for cycles-x changes

Ref T92573

Differential Revision: https://developer.blender.org/D9887
2021-12-16 20:54:04 +01:00
Brecht Van Lommel b815088416 Tests: add Cycles perspective/ortho/panoramic camera regression tests
Ref D12691
2021-12-07 20:08:12 +01:00
luzpaz 92dae5775f Cleanup: Fix typos in source code
Source typos corrected

Reviewed By: Blendify

Differential Revision: https://developer.blender.org/D13462
2021-12-06 22:23:17 -05:00
Hans Goudey 2b6c01d98c Fix: Updating geometry nodes test results fails
I ran into this when adding new geometry nodes tests.
The issue was caused by 7168a4fa5c.

Differential Revision: https://developer.blender.org/D13440
2021-12-01 21:22:00 -05:00
Jake 7168a4fa5c Tests: add edit-mesh operator tests
Added operator tests for hide, symmetry_snap, tris_convert_to_quads,
uvs_rotate, uvs_rotate, uv_texture_add, uv_texture_remove,
vert_connect_concave, vert_connect_nonplanar, vertex_color_add,
vertex_color_remove, vertices_smooth_laplacian, wireframe,
sculpt_vertex_color_add and sculpt_vertex_color_remove.

Ref D11798

Reviewed By: campbellbarton
2021-11-30 17:43:24 +11:00
Brecht Van Lommel 06691d1b21 Tests: disable Cycles volume test when WITH_MOD_FLUID is off 2021-11-19 13:21:48 +01:00
Brecht Van Lommel 7d5ef64bfb Cleanup: fix typos in comments and docs
Contributed by luzpaz.

Differential Revision: https://developer.blender.org/D13264
2021-11-19 12:46:49 +01:00
luzpaz dea26253a0 cleanup: fix typos in comments and docs
Followup to https://developer.blender.org/D10288

Reviewed By: Blendify

Differential Revision: https://developer.blender.org/D10346
2021-11-16 18:45:10 -05:00
Brecht Van Lommel 1b55b911f2 Merge branch 'blender-v3.0-release' 2021-11-12 20:04:05 +01:00
Brecht Van Lommel 71131b4969 Tests: disable audio system for performance tests 2021-11-12 20:03:46 +01:00
Bastien Montagne 06a74e7816 LibLink/Append tests: Add basic testing of `bpy.data.libraries.load` code. 2021-11-11 14:54:26 +01:00
Hans Goudey 4648c4990c Merge branch 'blender-v3.0-release' 2021-11-09 13:08:36 -06:00
Ray Molenkamp 7c25399576 tests/benchmarks: Fix operation on windows
The test script did not work on windows
since it had some trouble importing the
api module on the blender side of things.

turning the file path to the module into
a raw string literal sidesteps the
backslash issue in the path.

Differential Revision: https://developer.blender.org/D13163

Reviewed by: brecht
2021-11-09 09:58:48 -07:00
Campbell Barton 0bcf014bcf Merge branch 'blender-v3.0-release' 2021-11-10 00:38:51 +11:00
Brecht Van Lommel 0b01b81754 Tests: disable Cycles tests based on more build options
WITH_OPENCOLORIO and WITH_COMPOSITOR are required to run the tests at all,
since they affect many tests.

WITH_OPENSUBDIV WITH_FREESTYLE, WITH_OPENVDB, WITH_OPENIMAGEDENOISE and
WITH_MOD_FLUID selectively disable some tests.
2021-11-09 13:55:35 +01:00
Campbell Barton 27b37517f8 Cleanup: use static sets 2021-11-08 17:00:36 +11:00
Campbell Barton c516659b5e Cleanup: use static sets 2021-11-08 14:52:08 +11:00
Bastien Montagne d3328fabc9 Attempt to fix failing lib link test on windows.
According to https://docs.python.org/3/library/os.html#os.rename,
`os.rename` has os-specific behavior, and will fail in case you attempt
to rename to an existing file on windows.

So using `os.replace` instead, which should be os-agnostic.

NOTE: Fact that temp test directory is not cleared after tests are
sucessfully ran does not sound great...
2021-11-04 15:06:58 +01:00
Bastien Montagne 2d6d8fc7ca Attempt fix for new lib reload/relocate tests on windows.
Try splitting them into their own class.
2021-11-04 11:25:30 +01:00
Bastien Montagne 1b2342b4d3 Tests: Add basic unittest for library reload and relocate operators. 2021-11-02 15:33:30 +01:00
Brecht Van Lommel fc36772b06 Tests: minor updates to benchmark script for running on buildbot
* graph command accepts folder of json files as input
* reset command clears log files
2021-10-28 22:41:40 +02:00
Brecht Van Lommel aea2287af3 Tests: updated Python bundled modules test
Add the new zstandard module, as well as previously missing ones.

Ref D12777, T88438
2021-10-21 21:25:34 +02:00
Brecht Van Lommel f6af3d9197 Build: remove cmake messages about disabled tests when feature is disabled
No need to report this, it just adds noise to the cmake config. The messages
that we need to keep are the ones about disabling tests when the test file or
idiff are missing.
2021-10-21 13:06:57 +02:00
Michael Kowalski 0baa876b83 New test for USD import.
Added a basic test for importing a primitive hierarchy from a USDA
file into Blender.  This was reviewed by Sybren in patch D12479.
2021-10-20 12:07:28 -04:00
Bastien Montagne 6cd191a660 Link/Append tests: properly support and test with/without 'recursive' behaviors.
This requires adding an extra ('indirect') library to the test cases for
append.

Aftermath of T92224.
2021-10-20 11:58:06 +02:00
Campbell Barton d73f664790 Cleanup: trailing space, use single quotes for enums 2021-10-20 09:17:25 +11:00
Bastien Montagne a3d4ed20f9 Fix liblink tests after recent commit.
NOTE: This needs new tests, no time now, will do tomorrow.
2021-10-19 18:01:26 +02:00
Brecht Van Lommel 6e473a897c Tests: update Cycles GPU tests blacklist so all tests pass
More tests are matching now, mainly due to unified volume sampling.
2021-10-19 15:06:04 +02:00
Campbell Barton eb8afc39f8 Tests: remove noisy output from bl_pyapi_idprop_datablock
As part of expected behavior this printed an exception,
making it seem as if there was an error in the test.

Now the exception is suppressed from the output, ensuring it matches
an the expected output.
2021-10-12 17:58:52 +11:00
Campbell Barton 6139782d81 Tests: script_pyapi_idprop now cleans up after it's self
This test left blend files in the users temporary directory.
2021-10-12 17:58:52 +11:00
Campbell Barton 3d35d4a9e5 Tests: support running ID-property test without numpy 2021-10-12 17:57:38 +11:00
Campbell Barton 7b0b050dd5 Tests: quiet warning for UIList class name 2021-10-12 17:57:37 +11:00
Brecht Van Lommel 335f40ebfa Tests: include device type in benchmark graph labels 2021-10-06 14:21:26 +02:00
Himanshi Kalra 22c61e8060 Tests: Disable tests for non-compiled libraries
This diff disables tests for Boolean, subdivision surface and volume
when GMP, Opensubdiv and Openvdb are not compiled respectively.
It also changes the existing file structure and adds sub-folders for
boolean and subdivison tests. The volume folder only has one test and
is as unchanged structure-wise.

Reviewed By: JacquesLucke, LazyDodo

Differential Revision: https://developer.blender.org/D12448
2021-09-29 23:52:52 +05:30
Campbell Barton 6dceaafe5a Cleanup: trailing space, newlines at EOF 2021-09-29 07:30:34 +10:00
Brecht Van Lommel cc653c9b02 Fix potential render tests error with invalid utf-8 characters
In general should not happen, but better to report the actual error instead
of the Python test code failing.
2021-09-28 20:50:38 +02:00
Bastien Montagne f48a4aa0f9 LibLink Append: Expose 'reuse ID' through new BLO flag, and add basic tests.
Option is now available to append operator, alsthough hidden and
disabled by default.
2021-09-23 12:56:05 +02:00
Brecht Van Lommel 0803119725 Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.

Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.

Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles

Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)

For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.

Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-21 14:55:54 +02:00
Brecht Van Lommel e43ecca016 Tests: measure time per frame in animation performance benchmark
Instead of a fixed number of frames, so that benchmarking takes about the
same time on any machine.
2021-09-20 19:03:22 +02:00
Himanshi Kalra a866a32ff2 Tests: Updated test message for Directory Not Found 2021-09-15 23:04:47 +05:30
Bastien Montagne 0ed089cebd LibLink: Enable unittest that was previously failing in append case.
Previous commit fixed it.
2021-09-14 17:59:18 +02:00
Brecht Van Lommel 42215d7cb8 Tests: more graceful handling of keyboard interrupting benchmarks
Leave current test result unchanged and stop executing immediately,
so it can be continued.
2021-09-10 16:48:26 +02:00
Brecht Van Lommel 5bfc3a3421 Fix error running benchmark script with environment variables for builds
Ref D12434
2021-09-08 19:58:27 +02:00
Brecht Van Lommel 6fc94d1848 Tests: updates for performance benchmarking
* Make "run" command (re-)run all tests, add "update" command to only
  run queued and outdated tests equivalent to the old "run" command.
* Support specifying environment variables for revisions, to easily
  compare multiple parameter values.
* Better sorting of revisions in graph.
2021-09-08 16:40:58 +02:00
Bastien Montagne 81978594a8 Fix tests broken by rB58632a7f3c0f1be6.
Commits breaking RNA API should always run all tests, and do text search
in python code base to ensure everything is updated as needed.
2021-09-06 10:56:02 +02:00
Bastien Montagne 8355e3fc77 Unittest: Extend and basic linking tests and add basic append tests.
We could check many more things still, but this should already cover
most basic common cases.
2021-09-01 12:51:07 +02:00
Hans Goudey 8b9a3b94fc Refactor IDProperty UI data storage
The storage of IDProperty UI data (min, max, default value, etc) is
quite complicated. For every property, retrieving a single one of these
values involves three string lookups. First for the "_RNA_UI" group
property, then another for a group with the property's name, then for
the data value name. Not only is this inefficient, it's hard to reason
about, unintuitive, and not at all self-explanatory.

This commit replaces that system with a UI data struct directly in the
IDProperty. If it's not used, the only cost is of a NULL pointer. Beyond
storing the description, name, and RNA subtype, derived structs are used
to store type specific UI data like min and max.

Note that this means that addons using (abusing) the `_RNA_UI` custom
property will have to be changed. A few places in the addons repository
will be changed after this commit with D9919.

**Before**
Before, first the _RNA_UI subgroup is retrieved the _RNA_UI group,
then the subgroup for the original property, then specific UI data
is accessed like any other IDProperty.
```
prop = rna_idprop_ui_prop_get(idproperties_owner, "prop_name", create=True)
prop["min"] = 1.0
```

**After**
After, the `id_properties_ui` function for RNA structs returns a python
object specifically for managing an IDProperty's UI data.
```
ui_data = idproperties_owner.id_properties_ui("prop_name")
ui_data.update(min=1.0)
```
In addition to `update`, there are now other functions:
 - `as_dict`: Returns a dictionary of the property's UI data.
 - `clear`: Removes the property's UI data.
 - `update_from`: Copy UI data between properties,
   even if they have different owners.

Differential Revision: https://developer.blender.org/D9697
2021-08-27 08:27:24 -05:00
Himanshi Kalra 30d3dd4de1 Added more Geometry Node tests
* Attributes
* Utilities
* Volume

Test folder located in `lib\tests\modeling\geometry_nodes`
It contains around 34 new tests.
* attribute clamp + other attribute nodes
* Curve Primitive nodes
* Mesh Primitive nodes
* delete geometry
* convex hull
* subdivision surface
* boolean intersect
* boolean diff
* volume to mesh

Reviewed By: zazizizou, JacquesLucke

Differential Revision: https://developer.blender.org/D12250
2021-08-24 13:27:36 +05:30
Brecht Van Lommel 214e4aac97 Fix Python error in ./benchmark init after recent changes 2021-08-19 17:45:37 +02:00
Bastien Montagne 58ba75f9e3 LibOverride RNA API: add removal of properties and operations.
This should complete the basics of RNA API for library overrides.

Ref. T86656.
2021-08-04 16:57:08 +02:00
Bastien Montagne a8185d2d74 LibOverride: Add RNA API to reset/delete overrides.
Ref. T86656.
2021-08-04 16:57:08 +02:00
Bastien Montagne add719e31a Tweak to recent liboverride API addition: naming.
Rename new API function introduced in recent rB3b0fab6dfaa0 to match our
convention to put the action (verb) at the end of names:
`operations_update`.

Sorry for not catching that during review.
2021-08-04 12:38:13 +02:00
Jeroen Bakker 3b0fab6dfa Override: API update_operations.
The update_operations function will update the override structure of the
local object. When working with overrides the override structure is only
updated when the work-file is stored. When using scripts you might want
to enforce the update of override properties and operations.

This function removes a hack on the test cases.

Reviewed By: mont29

Maniphest Tasks: T86656

Differential Revision: https://developer.blender.org/D10848
2021-08-04 09:28:18 +02:00
Jacques Lucke 3fd5c93f9c Geometry Nodes: increase threshold to make regression tests pass
The real fix here is to use some kind of relative error in `customdata_compare`
instead of the absolute error used now. If vertex coordinates get larger in magnitude,
the allowed error should increase as well.
2021-08-02 10:38:11 +02:00
Campbell Barton bc0a7d3fae PyAPI: support multi-dimensional arrays for bpy.props vector types
- Multi-dimensional boolean, int and float vector types are supported.
- A sequence of int's for the "size" is used to declare dimensions.
- Nested sequences are required for default arguments.

Now it's possible to define matrix properties, for e.g:

  bpy.props.FloatVectorProperty(size=(4, 4), subtype='MATRIX')
2021-07-29 11:09:21 +10:00
Himanshi Kalra 4a02b9ffeb Regression Testing: Running tests based on blend files
Runs tests based on blend files with minimum python interaction.
Developed as part of GSoC 2021 - Regression Testing of Geometry Nodes.
Earlier, tests were built from scratch by adding a modifier/operation
from the Python API.
Now, tests can also be created inside blender and are compared using
Python script.

Features: Automatically adding expected object if it doesn't exist.
This patch adds tests for the following Geometry Nodes category:
* Curves
* Geometry
* Mesh
* Points

The implemented UML diagram for refactoring of mesh test framework.
{F10225906}

Technical Changes:
SpecMeshTest: It adds the modifier/operation based on the Spec provided.
BlendFileTest: It applies already existing modifier/operation from the blend file.

Test folders hierarchy with tests. This folder should be extracted to `lib\tests\modeling`
{F10240651}
Note: The `geometry_nodes` folder might lie under another `geometry_nodes` folder while extracting, please double check. Use the inner-most one.
The hierarchy should be:
-`lib\tests\modeling\geometry_nodes\mesh`
-`lib\tests\modeling\geometry_nodes\points`
and so on.

* From `ctest` the tests should be run as `ctest -R geo_node -C [Configuration]` on Windows.
* Each single test can be run with its entire name e..g `ctest -R geo_node_geometry_join_geometry`.(just an example). Run `ctest -N -R geo_node` to see all tests.
* From blender, the tests can be run `blender -b path\to\blend\file --python path\to\geo_node_test.py`

Reviewed By: zazizizou, JacquesLucke

Differential Revision: https://developer.blender.org/D11611
2021-07-27 21:01:15 +05:30
Brecht Van Lommel 22b03e1c68 Fix Python error in benchmark executable detection after recent changes 2021-07-26 18:04:40 +02:00
Brecht Van Lommel 320f34af86 Tests: continue running benchmarks if some tests fail to build or run
Convenient when testing many revisions where some might be broken.
2021-07-22 16:35:00 +02:00
Brecht Van Lommel 19b597c55d Tests: improve finding of Blender executables in benchmarking
* Allow specifying a folder and automatically setting the proper executable
  name depending on the operating system
* Use executables from configs for listing devices instead of a blender
  command being available
2021-07-22 16:34:57 +02:00
Brecht Van Lommel 37a5ff4a84 Tests: support graphing peak memory in Cycles performance tests
The general graphing mechanism will create one graph for each output
variable. So it's not limited to time and memory, but that is what the
Cycles tests now output.
2021-07-14 16:12:10 +02:00
Campbell Barton b90b1af25c Event Simulate: and a --time-actions command line argument
When enabled, print the time taken between running actions.
2021-07-13 14:50:52 +10:00
Campbell Barton 2289e26fa3 Cleanup: correct spelling in comments, remove profanity 2021-07-11 15:31:36 +10:00
Philipp Oeser 834e87af7b Alembic: remove non-functional "Renderable Objects" only option
When introduced in {rB61050f75b13e} this was actually working (meaning
it checked the Outliner OB_RESTRICT_RENDER flag and skipped the object if
desired).

Behavior has since then been commented in rBae6e9401abb7 and apparently
refactored out in rB2917df21adc8.

If checked, it seemed to be working (objects marked non-renderable in
the Outliner were pruned from the export), however unchecking that
option did not include them in the export.

Now it changed - for the worse if you like - in rBa95f86359673 which
made it so if "Renderable Objects" only is checked, it will still export
objects invisible in renders. So since we now have the non-functional
option with a broken/misleading default, it is better to just remove it
entirely.

In fact it has been superseeded by the "Visible Objects" option (this
does the same thing: depsgraph is evaluated in render mode) and as a
second step (and to make this even clearer) a choice whether
Render or Viewport evaluation is used can be added (just like the USD
exporter has). When that choice is explicit, it's also clear which
visibility actually matters.

This is breaking API usage, should be in release notes.

ref. T89594

Maniphest Tasks: T89594

Differential Revision: https://developer.blender.org/D11808
2021-07-06 13:22:07 +02:00
Campbell Barton 432bfbf7a3 Cleanup: pep8 2021-07-06 12:05:27 +10:00
Brecht Van Lommel dc3f46d96b Tests: performance testing framework
These are scripts for benchmarking Blender features on real-world .blend
files. They were originally written for benchmarking Cycles performance, and
were made generic so they can be used for more Blender features.

The benchmarks can be run locally by developers. But the plan is to also run
these as part of continuous integration to track performance over time.

Currently there are tests for Cycles rendering and .blend file loading.

Documentation:
https://wiki.blender.org/wiki/Tools/Tests/Performance

Main features:
* User created configurations to quickly run, re-run and analyze a selected
  subset of tests.
* Supports both benchmarking with existing builds, and automatic building of
  specified git commits, tags and branches.
* Generate HTML page with bar and line graphs from test results.
* Controlled using simple command line tool.
* For writing tests, convenient abstraction to run a Python function in Blender
  with arguments and return value.

Ref T74730

Differential Revision: https://developer.blender.org/D11662
2021-07-05 12:32:32 +02:00
Alexander Gavrilov bc8ae58727 Copy Transforms: implement Remove Target Shear and more Mix options.
This constraint can be naturally viewed as a prototype for a future
4x4 matrix math node (or subset thereof), since its basic semantics
already is matrix assignment. Thus it makes sense to add math options
to this constraint to increase flexibility in the meantime.

This patch adds support for several operations that would be useful:

- An option to remove shear in the incoming target matrix.

  Shear is known to cause issues for various mathematical operations,
  so an option to remove it at key points is useful.

  Constraints based on Euler like Copy Rotation and Limit Rotation
  already have always enabled shear removal built in, because their
  math doesn't work correctly with shear.

  In the future node system shear removal would be a separate node
  (and currently Limit Rotation can be used as a Remove Shear constraint).
  However removing shear from the result of the target space conversion
  before mixing (similar to Copy Rotation) has to be built into
  Copy Transforms itself as an option.

- More ways to combine the target and owner matrices.

  Similar to multiple Inherit Scale modes for parenting, there are
  multiple ways one may want to combine matrices based on context.
  This implements 3 variants for each of the Before/After modes
  (one of them already existing).

  - Full implements regular matrix multiplication as the most basic
    option. The downside is the risk of creating shear.
  - Aligned emulates the 'anti-shear' Aligned Inherit Scale mode,
    and basically uses Full for location, and Split for rotation/scale.
    (This choice already existed.)
  - Split Channels combines location, rotation and scale separately.

  Looking at D7547 there is demand for Split Channels in some cases,
  so I think it makes sense to include it in Copy Transforms too, so that
  the Mix menu items can be identical for it and the Action constraint.

Differential Revision: https://developer.blender.org/D9469
2021-07-02 15:15:05 +03:00
Leon Zandman c317f111c1 Cleanup: Spelling Mistakes
This patch fixes many minor spelling mistakes, all in comments or
console output. Mostly contractions like can't, won't, don't, its/it's,
etc.

Differential Revision: https://developer.blender.org/D11663

Reviewed by Harley Acheson
2021-06-22 10:54:50 -07:00
Campbell Barton 90b0fb135f PyAPI: remove deprecated bpy.app.binary_path_python 2021-06-14 23:52:08 +10:00
Brecht Van Lommel 1f55e12206 Tests: temporarily increase threshold for OpenImageDenoise test
Until all platforms have the same version, this helps the tests pass.
2021-06-09 15:28:19 +02:00
Campbell Barton f29a738e23 PyAPI: use keyword only arguments
Use keyword only arguments for the following functions.

- addon_utils.module_bl_info 2nd arg `info_basis`.
- addon_utils.modules 1st `module_cache`, 2nd arg `refresh`.
- addon_utils.modules_refresh 1st arg `module_cache`.
- bl_app_template_utils.activate 1nd arg `template_id`.
- bl_app_template_utils.import_from_id 2nd arg `ignore_not_found`.
- bl_app_template_utils.import_from_path 2nd arg `ignore_not_found`.
- bl_keymap_utils.keymap_from_toolbar.generate 2nd & 3rd args `use_fallback_keys` & `use_reset`.
- bl_keymap_utils.platform_helpers.keyconfig_data_oskey_from_ctrl 2nd arg `filter_fn`.
- bl_ui_utils.bug_report_url.url_prefill_from_blender 1st arg `addon_info`.
- bmesh.types.BMFace.copy 1st & 2nd args `verts`, `edges`.
- bmesh.types.BMesh.calc_volume 1st arg `signed`.
- bmesh.types.BMesh.from_mesh 2nd..4th args `face_normals`, `use_shape_key`, `shape_key_index`.
- bmesh.types.BMesh.from_object 3rd & 4th args `cage`, `face_normals`.
- bmesh.types.BMesh.transform 2nd arg `filter`.
- bmesh.types.BMesh.update_edit_mesh 2nd & 3rd args `loop_triangles`, `destructive`.
- bmesh.types.{BMVertSeq,BMEdgeSeq,BMFaceSeq}.sort 1st & 2nd arg `key`, `reverse`.
- bmesh.utils.face_split 4th..6th args `coords`, `use_exist`, `example`.
- bpy.data.libraries.load 2nd..4th args `link`, `relative`, `assets_only`.
- bpy.data.user_map 1st..3rd args `subset`, `key_types, `value_types`.
- bpy.msgbus.subscribe_rna 5th arg `options`.
- bpy.path.abspath 2nd & 3rd args `start` & `library`.
- bpy.path.clean_name 2nd arg `replace`.
- bpy.path.ensure_ext 3rd arg `case_sensitive`.
- bpy.path.module_names 2nd arg `recursive`.
- bpy.path.relpath 2nd arg `start`.
- bpy.types.EditBone.transform 2nd & 3rd arg `scale`, `roll`.
- bpy.types.Operator.as_keywords 1st arg `ignore`.
- bpy.types.Struct.{keyframe_insert,keyframe_delete} 2nd..5th args `index`, `frame`, `group`, `options`.
- bpy.types.WindowManager.popup_menu 2nd & 3rd arg `title`, `icon`.
- bpy.types.WindowManager.popup_menu_pie 3rd & 4th arg `title`, `icon`.
- bpy.utils.app_template_paths 1st arg `subdir`.
- bpy.utils.app_template_paths 1st arg `subdir`.
- bpy.utils.blend_paths 1st..3rd args `absolute`, `packed`, `local`.
- bpy.utils.execfile 2nd arg `mod`.
- bpy.utils.keyconfig_set 2nd arg `report`.
- bpy.utils.load_scripts 1st & 2nd `reload_scripts` & `refresh_scripts`.
- bpy.utils.preset_find 3rd & 4th args `display_name`, `ext`.
- bpy.utils.resource_path 2nd & 3rd arg `major`, `minor`.
- bpy.utils.script_paths 1st..4th args `subdir`, `user_pref`, `check_all`, `use_user`.
- bpy.utils.smpte_from_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.smpte_from_seconds 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.system_resource 2nd arg `subdir`.
- bpy.utils.time_from_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.time_to_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.units.to_string 4th..6th `precision`, `split_unit`, `compatible_unit`.
- bpy.utils.units.to_value 4th arg `str_ref_unit`.
- bpy.utils.user_resource 2nd & 3rd args `subdir`, `create`
- bpy_extras.view3d_utils.location_3d_to_region_2d 4th arg `default`.
- bpy_extras.view3d_utils.region_2d_to_origin_3d 4th arg `clamp`.
- gpu.offscreen.unbind 1st arg `restore`.
- gpu_extras.batch.batch_for_shader 4th arg `indices`.
- gpu_extras.batch.presets.draw_circle_2d 4th arg `segments`.
- gpu_extras.presets.draw_circle_2d 4th arg `segments`.
- imbuf.types.ImBuf.resize 2nd arg `resize`.
- imbuf.write 2nd arg `filepath`.
- mathutils.kdtree.KDTree.find 2nd arg `filter`.
- nodeitems_utils.NodeCategory 3rd & 4th arg `descriptions`, `items`.
- nodeitems_utils.NodeItem 2nd..4th args `label`, `settings`, `poll`.
- nodeitems_utils.NodeItemCustom 1st & 2nd arg `poll`, `draw`.
- rna_prop_ui.draw 5th arg `use_edit`.
- rna_prop_ui.rna_idprop_ui_get 2nd arg `create`.
- rna_prop_ui.rna_idprop_ui_prop_clear 3rd arg `remove`.
- rna_prop_ui.rna_idprop_ui_prop_get 3rd arg `create`.
- rna_xml.xml2rna 2nd arg `root_rna`.
- rna_xml.xml_file_write 4th arg `skip_typemap`.
2021-06-09 03:05:44 +10:00
Campbell Barton 7ca5ba14b5 Cleanup: use keywords for unit tests
Prepare for function calls to be keyword only.
2021-06-08 00:07:19 +10:00
Campbell Barton 51bf1680bd Cleanup: quiet warning accessing deprecated attribute in bl_test 2021-06-08 00:07:19 +10:00
Campbell Barton 7ef2b760dc Event Simulate: and a --keep-open command line argument
It can be useful to investigate the state of the file
after event simulation runs.
2021-06-06 23:05:46 +10:00
Campbell Barton ae28ceb9d8 Fix swapped x/y in event simulation script
Incorrect area center calculation, also correct comments.
2021-06-03 01:11:47 +10:00
Campbell Barton 3ec57ce6c7 Tests: add utility to generate interactive user actions
A utility that supports passing in actions as command line arguments for
writing reproducible interactions, benchmarking, profiling and testing.

Unlike regular scripts this is able to control model operators usefully.

Typical ways of controlling Blender using this utility are via
operator id's, menu search and explicit events.
Others methods can be added as needed.

See the doc-string for example usage.
2021-05-28 16:59:38 +10:00
Antonio Vazquez 7aa7cc4ca1 Merge branch 'blender-v2.93-release' 2021-05-18 15:43:06 +02:00
Brecht Van Lommel b158477551 Fix ocean modifier giving different result on Arm than x86
And re-enable the test on macOS Arm.

Ref T78710
2021-05-18 14:40:22 +02:00
Sebastián Barschkis eaf3160f13 Merge branch 'blender-v2.93-release' 2021-05-18 12:52:29 +02:00
Sebastián Barschkis 53376ec7fc Tests: Disabled physics ocean test on macOS arm64
Test is failing and needs further investigation.
2021-05-18 12:48:35 +02:00
Sebastián Barschkis f4eae747f9 Tests: Remove threshold param from physics ocean mesh test
This was not the reason for the test failure on macOS arm64.
2021-05-18 12:44:53 +02:00
Sebastián Barschkis c17433bb55 Tests: Increased threshold param for physics_ocean test
Adjusting threshold to see what the buildbot will make of this.
2021-05-17 23:21:16 +02:00
Sebastián Barschkis c9afea5bbf Tests: Added threshold to physics ocean mesh test
The physics_ocean test is currently failing on macOS arm.
This is one attempt to fix this issue.
2021-05-17 21:13:35 +02:00
Alexander Gavrilov a86e815dd8 Mathutils: add a Matrix.LocRotScale constructor for combining channels.
Combining location, rotation and scale channels into a matrix is
a standard task, so while it is easily accomplished by constructing
and multiplying 3 matrices, having a standard utility allows for
more clear code.

The new constructor builds a 4x4 matrix from separate location,
rotation and scale values. Rotation can be represented as a 3x3
Matrix, Quaternion or Euler value, while the other two inputs
are vectors. Unneeded inputs can be replaced with None.

Differential Revision: https://developer.blender.org/D11264
2021-05-17 19:12:40 +03:00
Campbell Barton 265d97556a PyAPI: use iterators for ID property methods (keys, values & items)
- Matches changes in Python 3.x dictionary methods.

- Iterating now raises a run-time error if the property-group changes
  size during iteration.

- IDPropertyGroup.iteritems() has been removed.

- IDPropertyGroup View & Iterator types have been added.

- Some set functionality from dict_keys/values/items aren't yet
  supported (isdisjoint method and boolean set style operations).

Proposed as part of T85675.
2021-05-15 00:36:49 +10:00
Campbell Barton bd5bab961e Merge branch 'blender-v2.93-release' 2021-05-14 19:27:30 +10:00
Campbell Barton 3c09beb3b1 Fix memory leak in IDPropertyGroup.pop()
When popping ID-property groups/arrays,
ID-property was removed but not freed.

Now the value is converted to a native Python type and freed.
2021-05-14 19:25:29 +10:00
Campbell Barton c1c0b661c0 Cleanup: clang-format 2021-05-14 17:35:08 +10:00
Himanshi Kalra 7134b9daca Added Operator tests: unsubdivide, shading, vertex connect and mark seam
Added tests for:
* Mark Seam
* Shade flat
* Shade smooth
* Unsubdivide
* Vertex Connect Path
* select nth (Checkered Deselect)

Notes:
1) Shade flat, shade smooth are base test cases (to check mesh doesn't change for real)

Updated blend file: tests/modeling/operators.blend

Reviewed By: zazizizou, mont29

Differential Revision: https://developer.blender.org/D10893
2021-04-29 20:15:11 +05:30
Ankit Meel a702ca3faa Tests/bpy: Add installation verification test
Makes it slightly easier to test whether the installed module works
or not. Depends on D10656

Ref T86579
Reviewed By: mont29, campbellbarton
Differential Revision: https://developer.blender.org/D10665
2021-03-29 22:26:54 +05:30
Ankit Meel fbe2c3f422 Tests: disable python tests for blender as python module
Avoid CTest errors and exit codes due to test failures which depend
on Blender executable.

Ref T86579
Reviewed By: mont29, campbellbarton
Differential Revision: https://developer.blender.org/D10656
2021-03-29 22:25:52 +05:30
Jeroen Bakker 075a19049f Cleanup: Updated Documentation Library Overrides. 2021-03-29 12:04:29 +02:00
Jeroen Bakker 87f9405c9a Overrides: API to create an override template.
This is functionality that isn't accessible via the user interface. The
API allows the creation and modification of an override template that
holds rules that needs to be checked when overriding the asset.

The API is setup that it cannot be changed after creation. Later on when
the system is more mature we will allow changing overrides operations.

NOTE: This is an experimental feature and should not be used in productions.

Reviewed By: mont29, sebbas

Differential Revision: https://developer.blender.org/D10792
2021-03-29 09:54:34 +02:00
Habib Gahbiche c4ab1891cc Automated testing: selection operators test cases
added 22 more test cases for following operators:
    - edges select sharp
    - loop multi select
    - select all
    - select faces by sides
    - select interior faces
    - select less
    - select linked

{F9853218}

Reviewed By: calra, mont29

Differential Revision: https://developer.blender.org/D10400
2021-03-27 09:48:54 +01:00
Habib Gahbiche 252c87b9e8 Compositor automated testing
Added support for compositor tests. Compositor tests can be added, executed and viewed in a similar way to cycles
and other render engines tests.

Running test:
`ctest -R compositor`

Updating test:
`BLENDER_TEST_UPDATE=1 ctest -R compositor`

Viewing test results:
typically saved under `build_folder/tests/compositor/report.html`

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D6334
2021-03-26 16:15:02 +01:00
Jeroen Bakker 7b7b554f94 Fix: wrong use of assert in recent commit. 2021-03-22 14:11:58 +01:00
Jeroen Bakker 36fdbed2f0 LibraryOverrides: Initial Test Case.
Added a first test case for review. This will be the base for future test cases.

The current API is sufficient for what is expected for such a low level API.
One concern is that you need to trigger a save in order to update the library overrides
structure. Not expected from TD/Dev point of view.

Test cases are very important when implementing restrictive mode as it is a second evaluation mode that
has impact on the (current) permissive mode.

Reviewed By: Sebastián Barschkis, Bastien Montagne

Differential Revision: https://developer.blender.org/D10747
2021-03-22 11:51:44 +01:00
Campbell Barton 042f06ef3c Cleanup: update comments, remove ifdef'd code 2021-03-15 14:48:17 +11:00
Campbell Barton 85b209e02e Tests: add script_validate_keymap
This checks the generated key-map data matches the result of
re-exporting and re-importing.

This shows up various inconsistencies, including:

- Unused keymaps.
- Unknown/unused data in the keymap.
- Event arguments that don't make sense.
- Event values that don't match the event type
  (tweak direction on keyboard event for example).
2021-03-14 23:31:09 +11:00
Campbell Barton ef7efc3751 Tests: don't write thumbnails when running tests
Also replace WM_OT_read_factory_settings with WM_OT_read_homefile
so the preferences don't have to be reloaded.
2021-03-04 17:43:12 +11:00
Ankit Meel 67856d8c4a macOS/GTests: add_dependencies to fix build error
When building `install`, linking blender_test fails because
test libraries do not exist. This happened on lite + Xcode. Error in
{rBdcb2821292f962951e88f146cb304160f21f73da}.

Reviewed By: #platform_macos, brecht
Differential Revision: https://developer.blender.org/D10607
2021-03-04 08:04:17 +05:30
Hans Goudey 85f6674241 Tests: Add additional object to convert curve to mesh file 2021-02-12 16:02:04 -06:00
Habib Gahbiche b6d7aa9e13 Mesh automated testing: compare selection
MeshTest now compares selection between evaluated mesh and expected mesh. This way, we can test more operators
such as `faces_select_linked_flat`

Note: selection comparison intentionally does not happen in BKE_mesh_cmp() on C side but rather on Python side, because
selection is independent of mesh generation.

Reviewed By: calra, mont29

Differential Revision: https://developer.blender.org/D10279
2021-02-12 01:33:56 +05:30
Habib Gahbiche a608313860 Mesh automated testing: improve progress printing
Print number of total tests with each test to show how many tests have been executed and how many are left.
Example: `Running test 27/36: PlaneFaceSplitByEdges...`

Reviewed By: calra, mont29

Differential Revision: https://developer.blender.org/D10278
2021-02-11 23:07:03 +05:30
Habib Gahbiche 916e3b6e3d Cleanup: delete comments with test index
Tests are not identified with indexes, so no need to maintain comments with indexes anymore

Reviewed By: calra, mont29

Differential Revision: https://developer.blender.org/D10277
2021-02-11 22:56:54 +05:30
Campbell Barton 7e850ffa73 Cleanup: cmake indentation, white-space 2021-02-05 09:45:16 +11:00
Ankit Meel dcb2821292 macOS/GTest: Fix duplicate symbol errors with some generators
Don't force load _and_ link against a library in case
linker fails to deduplicate them.
https://devtalk.blender.org/t/macos-duplicate-symbol-errors/17343

Reviewed By: #platform_macos, brecht
Differential Revision: https://developer.blender.org/D10294
2021-02-03 23:20:27 +05:30
Sebastian Parborg 74f6b81c12 Tests: skip OSL render tests in build without OSL
Differential Revision: https://developer.blender.org/D9990
2021-01-14 13:14:43 +01:00
Brecht Van Lommel 4e90266fd8 Tests: enable bake and shader raytracing tests for OptiX
These are now supported and so can be tested.

Also refactor the code a bit to move Cycles specific blacklist out of generic
render test code.
2021-01-14 13:14:43 +01:00
Hans Goudey 3f7c294a95 Mix modifiers test after commit to bevel modifier defaults
{rB6b5e4ad5899d} neglected to update the modifier tests to reflect
the fact that the default limit method is no longer "NONE".
2021-01-12 23:54:46 -06:00
Sybren A. Stüvel b2ad52a763 Tests: skip unit test if built without ocean sim modifier
Disable the Ocean Sim test when building with `WITH_MOD_OCEANSIM=OFF`.
2021-01-12 13:50:29 +01:00
Sybren A. Stüvel 54f8a5dd73 Tests: run suites instead of individual test cases
Group all tests of a test suite into a single test command invocation.
This reduces the number of invocations by `ctest` by an order of
magnitude.

Since rB56aa5b0d8c6b663, `bin/tests/blender_test` was run for every
individual test. Having over a 1000 tests made testing slower than
necessary. Individual tests can still be run if desired by invocation of
`bin/tests/blender_test --gtest_filter=suitename.testname`.

NOTE: For this commit to have an immediate effect, it may be necessary
to remove the `tests` and `Testing` directories and some CMake files
from your build directory and rebuild. Run `ctest -N` to see the list of
tests; there should be less than 200.

Reviewed By: sergey, LazyDodo, sebbas

Maniphest Tasks: T83222

Differential Revision: https://developer.blender.org/D9649
2021-01-11 11:29:30 +01:00
Himanshi Kalra 7241104877 Enabled Physics Particle Instance test 2021-01-05 16:16:08 +05:30
Sebastian Parborg 8c80299fc4 Make mesh modifier tests not fail with optimized OSD lib
When building opensubdiv with more aggressive optimization flags
(-march=native -02) the output meshes would differ a bit from what we
expected in the current automated modifier test file.

The differences in vertex position is within the 1e-6 range, which I
would call is acceptable for floats. In addition to this, all the
modifier test that tests the subdiv modifier in particular pass without
any modifications. I've updated two tests in the modifier test file and
script to make it pass (listed below).

Updated following test categories:

1. Decimate test

Here there was a subdiv modifier applied before the actual decimate
modifier. Because the decimate modifier creates a queue of potential
vertices it can remove, it is highly sensitive to even small changes as
it drastically changes in which order the vertices are decimated in.

As this test should only be testing the decimate modifier, I pre-applied
the subdiv modifier in the test file.

2. RandomCubeModifier
For these tests I removed the subdiv modifier as well. As with decimate,
a small change in vertex position here can lead to quite different
results.

Reviewed By: Sergey, Bastien

Differential Revision: http://developer.blender.org/D9004
2021-01-04 19:30:20 +01:00
Hans Goudey 8373f497bd Add regression tests for curve conversion to mesh
This adds a basic set of tests for curve sampling and bevel generation.
At the moment there are basic test cases for bevels, caps, and the
filling of 2D curves, but more tests can be added in the future.

Curves are actually converted to "DispLists" for displaying them in the
viewport, so it's much simpler to rely on the mesh conversion operator
instead of building a new test framework for another data structure.

Differential Revision: https://developer.blender.org/D9958
2020-12-30 13:12:29 -06:00
Hans Goudey 761ef45a24 Cleanup: Fix typo in tests error message 2020-12-29 20:46:29 -06:00
Sergey Sharybin 5428ad40e8 Test: Add utility to do near comparison for float[2] 2020-12-29 10:38:38 +01:00
Himanshi Kalra e7b698327c Updated and extended Regression Testing frameworks (Gsoc 2020)
This revision contains the following changes-

  - Updated the existing testing framework for Modifiers for Regression
  Testing.
  - Tests for Physics modifiers and remaining Generate and Deform modifiers are added.
  - The existing `ModifierSpec` is updated with backward compatibility to support Physics Modifiers.
  - Now there is support for frame number and giving nested parameters for attributes.
  - Some Deform modifiers required Object Operators, e.g. "Bind" in Mesh Deform, so a new class was added to support that functionality.
  - A separate class for holding Particles System, they are tested by converting all the particles to mesh and joining it to the mesh they were added.
  - Updated the format to add tests for Bevel, Boolean and Operators as
  well.

Reviewed By: zazizizou, mont29, campbellbarton

Differential Revision: https://developer.blender.org/D8507
2020-12-17 20:58:20 +05:30
Campbell Barton e21f1136c2 Tests: fix 'ctest -j' running multiple tests at once
bl_blendfile_io & bl_blendfile_liblink shared a filename,
which could make these tests fail.
2020-12-10 17:18:38 +11:00
Brecht Van Lommel b14b57fc05 Fix failing Eevee render tests after recent changes 2020-12-07 17:09:34 +01:00
Henrik Dick a6c4e39876 Add Custom Object Space to Constraints
Add Custom Space to the list of space conversions for constraints.

Constraints can use World Space, Local Space, Pose Space, Local with
Parent, and now also Custom Space with a custom object to define the
evaluation space.

The Custom Space option uses the Local Space of an other
object/bone/vertex group. If selected on owner or target it will show a
box for object selection. If an armature is selected, then it will also
show a box for bone selection. If a mesh object is selected it will show
the option for using the local space of a vertex group.

Reviewed By: #animation_rigging, sybren, Severin, angavrilov

Differential Revision: https://developer.blender.org/D7437
2020-12-03 11:20:21 +01:00
Brecht Van Lommel 2a430a670c Tests: blacklist failing tests for Cycles CUDA and OptiX devices
Blacklist a bunch of tests on the GPU, which are known to currently have
differences with CPU. These can be enabled as they are fixed or the test
is modified to give compatible results when there are known limitations.

OSL tests were also moved to their own directory since those are not
supported on the GPU.

Ref T82193
2020-11-30 13:40:33 +01:00
Brecht Van Lommel dd391d38f6 Tests: add CMake option to run Cycles regression tests on GPU devices
CYCLES_TEST_DEVICES is a list of devices (CPU, CUDA, OPTIX, OPENCL). It is set
to CPU only by default.

Test output is now writen to build/tests/cycles/<device>, and the HTML report
has separate report pages for the different devices, with option to compare
between CPU and GPU renders.

Various GPU tests are still failing due to CPU/GPU differences, these are to be
fixed or blacklisted still.

Ref T82193
2020-11-30 13:40:33 +01:00
Sybren A. Stüvel e4ca1fc4ea Animation: New Euler filter implementation
This new discontinuity filter performs actions on the entire Euler
rotation, rather than only on the individual X/Y/Z channels. This makes
it fix a wider range of discontinuities, for example those in T52744.

The filter now runs twice on the selected channels, in this order:
- New: Convert X+Y+Z rotation to matrix, then back to Euler angles.
- Old: Add/remove factors of 360° to minimize jumps.

The messaging is streamlined; it now reports how many channels were
filtered, and only warns (instead of errors) when there was an actual
problem with the selected channels (like selecting three or more
channels, but without X/Y/Z triplet).

A new kernel function `BKE_fcurve_keyframe_move_value_with_handles()` is
introduced, to make it possible to move a keyframe's value and move its
handles at the same time.

Manifest Task: T52744

Reviewed By: looch

Differential Revision: https://developer.blender.org/D9602
2020-11-23 12:48:04 +01:00
Sybren A. Stüvel feb71f1d71 Animation: Expand unit tests for `BKE_fcurve_active_keyframe_index()`
Expand unit test for `BKE_fcurve_active_keyframe_index()` to test edge
cases better.

This also introduces a new test macro `EXPECT_BLI_ASSERT()`, which can be
used to test that an assertion fails successfully.

No functional changes to actual Blender code.
2020-11-10 15:36:21 +01:00
Brecht Van Lommel b1efea986d Fix sequence tests writing HTML report to wrong directory
It was missing from tests/report.html that gathers all tests reports.
2020-11-03 13:31:31 +01:00
Richard Antalik c887a50f62 Add sequencer transform tests
Tests files are based on test from D8393

Test files should be in `lib\tests\sequence_editing`
These are files, I will add few more tests including animation test.
{F9155273}

Using generic tool to compare rendered vs reference image as other render engines.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D9394
2020-11-01 21:34:18 +01:00
Ankit Meel a181b15639 Tests: use environment variable for leak sanitizer
Don't override other `LSAN_OPTIONS` like suppression file set in
the environment variable.

Old code added in {rB38ff5064b33ccb8} and {rB5f4e99b7a2b8376}

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D9207
2020-10-14 16:53:49 +05:30
Campbell Barton 41d2d6da0c Cleanup: pep8 (indentation, spacing, long lines) 2020-10-02 11:59:16 +10:00
Campbell Barton bab9de2a52 Cleanup: pep8, blank lines 2020-10-02 11:59:16 +10:00
Campbell Barton 28ebe827e6 Cleanup: trailing space 2020-10-02 11:59:16 +10:00
Henrik Dick bea4505744 Fix Tests for Weld Modifier with KD-Tree
Fixes the failing tests and reintroduces the KD-Tree solution.

Reviewed By: mano-wii

Differential Revision: https://developer.blender.org/D9013
2020-09-25 15:17:02 -03:00
Sebastian Parborg 6877a7b3ff Fix running tests when building without portable install. 2020-09-24 18:34:55 +02:00
Sebastian Parborg 331f383337 Fix blender constraints automated tests when using march=native
More agressive optimization made the results differ a bit more than the
current error margin would allow. Bump the error margin to be 1e-6
instead of the previous 0.5e-7.
2020-09-24 18:33:36 +02:00
Brecht Van Lommel f9fcb25d52 CMake: clean up setting of platform specific linker flags
Set flags directly on the target, and use common function for all cases.
This refactoring helps with the next commit for test executables.

Ref D8714
2020-09-17 12:29:19 +02:00
Campbell Barton dd25d47e8a Cleanup: add missing headers to CMake, formatting 2020-09-15 22:53:44 +10:00
TonyG da95d1d851 Fix T75881: Animation, limitation of Bézier Handles
Relax limits of FCurve Bézier handles during evaluation. FCurve handles
can be scaled down to avoid the curve looping backward in time. This
scaling was done correctly but over-carefully, posing unnecessary
limitations on the possible slope of FCurves. This commit changes the
scaling approach such that the FCurve can become near-vertical.

Bump Blender's subversion from 291.0.1 to 291.0.2 to ensure that older
animation files are correctly updated.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D8752
2020-09-15 13:08:18 +02:00
Sybren A. Stüvel ee97add4c4 Alembic export: write custom properties
Write custom properties (aka ID properties) to Alembic, to the
`.userProperties` compound property.

Manifest Task: https://developer.blender.org/T50725

Scalar properties (so single-value/non-array properties) are written as
single-element array properties to Alembic. This is also what's done by
Houdini and Maya exporters, so it seems to be the standard way of doing
things. It also simplifies the implementation.

Two-dimensional arrays are flattened by concatenating all the numbers
into a single array. This is because ID properties have a limited type
system. This means that a 3x3 "matrix" could just as well be a list of
three 3D vectors.

Alembic has two container properties to store custom data:
- `.userProperties`, which is meant for properties that aren't
  necessarily understood by other software packages, and
- `.arbGeomParams`, which can contain the same kind of data as
  `.userProperties`, but can also specify that these vary per face of a
  mesh. This property is mostly intended for renderers.

Most industry packages write their custom data to `.arbGeomParams`.
However, given their goals I feel that `.userProperties` is the more
appropriate one for Blender's ID Properties.

The code is a bit more involved than I would have liked. An
`ABCAbstractWriter` has a `uniqueptr` to its `CustomPropertiesExporter`,
but the `CustomPropertiesExporter` also has a pointer back to its owning
`ABCAbstractWriter`. It's the latter pointer that I'm not too happy
with, but it has a reason. Getting the aforementioned `.userProperties`
from the Alembic library will automatically create it if it doesn't
exist already. If it's not used to actually add custom properties to, it
will crash the Alembic CLI tools (and maybe others too). This is what
the pointer back to the `ABCAbstractWriter` is used for: to get the
`.userProperties` at the last moment, when it's 100% sure at least one
custom property will be written.

Differential Revision: https://developer.blender.org/D8869

Reviewed by: sergey, dbystedt
2020-09-14 12:49:27 +02:00
Howard Trickey 3699d6fe34 Re-enable modifer and bmesh_boolean tests.
These were disabled in the newboolean merge commit.
This commit renables them, using the original 'FAST' solver
so that the result objects need not change.
A TODO to add more tests using the 'EXACT' solver,
though most functionality there is now covered by unit gtests.
2020-08-30 08:31:40 -04:00
Howard Trickey 9e09b5c418 Merge newboolean branch into master.
This is for design task T67744, Boolean Redesign.
It adds a choice of solver to the Boolean modifier and the
Intersect (Boolean) and Intersect (Knife) tools.
The 'Fast' choice is the current Bmesh boolean.
The new 'Exact' choice is a more advanced algorithm that supports
overlapping geometry and uses more robust calculations, but is
slower than the Fast choice.
The default with this commit is set to 'Exact'. We can decide before
the 2.91 release whether or not this is the right choice, but this
choice now will get us more testing and feedback on the new code.
2020-08-28 11:01:06 -04:00
Jacques Lucke 8a9912eaf8 Tests: fail automated tests on memory leaks and other internal errors
This adds a new `--debug-exit-on-error` flag. When it is set, Blender
will abort with a non-zero exit code when there are internal errors.
Currently, "internal errors" includes memory leaks detected by
guardedalloc and error/fatal log entries in clog.

The new flag is passed to Blender in various places where automated
tests are run. Furthermore, the `--debug-memory` flag is used in tests,
because that makes the verbose output more useful, when dealing
with memory leaks.

Reviewers: brecht, sergey

Differential Revision: https://developer.blender.org/D8665
2020-08-26 22:02:02 +02:00
Jacques Lucke 48bd6e7102 Tests: use guarded allocator in tests
This helps finding memory leaks in tests.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D8631
2020-08-19 18:18:20 +02:00
Sybren A. Stüvel ac41215f07 Tests: fix Alembic export test on Windows
Convert all `subprocess.run()` arguments to string, to prevent breaking
"does this argument need quoting" checks on Windows.
2020-08-17 20:08:01 +02:00
Sybren A. Stüvel a95f863596 Fix T75936: Alembic, allow exporting of invisible objects
Add a new depsgraph builder class that includes invisible objects and
use that in the Alembic exporter.

Alembic supports three options for visibility, "visible", "inherited",
and "hidden". This means that parents can be hidden and still have
visible children (contrary to USD, where invisibility is used to prune
an entire scene graph subtree). Because of this, the visibility is
stored on the transform node, as that represents the Object in Blender
and thus keeps the Alembic file as close to Blender's own structure as
possible.

Reviewed By: Sergey

Differential Revision: https://developer.blender.org/D8595
2020-08-17 17:56:05 +02:00
Sybren A. Stüvel 04ae290024 Cleanup: Alembic, rename test in CMake for consistency
Rename test `alembic_tests` to `alembic_export_tests`, so that its name
is consistent with the Python file containing the tests,
`alembic_export_tests.py`.

No functional changes.
2020-08-17 17:56:05 +02:00
Sybren A. Stüvel 449ccb7b30 Fix typo: missing `f` string prefix in Alembic export test 2020-08-17 15:16:20 +02:00
Sybren A. Stüvel 6b6de5beba Cleanup: Alembic tests, add note explaining how the export tests work
No functional changes.
2020-08-17 14:07:45 +02:00
Sybren A. Stüvel ad459302ce Cleanup: rename `alembic_tests.py` to `alembic_tests_export.py`
Rename `alembic_tests.py` to `alembic_tests_export.py`, as this makes it
clearer what is being tested.

No functional changes.
2020-08-17 14:07:45 +02:00
Sybren A. Stüvel 4a2ff0fef8 Tests: Better error reporting in `AbstractAlembicTest`
Instead of checking for the length of a list, just handle the error that
occurs when the length is incorrect.

No functional changes to any actual test.
2020-08-17 14:07:45 +02:00
Sybren A. Stüvel 38752944f8 Fix formatting bug in `AbstractAlembicTest` class
Replace `formatstring, value` with the correct `formatstring % value`.

No functional changes to any actual tests.
2020-08-17 14:07:45 +02:00
Brecht Van Lommel 53d203dea8 Tests: move remaining gtests into their own module folders
And make them part of the blender_test runner. The one exception is blenlib
performance tests, which we don't want to run by default. They remain in their
own executable.

Differential Revision: https://developer.blender.org/D8498
2020-08-10 18:14:00 +02:00
Sergey Sharybin 2c5c39d53c Merge branch 'blender-v2.90-release' 2020-08-05 13:00:15 +02:00
Sergey Sharybin 02ccc37144 Correct recent fix for Cycles motion blur test
Need to only compare directory name, not the whole path.
2020-08-05 12:59:28 +02:00
Julian Eisel fc9f7e3e51 Merge branch 'blender-v2.90-release' 2020-08-05 12:19:28 +02:00
Brecht Van Lommel ec9ab00fcb Fix failing USD test on macOS after becoming part of blender test runner 2020-08-05 12:15:17 +02:00
Brecht Van Lommel de53178b26 Fix T78777: Cycles motion blur test differences between AVX/AVX2
This appears to be slight precision differences in the Embree implementation,
simply increase the diff threshold a little for these motion blur tests.
2020-08-05 11:45:31 +02:00
Campbell Barton 6119f3cad1 Cleanup: spelling (initialized) 2020-08-01 13:57:27 +10:00
Campbell Barton 901ee66ea1 Cleanup: use term init instead of initialize/initialise
The abbreviation 'init' is brief, unambiguous and already used
in thousands of places, also initialize is often accidentally
written with British spelling.
2020-08-01 13:51:05 +10:00
Brecht Van Lommel 81caec8c60 Fix blender_test runner build on the buildbot on Linux and macOS
Add our own copy of the gtest discovery scripts from CMake a few reasons:
* Use the very latest version which supports PRE_TEST for Windows
* Fix usage of [] symbols in file paths that fail with the zsh shell
* Disable asan leak checker when discovering tests

This means Windows also no longer requires the very latest CMake 3.18.
2020-07-31 14:41:13 +02:00
Brecht Van Lommel 5628aaeee1 Fix build of blender_test runner on macOS 2020-07-31 14:15:42 +02:00
Sergey Sharybin db24e289b2 Merge branch 'blender-v2.90-release' 2020-07-31 11:53:22 +02:00
Sergey Sharybin de21ddf821 BLI: Initial implementation of generic session UUID API
Covers basics like generation of new UUID.

Also contains code needed to use the SessionUUID as a key in the Map.
2020-07-31 11:24:03 +02:00
Ray Molenkamp 44928a2a8f Fix: Blender_test not working on windows.
This bumps the minimum requirement for cmake from 3.10 to 3.18 on windows
if `WITH_GTESTS` is enabled.

Reviewed By: sergey brecht sybren campbellbarton

Differential Revision: https://developer.blender.org/D8405
2020-07-30 13:18:05 -06:00
Germano Cavalcante 2181028292 Merge branch 'blender-v2.90-release' 2020-07-29 19:19:25 -03:00
Brecht Van Lommel 81ce8481b2 Fix failing PLY test, update hash because metadata changed 2020-07-29 19:49:53 +02:00
Jacques Lucke 814ca40c63 Merge branch 'blender-v2.90-release' 2020-07-28 16:37:01 +02:00
Jacques Lucke b274d18aec Cleanup: correct usage of extern-C blocks in various places
This removes extern-C blocks around other includes and adds
such blocks for some headers that need them.
2020-07-28 16:33:43 +02:00
Sybren A. Stüvel e8869d9c71 Merge remote-tracking branch 'origin/blender-v2.90-release' 2020-07-27 19:02:44 +02:00
Sybren A. Stüvel 2584a2a4e7 Fix USD unit test on buildbot
The buildbot uses a separate `CMAKE_INSTALL_PREFIX`. This means that
the unit test could not find its USD JSON files in the build directory.
Using `${CMAKE_INSTALL_PREFIX}` instead of `$<TARGET_FILE_DIR:blender>`
solved this.
2020-07-27 19:02:22 +02:00
Ray Molenkamp 729da8bfac CTest: Fix blender_test not working on windows.
MSVC does need the wholearchive flag but it was not set,
so no tests were actually linked into the binary.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D8404
2020-07-27 10:55:34 -06:00
Jacques Lucke 6cecdf2ade Functions: move tests closer to code 2020-07-26 12:19:11 +02:00
Jacques Lucke f495b583be Merge branch 'blender-v2.90-release' 2020-07-24 12:40:20 +02:00
Jacques Lucke 236ca8fbe8 Allocator: make leak detection work with static variables
When definining static variables that own memory, you should
use the "construct on first use" idiom. Otherwise, you'll get
a warning when Blender exits.

More details are provided in D8354.

Differential Revision: https://developer.blender.org/D8354
2020-07-24 12:26:11 +02:00
Jacques Lucke 149bb0c26d Cleanup: unify naming between different spans 2020-07-23 18:07:44 +02:00
Jacques Lucke c8b24af1b2 BLI: move some tests into blenlib/tests
Reviewers: sybren

Differential Revision: https://developer.blender.org/D8315
2020-07-23 15:23:55 +02:00
Hans Goudey 4aa2a5481c Bevel: Refactor "Vertex Only" to an enum
This matches the change that was done to the bevel modifier so that the
interface for the modifier, the active tool, and the operator are consistent.

 This commit extends the refactor to the bmesh implementation too, so
that the parameters in the implementation don't stray too far from what
is exposed.

Tests are adjusted and still pass.
2020-07-21 16:32:00 -04:00
Alexander Gavrilov f8cc01595d Drivers: add lerp and clamp functions to namespace.
Implementation of lerp without a function requires repeating one of
the arguments, which is not ideal. To avoid that, add a new function
to the driver namespace. In addition, provide a function for clamping
between 0 and 1 to support easy clamped lerp, and a smoothstep function
from GLSL that is somewhat related.

The function implementations are added to a new bl_math module.
As an aside, add the round function and two-argument log to the
pylike expression subset.

Differential Revision: https://developer.blender.org/D8205
2020-07-21 19:01:50 +03:00
Jacques Lucke 579b180053 BLI: add Vector/Array.fill methods 2020-07-20 13:02:10 +02:00
Jacques Lucke 8cbbdedaf4 Refactor: Update integer type usage
This updates the usage of integer types in code I wrote according to our new style guides.

Major changes:
* Use signed instead of unsigned integers in many places.
* C++ containers in blenlib use `int64_t` for size and indices now (instead of `uint`).
* Hash values for C++ containers are 64 bit wide now (instead of 32 bit).

I do hope that I broke no builds, but it is quite likely that some compiler reports
slightly different errors. Please let me know when there are any errors. If the fix
is small, feel free to commit it yourself.
I compiled successfully on linux with gcc and on windows.
2020-07-20 12:16:20 +02:00
Jacques Lucke 2679236047 Cleanup: avoid static initialization order issues when accessing CPPTypes
Instead of depending on static initialization order of globals use
static variables within functions. Those are initialized on first use.
This is every so slighly less efficient, but avoids a full class of problems.
2020-07-17 14:15:06 +02:00
Sybren A. Stüvel e7c1a32a78 Tests: disable ASAN when discovering tests
CMake, when it's configuring the project, runs the `blender_test` test
runner (if it exists from a previous build) to discover which tests it
contains. At this time none of the tests themselves are run, so it's not
that useful to run ASAN and have it break things when there are memory
leaks.

This commit disables ASAN by injecting `ASAN_OPTIONS="detect_leaks=0"` in
the environment variables.

It is not enough to use `set(ENV{ASAN_OPTIONS} "detect_leaks=0")` in
`tests/gtests/runner/CMakeLists.txt`, as it wouldn't be passed to the child
process.
2020-07-16 17:38:29 +02:00
Sybren A. Stüvel a138bf57c9 Tests: move tests from USD test directory into `io/common` and `io/usd`
This commit is a followup of {D7649}, and ports the USD tests to the new
testing approach. It moves test code from `tests/gtests/usd` into
`source/blender/io/common` and `source/blender/io/usd`, and adjusts the
use of namespaces to be consistent with the other tests.

I decided to put one test into `io/usd/tests`, instead of
`io/usd/intern`. The reason is that this test does not correspond with a
single file in that directory; instead, it tests Blender's integration
with the USD library itself.

There are two new CLI arguments for the Big Test Runner:

- `--test-assets-dir`, which points to the `lib/tests` directory in the
  SVN repository. This allows unit tests to find test assets.
- `--test-release-dir`, which points to `bin/{BLENDER_VERSION}` in the
  build directory. At the moment this is only used by the USD test.

The CLI arguments are automatically passed to the Big Test Runner when
using `ctest`. When manually running the tests, the arguments are only
required when there is a test run that needs them.

For more info about splitting some code into 'common', see
rB084c5d6c7e2cf8.

No functional changes to the tests themselves, only to the way they are
built & run.

Differential Revision: https://developer.blender.org/D8314

Reviewed by: brecht, mont29
2020-07-16 17:38:29 +02:00
Sybren A. Stüvel 56aa5b0d8c T73268: Link C/C++ unit tests into single executable
This commit introduces a new way to build unit tests. It is now possible
for each module to generate its own test library. The tests in these
libraries are then bundled into a single executable.

The test executable can be run with `ctest`. Even though the tests
reside in a single executable, they are still exposed as individual
tests to `ctest`, and thus can be selected via its `-R` argument.

Not yet ported tests still build & run as before.

The following rules apply:

- Test code should reside in the same directory as the code under test.
- Tests that target functionality in `somefile.{c,cc}` should reside in
  `somefile_test.cc`.
- The namespace for tests is the `tests` sub-namespace of the code under
  test. For example, tests for `blender::bke` should be in
  `blender::bke:tests`.
- The test files should be listed in the module's `CMakeLists.txt` in a
  `blender_add_test_lib()` call. See the `blenkernel` module for an
  example.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7649
2020-07-16 12:58:49 +02:00
Jacques Lucke d897228682 BLI: move safe math functions to separate header 2020-07-16 11:28:31 +02:00
Jacques Lucke f6f93b5b12 BLI: add safe_divide, safe_modf and safe_logf
Those are defined exactly as their corresponding functions in Cycles.
2020-07-16 11:05:30 +02:00
Jacques Lucke 35bfe1702c BLI: add safe_powf function
The same function is also used by cycles.
2020-07-16 10:46:18 +02:00
Jacques Lucke e8b26a0501 Fix signed/unsigned comparison 2020-07-15 11:06:54 +02:00
Ray Molenkamp 70992ae270 Fix: Fix build error with MSVC in BLI_span_test
span.size() returns an uint, causing a signed/unsigned comparison
using 3u sidesteps the issue
2020-07-13 12:29:53 -06:00
Jacques Lucke a19584a471 BLI: fix constructor regression for Vector and Array
This was introduced in rB403384998a6bb5f428e15ced5.
2020-07-13 10:51:46 +02:00
Jacques Lucke c7eada103c Nodes: support implicit conversions and incorrectly linked sockets 2020-07-11 18:02:06 +02:00
Jacques Lucke 3edd2832b2 Functions: make generic types hashable 2020-07-10 12:57:28 +02:00
Jacques Lucke 8f6c0f2242 Functions: make generic types equality comparable 2020-07-10 12:57:28 +02:00
Jacques Lucke 403384998a BLI: improve constructors and conversions to span
This allows us to avoid many calls to `as_span()` methods. I will
remove those in the next commit. Furthermore, constructors
of Vector and Array can convert from one type to another now.

I tested these changes on Linux with gcc and on Windows.
2020-07-08 22:27:25 +02:00
Jacques Lucke 36a547af7b Cleanup: add correct license header to tests 2020-07-08 15:10:30 +02:00
Jacques Lucke ff133bbd33 BLI: add disjoint set data structure
This can be used to find separate islands in meshes efficiently (as is
done in cycles already). Furthermore, this helps to implement some
algorithms on node trees more efficiently.
2020-07-08 15:10:30 +02:00
Jacques Lucke 22158162ef Functions: add generic functions that output constants 2020-07-07 19:34:35 +02:00
Jacques Lucke a8627ea66d Functions: Add debug print and destruct callback to CPPType 2020-07-07 18:39:24 +02:00
Sybren A. Stüvel 98bee41c8a IO: Reversed persistent ID order in exports to Alembic and USD
Each duplicated (a.k.a. instanced) object has a Persistent ID, which
identifies a dupli within the context of its duplicator. This ID
consists of several numbers when there are nested duplis (for example a
mesh instancing empties on its vertices, where each empty instances a
collection). When exporting to Alembic/USD, these are used to uniquely
name the duplicated objects in the export.

This commit reverses the order of the persistent ID numbers, so that the
first number identifies the first level of recursion. This produces
trees like this:

    ABC
     `--Triangle
         |--Triangle
         |--Empty-1
         |    `--Pole-1-0
         |        |--Pole
         |        `--Block-1-1
         |            `--Block
         |--Empty
         |    `--Pole-0
         |        |--Pole
         |        `--Block-1
         |            `--Block
         |--Empty-2
         |    `--Pole-2-0
         |        |--Pole
         |        `--Block-2-1
         |            `--Block
         `--Empty-0
             `--Pole-0-0
                 |--Pole
                 `--Block-0-1
                     `--Block

It is now clearer that `Pole-2-0` and `Block-2-1` are instanced by
`Empty-2`. Before this commit, they would have been named `Pole-0-2` and
`Block-1-2`.
2020-07-07 14:30:55 +02:00
Sybren A. Stüvel 70b1c09d7a IO: Fix bug exporting dupli parent/child relations
Exporting a scene to USD or Alembic would fail when there are multiple
duplicates of parent & child objects, duplicated by the same object. For
example, this happens when such a hierarchy of objects is contained in a
collection, and that collection is instanced multiple times by mesh
vertices. The problem here is that the 'parent' pointer of each
duplicated object points to the real parent; Blender would not figure
out properly which duplicated parent should be used.

This is now resolved by keeping track of the persistent ID of each
duplicated instance, which makes it possible to reconstruct the
parent-child relations of duplicated objects. This does use up some
memory for each dupli, so it could be heavy to export a Spring scene
(with all the pebbles and leaves), but it's only a small addition on top
of the USD/Alembic writer objects that have to be created anyway. At
least with this patch, they're created correctly.

Code-wise, the following changes are made:

- The export graph (that maps export parent to its export children) used
  to have as its key (Object, Duplicator). This is insufficient to
  correctly distinguish between multiple duplis of the same object by
  the same duplicator, so this is now extended to (Object, Duplicator,
  Persistent ID). To make this possible, new classes `ObjectIdentifier`
  and `PersistentID` are introduced.
- Finding the parent of a duplicated object is done via its persistent
  ID. In Python notation, the code first tries to find the parent
  instance where `child_persistent_id[1:] == parent_persistent_id[1:]`.
  If that fails, the dupli with persistent ID `child_persistent_id[1:]`
  is used as parent.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8233
2020-07-07 13:01:07 +02:00
Jacques Lucke 955abbeff2 Fix sign conversion error 2020-07-07 09:01:01 +02:00
Hans Goudey e20171e59f Fix build error with tests for removed functions
These GHash functions were removed in 12817083ec,
so the tests should be removed too.
2020-07-06 16:39:28 -04:00
Jacques Lucke f6f4043924 BLI: add methods to lookup a stored key in a set 2020-07-06 17:59:27 +02:00
Jacques Lucke 572c48cf98 BLI: improve exception safety of memory utils
Even if we do not use exception in many places in Blender, our core C++ library
should become exception safe. Otherwise, we don't even have the option
to work with exceptions if we decide to do so.
2020-07-06 09:08:53 +02:00
Jacques Lucke 703a73fa84 BLI: refactor how buffers for small object optimization are stored
Previously, there was an error when operator-> was returning an
invalid type. See error C2839.
2020-07-06 10:56:26 +02:00
Jacques Lucke 247a28f242 Revert "BLI: refactor how buffers for small object optimization are stored"
This reverts commit 5d79f9f276.

This was introducing build errors in windows. Need a bit more time to check it.
2020-07-05 15:08:26 +02:00
Jacques Lucke 5d79f9f276 BLI: refactor how buffers for small object optimization are stored 2020-07-05 16:30:26 +02:00
Jacques Lucke 1e255ce031 Fix T72214: Fluids: noise does not work with negative frame numbers
The issue is duplicated code. There are two functions that zero-fill
the frame number. They worked the same for positive frames numbers, but
behaved differently for negative ones.

On frame `-100`, `BLI_path_frame` outputs `-0100` and
`fluid_cache_get_framenr_formatted_$ID$` outputted `-100`.

I changed the behavior of the latter, because we depend on the behavior
of the former for much longer already.

Reviewers: sebbas

Differential Revision: https://developer.blender.org/D8107
2020-07-03 15:27:02 +02:00
Jacques Lucke 395b294b61 Cleanup: use nested namespaces 2020-07-03 14:25:20 +02:00
Jacques Lucke 0949140d36 Fix compile error
This is the same issue as in rBbcf49d13e53454.
2020-06-30 18:32:38 +02:00
Jacques Lucke 613f62d15c Functions: add two more customizable multi-functions 2020-06-30 18:18:48 +02:00