Commit Graph

773 Commits

Author SHA1 Message Date
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
Jacques Lucke 26cdab02a8 Cleanup: move tests into their corresponding namespace 2020-06-30 16:46:52 +02:00
Jacques Lucke 37820651bb BLI: add Array constructor that does not initialize non-trivial types
This should rarely be necessary, but I have a use case coming up soon.
2020-06-30 15:58:29 +02:00
Sybren A. Stüvel 2917df21ad Alembic: new exporter based on the USD exporter structure
The Alembic exporter has been restructured by leverages the
`AbstractHierarchyIterator` introduced by the USD exporter. The produced
Alembic files have not changed much (details below), as the Alembic
writing code has simply been moved from the old exporter to the new. How
the export hierarchy is handled changed a lot, though, and also the way
in which transforms are computed. As a result, T71395 is fixed.

Differences between the old and new exporter, in terms of the produced
Alembic file:
- Duplicated objects now have a unique numerical suffix.
- Matrices are computed differently, namely by simply computing the
  evaluated transform of the object relative to the evaluated transform
  of its export-parent. This fixes {T71395}, but otherwise should
  produce the same result as before (but with simpler code).

Compared to the old Alembic exporter, Subdivision modifiers are now
disabled in a cleaner, more efficient way (they are disabled when
exporting with the "Apply Subdivisions" option is unchecked). Previously
the exporter would move to a new frame, disable the modifier, evaluate
the object, and enable the modifier again. This is now done before
exporting starts, and modifiers are only restored when exporting ends.

Some issues with the old Alembic exporter that have NOT been fixed in
this patch:
- Exporting NURBS patches and curves (see T49114 for example).
- Exporting flattened hierarchy in combination with dupli-objects. This
  seems to be broken in the old Alembic exporter as well, but nobody
  reported this yet.

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

Reviewed By: Sergey
2020-06-30 11:38:46 +02:00
Jacques Lucke 18bff53c99 BLI: remove blender::Optional in favor of std::optional
`std::optional` can be used now, because we switched to C++17.
2020-06-29 14:30:06 +02:00
Jacques Lucke ff82049642 Functions: add MutableAttributesRef data structure
This will be used to reference the content of a CustomData structure
in C++ code, that does not need to know who owns the data but only
works with it.
2020-06-27 20:58:35 +02:00
Jacques Lucke 2350159101 Cleanup: make it easier to check if a CPPType is a specific compile time type 2020-06-27 13:28:46 +02:00
Jacques Lucke 3a3708cefb Functions: Multi Function Network
A multi-function network is a graph data structure, where nodes are
multi-functions (or dummies) and links represent data flow.
New multi-functions can be derived from such a network. For that
one just has to specify two sets of sockets in the network that
represent the inputs and outputs of the new function.

It is possible to do optimizations like constant folding on this
data structure, but that is not implemented in this patch yet.

In a next step, user generated node trees are converted into a
MFNetwork, so that they can be evaluated efficiently for many particles.

This patch also includes some tests that cover the majority of the code.
However, this seems to be the kind of code that is best tested by some
.blend files. Building graph structures in code is possible, but is
not easy to understand afterwards.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D8049
2020-06-23 10:16:14 +02:00
Jacques Lucke c94a1f5349 Functions: add utilities that allow creating some multi-functions with less typing 2020-06-22 15:50:31 +02:00
Jacques Lucke 6223385043 Functions: Various improvements to the spans and generic data structures
Most of this code is covered by unit tests.
2020-06-22 15:50:31 +02:00
Sybren A. Stüvel 1a448c66ed Cleanup: Alembic, move the C++ code to `blender::io::alembic` namespace
This commit only moves code into the `blender::io::alembic` namespace,
it does not move `static` functions into an anonymous namespace.

No functional changes.
2020-06-19 15:30:18 +02:00
Sybren A. Stüvel 89b7f785e6 Cleanup: Alembic, moved exporter code into separate directory
This moves most of the exporter-related code
from `source/blender/io/alembic/intern`
to   `source/blender/io/alembic/exporter`

This is to prepare the Alembic code for the switchover to using
`blender::io::AbstractHierarchyIterator`. When that happens, a few more
files will be added, and having things in a separate 'exporter'
directory makes things less cluttered.

