diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-09-06 16:54:08 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-09-06 16:58:38 +0400 |
commit | e44c49d89d67038657cdcbd373e64b9a17b6c993 (patch) | |
tree | 1a4d64bdbaca13948bb5927dd83c5477638aa55a /source/blender/python/mathutils/mathutils_Matrix.h | |
parent | f670a8aeaa9ac63f3245bed1ba9bd84c0b575aa3 (diff) |
Py Mathutils: add `invert_safe()` and `inverted_safe()` to `Matrix`.
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!
Diffstat (limited to 'source/blender/python/mathutils/mathutils_Matrix.h')
-rw-r--r-- | source/blender/python/mathutils/mathutils_Matrix.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h index c7fb23d8776..f94af9e540e 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.h +++ b/source/blender/python/mathutils/mathutils_Matrix.h @@ -41,6 +41,7 @@ extern PyTypeObject matrix_access_Type; # define MATRIX_ITEM_ASSERT(_mat, _row, _col) (void)0 #endif +#define MATRIX_ITEM_INDEX_NUMROW(_totrow, _row, _col) ((_totrow * (_col)) + (_row)) #define MATRIX_ITEM_INDEX(_mat, _row, _col) (MATRIX_ITEM_ASSERT(_mat, _row, _col),(((_mat)->num_row * (_col)) + (_row))) #define MATRIX_ITEM_PTR( _mat, _row, _col) ((_mat)->matrix + MATRIX_ITEM_INDEX(_mat, _row, _col)) #define MATRIX_ITEM( _mat, _row, _col) ((_mat)->matrix [MATRIX_ITEM_INDEX(_mat, _row, _col)]) |