Support 2D KDTree's as well as 3D, allowing KDTree's to be built
from 2D data, using 2D coordinates for lookups/searching.
- Add dimension keyword argument for new KDTree's.
- Add KDTree.dimension read-only accessor.
- Add `Doxygen` documentation.
- Update tests.
Ref !159342
Extend slice get/set on Vector, Color, Euler, Quaternion, Matrix and
MatrixAccess to support extended slices with arbitrary step
(`obj[::2]`, `obj[::-1]`, etc.), matching Python list semantics,
with the exception that resizing isn't supported.
This also add support for MatrixAccess slice assignment
(mat.row[i:j] = ..., mat.col[i:j] = ...) previously raised TypeError.
Tests extended with checks that steps work as intended.
Ref !158183
Row and column access used `BaseMath_ReadCallback_ForWrite`
which fails on frozen matrices, returning NULL.
Use the read-only `BaseMath_ReadCallback`, rely on the write
checks on the vectors to ensure the frozen matrix isn't modified.
Also correct invalid ROW/COL comments.
Ref !158183
- Parsing zero length arrays entered a while loop starting at index -1
mathutils_array_parse_fast, writing into negative indices (crashing).
- Color & Euler assignment wrote past the parsed size because their
assignment loops iterated on their type size instead of the slice size.
Tests added for empty-slice assignment.
Ref !158183
Expression such as: vec[0:3] = (1, 2, 3, 4)
Would silently ignore trailing items,
Other mathutils types would raise an error but vector ignored this.
Update tests and note why raising an exception is preferred
over resizing.
Ref !158183
A long standing confusion with the C/Python API is arguments
that are optional and documented as defaulting to "None" yet,
will fail with a type error if None is passed in.
This is confusing both for API users & developers,
as well as making the code difficult to properly type check.
The reason for this is PyArg_Parse* functions don't support
parsing arguments that can optionally be None for most types.
Resolve by adding our own argument parsing helpers.
Also rename bmesh 'example' parameter to 'source'
for verts/edges/faces.new and face_split.
To match BMesh internal naming, although this is only for documentation
purposes as it isn't a keyword argument.
Ref !154178
Regression in [0] which removed `__new__`, which broke
sub-class instancing.
Resolve by adding back `__new__` which wraps `tp_vectorcall`.
The speed-up from [0] remains as direct calls to mathutils types
still use `tp_vectorcall`.
Include tests to ensure sub-typing mathutils types works as expected.
Ref !149685
[0]: b2176bfdd7
Regression in [0] failed to account for keywords being changed from
a dict to a tuple.
Include a test to ensure keyword arguments are ignored.
Ref !149685
[0]: b2176bfdd7
It's important that frozen types are immutable, add a generic
check that mathutils types can be resized and check the frozen flag.
Also correct the exception types when Vector's cant be resized,
using a ValueError instead of a TypeError as the type is correct.
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.
While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.
Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.
Some directories in `./intern/` have also been excluded:
- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.
An "AUTHORS" file has been added, using the chromium projects authors
file as a template.
Design task: #110784
Ref !110783.
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
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
This 'fixes' T68554: 'API mathutils.geometry.tessellate_polygon returns
bad results sometimes' by documenting the limitations of the current
implementation.
I've also added a unit test for the function, so that any change in this
behaviour will get noticed.
No functional changes.
Added conversion to and from exponential map representation. This
representation is useful for interpolation of > 2 quaternions, or in
PD controllers.
Implementation in C functions quat_to_expmap,
quat_normalized_to_expmap, and expmap_to_quat with Python API, unit
tests and documentation.
Added Quaternion.to_exponential_map() and Quaternion(3-vector) to
Python API.
Reviewers: campbellbarton
Projects: #bf_blender
Differential Revision: https://developer.blender.org/D1049
Those two mimic our BLI invert_m4_m4_safe - they add a small offset to diagonal values,
in case org matrix is degenerated, and if still non-invertible, return identity matrix.
Org patch by me, final enhanced version by ideasman42, many thanks!