Note that exporting consists of multiple steps (determine export
hierarchy, create Alembic archive, and then write data into it), which
is why the directory is called "exporter", but many of the files are
called "writer".

No functional changes.
2020-06-19 15:30:18 +02:00
Sergey Sharybin 2193e28dfc USD Test: Don't use designated initializers
This isn't really in C++ standard, some corner cases work in some
compilers (like when all fields are specified), but in general they
do not work.

For some reason MSVC builder started to complain about it now,
weird but better not rely on compiler specifics.
2020-06-19 12:36:37 +02:00
Sergey Sharybin b3b445979e Tests: Use explicit signature constants
Are reported by MSVC 2019 after C++17 switch.

One might suggest lets just silence the warning, I will say why to have
specific signed/unsigned types in API just to then (usafely) ignore the
sign conversion.
2020-06-19 12:02:21 +02:00
Sergey Sharybin 0f78a57904 Make BLI_edgehash_test compatible with C++17
random_shuffle was removed (at least the used version).
2020-06-19 12:02:21 +02:00
Sybren A. Stüvel 2dff08c8ce Alembic: always export transforms as inheriting
Blender now always exports transforms as as "inheriting", as Blender has
no concept of parenting without inheriting the transform.

Previously only objects with an actual parent were marked as
"inheriting", and parentless objects as "non-inheriting". However,
certain packages (for example USD's Alembic plugin) are incompatible
with non-inheriting transforms and will completely ignore such
transforms, placing all such objects at the world origin.

When importing non-inheriting transforms from Alembic, Blender will
break the parent-child relation and thus force the child to (correctly)
interpret the transform as world matrix.
2020-06-19 10:24:57 +02:00
Sybren A. Stüvel f106369ce8 Alembic: prevent spaces in names of exported particle systems
Other types already had spaces, periods, and colons replaced by
underscores. The upcoming Alembic exporter (based on the
`AbstractHierarcyIterator` class) will be more consistent and apply the
same naming rules everywhere. This is in preparation for that change.
The `get_…_name()` functions in `abc_util.{cc,h}` will be removed then.
2020-06-19 10:24:51 +02:00
Sybren A. Stüvel 0d744cf673 Alembic: export object data with object data name
Previously the Alembic exporter exported a mesh object to
`{object.name}/{object.name}Shape`. Now it exports to
`{object.name}/{mesh.name}` instead. The same change also applies to
other object data types.

Note that the code now is a bit hackish, as `m_name` is set even in
cases where it isn't used. This hackishness was already there, though,
but it's now just more visible. This will all be cleaned up when the
Alembic exporter is ported to use the `AbstractHierarchyImporter`
structure of the Universal Scene Description (USD) exporter.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D7672
2020-06-19 10:17:41 +02:00
Sybren A. Stüvel 69c3d9804f IO: Allow exporting a subset of the writers
This is in order to prepare for compatibility with the Alembic exporter.
That exporter is capable of writing object transforms and object data at
different (sub)frames.

The rename from `created_writers` to `used_writers` is necessary, as not
all created writers will be actually used in each iteration.

The Universal Scene Description (USD) exporter does not make use of
this.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D7670
2020-06-19 10:17:41 +02:00
Sybren A. Stüvel 084c5d6c7e IO: Move Abstract Hierarchy Iterator into `io/common`
The goal of the `AbstractHierarchyIterator` class (and supporting
classes) was to use it in different exporters. It shouldn't be part of
the USD module + namespace any more, now that it will also be used in
the upcoming Alembic exporter rewrite.

The source files are moved into `io/common`, which is compiled & linked
into a new library `bf_io_common`. The unittests are still inside the
`tests/gtests/usd` directory. They should be moved to a separate test
module too, but that will be delayed until after T73268 has been
resolved.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D7669
2020-06-19 10:17:41 +02:00
Sybren A. Stüvel a5e176a8ed Allow interpolation of matrices with negative scale / axis flips
The matrix interpolation function `interp_m3_m3m3()` decomposes the
matrices into rotation and scale matrices, converts the rotation
matrices to quaternions, SLERPs the quaternions, and converts the result
back to a matrix. Since quaternions cannot represent axis flips, this
results in interpolation problems like described in T77154.

Our interpolation function is based on "Matrix Animation and Polar
Decomposition", by Ken Shoemake & Tom Duff. The paper states that it
produces invalid results when there is an axis flip in the rotation
matrix (or negative determinant, or negative scale, those all indicate
the same thing). Their solution is to multiply the rotation matrix with
`-I`, where `I` is the identity matrix. This is the same as element-wise
multiplication with `-1.0f`. My proposed solution is to not only do that
with the rotation matrix `R`, but also with the scale matrix `S`. This
ensures that the decomposition of `A = R * S` remains valid, while also
making it possible to conver the rotation component to a quaternion.

There is still an issue when interpolating between matrices with
different determinant. As the determinant represents the change in
volume when that matrix is applied to an object, interpolating between a
negative and a positive matrix will have to go through a zero
determinant. In this case the volume collapses to zero. I don't see this
as a big issue, though, as without this patch Blender would also produce
invalid results anyway.

Reviewed By: brecht, sergey

Differential Revision: https://developer.blender.org/D8048
2020-06-18 10:37:52 +02:00
Sybren A. Stüvel 46e4cdf788 Tests: added simple unittests for matrix interpolation
The interpolation of 4x4 and 3x3 matrices will fail when the rotation
component has a singularity, i.e. when there is one axis mirrored. Two
mirrored axes are just a rotation of 180 degrees around the third, and
three mirrored axes are such a rotation + a single axis mirror. To
prepare for a fix, I first wanted to cover the basic functionality with
a few unit tests.

These tests check that `interpolate(A, B, alpha)` always returns `A` for
`alpha=0`, always return `B` for `alpha=1`, and something in between for
`alpha=0.5`.
2020-06-18 10:37:46 +02:00
Bastien Montagne ad6cccf058 Refactor duplicate of data-blocks.
Main change from user side, besides that all pointers should now be
properly remapped to new IDs, is that linked objects are no longer
preserved when doing a full copy of scenes.

Will open a task to check whether we actually still want that behavior
(and re-code it in a more correct way then).

This is the main part of work done here, it aims at uniformizing and
sanitizing that 'deep copy' process for supported IDs (currently scenes,
collections and objects).

Note that there will be more follow up commits after that one, but this
should be the most risky and changing one.
2020-06-17 17:06:05 +02:00
Jacques Lucke 4365de3870 Functions: Multi Function
This adds the `MultiFunction` type and some smallish utility types that it uses.
A `MultiFunction` encapsulates a function that is optimized for throughput by
always processing many elements at once.

This is an important part of the new particle system, because it allows us to
execute user generated node trees for many particles efficiently.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D8030
2020-06-16 16:35:57 +02:00
Jacques Lucke 38c9573b23 BLI: fix Map.foreach_item method 2020-06-16 12:16:07 +02:00
Sergey Sharybin 9cc0597556 Functions: Wrap into blender namespace
Similar to previous commit, aims to resolve compilation on
devtoolset-6.
2020-06-12 15:39:16 +02:00
Sergey Sharybin f8696742bb Fix/workaround compilation error on devtoolset-6
Smells like GCC bug [1], which is backed up by the fact that locally
GCC-10 and CLang-10 works fine.

Since the change is trivial (and, arguably, correct since there is
no real difference between tests code and actual code) seems fine to
fix.

Fix suggested by Jacques Lucke, thanks!

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
2020-06-12 15:17:17 +02:00
Jacques Lucke 3d18bd5c51 BLI: define default hash function for const types 2020-06-11 16:16:44 +02:00
Jacques Lucke f028760b83 BLI: make Map::Item and Map::MutableItem more accessible
This makes it easier to write range-for loops over all items
in the map without using auto.
2020-06-11 10:48:52 +02:00
Jacques Lucke 474b288933 BLI: add Map.pop_default method
There is a nice use case for this in depsgraph code.

Also I added some previously missing calls to std::move.
2020-06-10 19:02:34 +02:00
Jacques Lucke 4c172f7ca6 BLI: support constructing StringRef from start and end pointer 2020-06-10 18:27:18 +02:00
Jacques Lucke a58dc25b07 Cleanup: improve custom data type names
This is related to T76659.

This just renames data type names to `CD_PROP_STRING`, `CD_PROP_FLOAT`
and `CD_PROP_INT32`. It makes them a bit more specific and removes
unnecessary abbreviations.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D7980
2020-06-10 15:47:31 +02:00
Jacques Lucke 4fefe3ac3b BLI: rename tests from "array_ref" to "span"
This was missing in an earlier commit.
2020-06-10 14:50:29 +02:00
Jacques Lucke a71f073dfb BLI: add Map.pop_try method
I found this pattern in depsgraph code more than once.
2020-06-10 14:47:22 +02:00
Jacques Lucke 84a0a6d16c BLI: update behavior of Map.lookup_or_add
Previously, this function would expect a callback function as parameter.
This behavior is now in Map.lookup_or_add_cb. The new version just
takes the key and value directly.
2020-06-10 14:15:04 +02:00
Jacques Lucke f7c0f1b8b8 BLI: rename ArrayRef to Span
This also renames `MutableArrayRef` to `MutableSpan`.
The name "Span" works better, because `std::span` will provide
similar functionality in C++20. Furthermore, a shorter, more
concise name for a common data structure is nice.
2020-06-09 11:58:47 +02:00
Jacques Lucke 9bb7d6ed68 BLI: put C++ data structures in "blender" namespace instead of "BLI"
We plan to use the "blender" namespace in other modules as well.
2020-06-09 10:27:24 +02:00
Jacques Lucke d8678e02ec BLI: generally improve C++ data structures
The main focus here was to improve the docs significantly. Furthermore,
I reimplemented `Set`, `Map` and `VectorSet`. They are now (usually)
faster, simpler and more customizable. I also rewrote `Stack` to make
it more efficient by avoiding unnecessary copies.

Thanks to everyone who helped with constructive feedback.

Approved by brecht and sybren.

Differential Revision: https://developer.blender.org/D7931
2020-06-09 10:15:43 +02:00
Jacques Lucke 0a907657d4 Functions: Run-time type system and index mask
This adds a new `CPPType` that encapsulates information about how to handle
instances of a specific data type. This is necessary for the function evaluation
system, which will be used to evaluate most of the particle node trees.

Furthermore, this adds an `IndexMask` class which offers a surprisingly useful
abstraction over an array containing unsigned integers. It makes two assumptions
about the underlying integer array:
* The integers are in ascending order.
* There are no duplicates.

`IndexMask` will be used to "select" certain particles that will be
processed in a data-oriented way. Sometimes, operations don't have to
be applied to all particles, but only some, those that are in the indexed by
the `IndexMask`. The two limitations imposed by an `IndexMask` allow for
better performance.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D7957
2020-06-08 17:37:43 +02:00
Jeroen Bakker e8b8e16b24 Code Cleanup: fcurve function naming 2020-06-05 09:30:15 +02:00
Jeroen Bakker fe6be70875 CleanUp: Introduce BKE_fcurve_create 2020-06-05 08:41:35 +02:00
Sybren A. Stüvel 78eae89c39 Merge remote-tracking branch 'origin/blender-v2.83-release' 2020-05-26 16:44:35 +02:00
Sybren A. Stüvel a1c9d42584 Fix T77021: Alembic export of animated mesh with multiple UV maps fails
This was caused by a side-effect of our exporting code's memory
management (Alembic considers data "written" and "final" when its C++
objects go out of scope) in combination with my change in
rB65574463fa2d. I removed an "only export UVs on the first frame" clause
because it was unclear why this restriction was there. As it turns out,
it breaks the export of the 2nd and subsequent UV maps on an animated
mesh. Effectively, on every frame the Alembic library thought we want to
create a new UV map, instead of continuing to write a new frame of data
to the existing one.

This is resolved by keeping a reference to the C++ objects for the UV
maps in memory while the exporter is running.
2020-05-26 16:42:01 +02:00
Dalai Felinto 7a51eb5340 Merge remote-tracking branch 'origin/blender-v2.83-release' 2020-05-25 16:37:43 +02:00
Sybren A. Stüvel 026eba8523 Fix T76941: "Set Inverse" in Child Of constraint broken with armatures
When the Child Of constraint is owned by a bone, before the constraint is
run the matrix is converted from world to pose space. However, setting the
inverse should also take the armature object's transform into account.
2020-05-25 15:46:08 +02:00
Campbell Barton 0270941b70 Merge branch 'blender-v2.83-release' 2020-05-25 21:43:54 +10:00
Campbell Barton 7e9480b6cd Tests: correct the blender path for non-portable installations 2020-05-25 21:28:03 +10:00
Campbell Barton 3c40d2485f Merge branch 'blender-v2.83-release' 2020-05-25 21:01:38 +10:00
Campbell Barton d65f60764b GTest: BLI_ghash_performance_test was failing
Change the seed from 0 to 1, so BLI_ghash_performance_test doesn't
assert with duplicate keys.
2020-05-25 20:52:10 +10:00
Jeroen Bakker 9ef272bae3 Task: Graph Flow Task Scheduling
Add TBB::flow graph scheduling to BLI_task.

Using flow graphs, a graph of nodes (tasks) and links can be defined.
Work can flow though the graph. During this process the execution of the nodes will be
scheduled among the available threads.

We are planning to use this to improve the threading in the draw manager.

The implemented API is still limited it only supports sequential flows. Joins and buffers
are not supported. We could eventually support them as part of an CPP API. These features
from uses compile time templates and are hard to make a clean C-API for this.

Reviewed By: Sergey Sharybin, Brecht van Lommel

Differential Revision: https://developer.blender.org/D7578
2020-05-25 12:38:12 +02:00
Jacques Lucke 0c9e73845c BLI: improve Vector test 2020-05-21 14:35:19 +02:00
Brecht Van Lommel 4f622c9a08 Fix Windows build after recent guardedalloc changes 2020-05-20 00:32:17 +02:00
Sybren A. Stüvel 163f21db8c Cleanup: USD test, clarfied comment
No functional changes
2020-05-08 15:41:50 +02:00
Sybren A. Stüvel f9d9bf41f6 Tests: Alembic, log entire command when `abcls` fails
This makes it easier to manually run the `abcls` when a test fails, aiding
inspection & fixing.

No function changes to actual Blender code.
2020-05-08 15:10:28 +02:00
Sybren A. Stüvel 163a48f203 Cleanup: Alembic, moved axis conversion functions into their own files
The long-term goal is to move code out of `abc_util.{h,cc}` into either
files with better, more concrete names, or simply into the one file
where they are used.

No functional changes.
2020-05-08 12:19:43 +02:00
Sybren A. Stüvel 1771c7e441 Merge remote-tracking branch 'origin/blender-v2.83-release' 2020-05-04 18:08:17 +02:00
Sybren A. Stüvel 0c8b872188 Fix T76355: USD test fails in debug mode
Thanks @LazyDodo for the help!

No functional changes.
2020-05-04 18:03:19 +02:00
Jacques Lucke df16c23832 Add StringMap.LookupOrAdd and StringMap.LookupOrAddDefault 2020-05-04 17:12:23 +02:00
Sybren A. Stüvel b3553c0961 Cleanup: USD tests, use `EXPECT_LT` and `EXPECT_FALSE` where appropriate
Unfortunately there is no `EXPECT_NOT_LT`; as the `HierarchyContext` only
has an `operator<()` function, testing for `(A < B) == false` is different
than simply testing `(A >= B)`.

No functional changes.
2020-05-04 16:17:54 +02:00
Campbell Barton 76be35efb2 Cleanup: clang-format 2020-05-03 13:42:49 +10:00
Sybren A. Stüvel 28bdf669a9 Fix: added missing buildinfo to BKE_fcurve test 2020-05-01 12:45:53 +02:00
Sybren A. Stüvel 9a4844cfdb Tests: Animation, added unittests for FCurve evaluation
This introduces unittests for FCurve evaluation.

No functional changes to actual Blender code.

Differential Revision: https://developer.blender.org/D6778
2020-05-01 11:56:59 +02:00
Brecht Van Lommel d8a3f3595a Task: Use TBB as Task Scheduler
This patch enables TBB as the default task scheduler. TBB stands for Threading Building Blocks and is developed by Intel. The library contains several threading patters. This patch maps blenders BLI_task_* function to their counterpart. After this patch we can add more patterns. A promising one is TBB:graph that can be used for depsgraph, draw manager and compositor.

Performance changes depends on the actual hardware. It was tested on different hardwares from laptops to workstations and we didn't detected any downgrade of the performance.
* Linux Xeon E5-2699 v4 got FPS boost from 12 to 17 using Spring's 04_010_A.anim.blend.
* AMD Ryzen Threadripper 2990WX 32-Core Animation playback goes from 9.5-10.5 FPS to 13.0-14.0 FPS on Agent 327 , 10_03_B.anim.blend.

Reviewed By: brecht, sergey

Differential Revision: https://developer.blender.org/D7475
2020-04-30 08:09:21 +02:00
Jacques Lucke 4d06c1c25b BLI: add VectorSet.is_empty method 2020-04-28 19:18:12 +02:00
Jacques Lucke a72eed7dd5 BLI: rename Vector.empty to Vector.is_empty 2020-04-28 17:04:07 +02:00
Jacques Lucke c05ef1459c BLI: add Set.clear method 2020-04-28 16:41:37 +02:00
Jacques Lucke d575b72c16 BLI: add Set.is_empty method 2020-04-28 16:35:49 +02:00
Jacques Lucke 9c65ac7311 BLI: add Map.lookup_or_add_default method 2020-04-28 13:55:36 +02:00
Brecht Van Lommel 20100009f6 Fix armature roll test failing on macOS 2020-04-28 13:31:59 +02:00
Brecht Van Lommel 8da80e7771 Merge branch 'blender-v2.83-release' 2020-04-28 13:02:06 +02:00
Brecht Van Lommel 6cab53eaaa Tests: fix some tests passing even if there are Python errors
Blender was not configured to exit with non-zero return code on Python errors.
A bunch of tests worked around this but not all. This removes the need for such
workarounds.
2020-04-28 12:50:16 +02:00
Brecht Van Lommel a7bd835644 Fix Python bundled module test error
We don't bundle cffi, rather the ffi library is used for ctypes. This test is
currently passing even when there are errors, that will be fixed next.
2020-04-28 12:48:29 +02:00
Himanshi Kalra b9f422c4be Tests: add physics tests cloth and softybody
This uses the same framework as automated modifier tests. It adds a physics
modifier, bakes and compares vertex coordinates on the end frame.

Differential Revision: https://developer.blender.org/D7017
2020-04-28 12:29:46 +02:00
Howard Trickey 18e9626e41 Strengthen modifiers test validation, from D7397.
Submitting on behalf of Jesse Y (deadpin).
In test harness for modifier testing, now run mesh validation
on output mesh. Also, fix printing so it interleaves properly.
2020-04-28 12:27:33 +02:00
Jacques Lucke 9c2715ffda BLI: add Map.is_empty() method 2020-04-28 11:44:10 +02:00
Jacques Lucke c5f4d5e448 BLI: add LinearAllocator
This allocator is useful when it is necessary to allocate many small elements.
2020-04-24 23:52:55 +02:00
Jacques Lucke 1f2b1d520f BLI: improve StringRef.copy 2020-04-24 23:35:17 +02:00
Jacques Lucke 62f6255b47 BLI: Implement StringMap.add and StringMap.add_or_modify 2020-04-24 22:33:48 +02:00
Sybren A. Stüvel be5c9d45bd Tests: use explicit Python to run unit tests
CentOS on the buildbot still runs Python 3.6, which is also used for the
unit tests. This means that the tests can't use language features that
are available to Blender itself. And testing with a different version of
Python than will be used by the actual code seems like a bad idea to me.

This commit adds `TEST_PYTHON_EXECUTABLE` as advanced CMake option. This
will allow us to set a specific Python executable when we need it. When
not set, a platform-specific default will be used:

- On Windows, the `python….exe` from the installation directory. This is
  just like before this patch, except that this patch adds the
  overridability.
- On macOS/Linux, the `${PYTHON_EXECUTABLE}` as found by CMake.

Every platform should now have a value (configured by the user or
detected by CMake) for `TEST_PYTHON_EXE`, so there is no need to allow
running without. This also removes the need to have some Python files
marked as executable.

If `TEST_PYTHON_EXE` is not user-configured, and thus the above default
is used, a status message is logged by CMake. I've seen this a lot in
other projects, and I like that it shows which values are auto-detected.
However, it's not common in Blender, so if we want we can either remove
it now, or remove it after the buildbot has been set up correctly.

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

Reviewed by: campbellbarton, mont29, sergey
2020-04-24 17:10:22 +02:00
Jacques Lucke 8f5a4a4da3 BLI: various data structure improvements
* Rename template parameter N to InlineBufferCapacity
* Expose InlineBufferCapacity parameter for Set and Map
* Add some comments
* Fixed an error that I introduced recently
2020-04-23 20:05:53 +02:00
Brecht Van Lommel 3b47f335c6 BLI: remove TaskParallelRangePool
This is not currently used and will take some work to support with TBB, so
remove it until we have a new implementation based on TBB.

Fixes T76005, parallel range pool tests failing.

Ref D7475
2020-04-23 15:39:34 +02:00
Brecht Van Lommel 8f51f60948 Fix T76005: BLI_task test failing after recent changes
This was an error in changes made to this test to accomodate the new reduce
callback.
2020-04-23 14:04:29 +02:00
Jacques Lucke 614621747e BLI: optimize VectorSet implementation
Instead of building on top of `BLI::Vector`, just use a raw array
and handle the growing in `BLI::VectorSet`.

After this change, the existing `EdgeSet` can be reimplemented using
`BLI::VectorSet` without performance regressions.
2020-04-23 12:02:06 +02:00
Ray Molenkamp 6c9bebd827 Tests: Fix build error in BKE_armature test
Test does not link due to missing symbols, needs
buildinfoobj to link against when WITH_BUILDINFO is on
2020-04-22 07:47:32 -06:00
Sybren A. Stüvel 93e193399d Tests: added unit test for `mat3_vec_to_roll()` function
This was used to investigate T73840. Since the armature math is far from
simple, I thought it would be a good idea to start writing some unit
tests for it.

No functional changes in Blender itself.
2020-04-21 17:58:27 +02:00
Jacques Lucke 29e9506a7f BLI: simplify naming of listbase wrapper 2020-04-21 17:38:19 +02:00
Jacques Lucke 3059353b38 BLI: Use .hh extension for C++ headers in blenlib 2020-04-21 17:31:56 +02:00
Jeroen Bakker 2d6ad88466 CleanUp: Renamed `BLI_task_pool_userdata` to `BLI_task_pool_user_data`
In preparation for {D7475}
2020-04-21 15:37:36 +02:00
Howard Trickey a93ed3bcb7 Strengthen modifiers test validation, from D7397.
Submitting on behalf of Jesse Y (deadpin).
In test harness for modifier testing, now run mesh validation
on output mesh. Also, fix printing so it interleaves properly.
2020-04-21 08:15:26 -04:00
Jeroen Bakker d923fb784f Task: Separate Finalize into Reduce And Free
In preparation of TBB we need to split the finalize function into reduce
and free. Reduce is used to combine results and free for freeing any
allocated memory.

The reduce function is called to join user data chunk into another, to reduce the
result to the original userdata_chunk memory. These functions should have no side
effects so that they can be run on any thread.
The free functions should free data created during execution (TaskParallelRangeFunc).

Original patch by Brecht van Lommel
{rB61f49db843cf5095203112226ae386f301be1e1a}.

Reviewed By: Brecht van Lommel, Bastien Montagne

Differential Revision: https://developer.blender.org/D7394
2020-04-17 16:06:54 +02:00
Brecht Van Lommel 78f56d5582 TaskScheduler: Minor Preparations for TBB
Tasks: move priority from task to task pool {rBf7c18df4f599fe39ffc914e645e504fcdbee8636}
Tasks: split task.c into task_pool.cc and task_iterator.c {rB4ada1d267749931ca934a74b14a82479bcaa92e0}

Differential Revision: https://developer.blender.org/D7385
2020-04-09 19:18:14 +02:00
Sybren A. Stüvel 17da3b5d82 USD: ensure test does not depend on BLI_assert()
The test failure in T75491 only showed up in debug builds because
`BLI_assert()` is a no-op in release builds. This is now replaced by a
proper GTests call to `ADD_FAILURE()`, ensuring that the test fails
regardless of build mode.
2020-04-09 12:14:51 +02:00