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!
This commit is contained in:
@@ -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)])
|
||||
|
Reference in New Issue
Block a user