2011-02-18 13:58:08 +00:00
|
|
|
/*
|
2009-11-09 22:42:41 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-11-09 22:42:41 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2019-03-19 15:17:46 +11:00
|
|
|
* The Original Code is: some of this file.
|
2021-01-20 15:15:38 +11:00
|
|
|
*/
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup bli
|
2011-02-18 13:58:08 +00:00
|
|
|
*/
|
|
|
|
|
2020-05-08 18:16:39 +02:00
|
|
|
#include "BLI_compiler_attrs.h"
|
|
|
|
#include "BLI_sys_types.h"
|
|
|
|
|
2009-11-09 22:42:41 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/********************************* Init **************************************/
|
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
void zero_m2(float m[2][2]);
|
|
|
|
void zero_m3(float m[3][3]);
|
|
|
|
void zero_m4(float m[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
void unit_m2(float m[2][2]);
|
|
|
|
void unit_m3(float m[3][3]);
|
|
|
|
void unit_m4(float m[4][4]);
|
2019-08-20 21:09:55 +08:00
|
|
|
void unit_m4_db(double m[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
void copy_m2_m2(float m1[2][2], const float m2[2][2]);
|
|
|
|
void copy_m3_m3(float m1[3][3], const float m2[3][3]);
|
|
|
|
void copy_m4_m4(float m1[4][4], const float m2[4][4]);
|
|
|
|
void copy_m3_m4(float m1[3][3], const float m2[4][4]);
|
|
|
|
void copy_m4_m3(float m1[4][4], const float m2[3][3]);
|
|
|
|
void copy_m3_m2(float m1[3][3], const float m2[2][2]);
|
|
|
|
void copy_m4_m2(float m1[4][4], const float m2[2][2]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2019-08-20 21:09:55 +08:00
|
|
|
void copy_m4_m4_db(double m1[4][4], const double m2[4][4]);
|
|
|
|
|
2013-10-20 12:08:51 +00:00
|
|
|
/* double->float */
|
2020-09-04 20:59:13 +02:00
|
|
|
void copy_m3_m3d(float m1[3][3], const double m2[3][3]);
|
2013-10-20 12:08:51 +00:00
|
|
|
|
2019-08-20 21:09:55 +08:00
|
|
|
/* float->double */
|
2020-09-04 20:59:13 +02:00
|
|
|
void copy_m4d_m4(double m1[4][4], const float m2[4][4]);
|
2019-08-20 21:09:55 +08:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
void swap_m3m3(float m1[3][3], float m2[3][3]);
|
|
|
|
void swap_m4m4(float m1[4][4], float m2[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2020-02-15 01:49:50 +01:00
|
|
|
/* Build index shuffle matrix */
|
2020-07-13 11:27:09 +02:00
|
|
|
void shuffle_m4(float R[4][4], const int index[4]);
|
2020-02-15 01:49:50 +01:00
|
|
|
|
2009-11-09 22:42:41 +00:00
|
|
|
/******************************** Arithmetic *********************************/
|
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
void add_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3]);
|
|
|
|
void add_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4]);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2019-04-05 18:40:59 +03:00
|
|
|
void madd_m3_m3m3fl(float R[3][3], const float A[3][3], const float B[3][3], const float f);
|
|
|
|
void madd_m4_m4m4fl(float R[4][4], const float A[4][4], const float B[4][4], const float f);
|
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
void sub_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3]);
|
|
|
|
void sub_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3]);
|
|
|
|
void mul_m4_m3m4(float R[4][4], const float A[3][3], const float B[4][4]);
|
|
|
|
void mul_m4_m4m3(float R[4][4], const float A[4][4], const float B[3][3]);
|
|
|
|
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4]);
|
2019-04-14 18:13:39 +03:00
|
|
|
void mul_m3_m3m4(float R[3][3], const float A[3][3], const float B[4][4]);
|
|
|
|
void mul_m3_m4m3(float R[3][3], const float A[4][4], const float B[3][3]);
|
|
|
|
void mul_m3_m4m4(float R[3][3], const float A[4][4], const float B[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2016-09-25 18:48:11 +02:00
|
|
|
/* special matrix multiplies
|
|
|
|
* uniq: R <-- AB, R is neither A nor B
|
|
|
|
* pre: R <-- AR
|
|
|
|
* post: R <-- RB
|
|
|
|
*/
|
|
|
|
void mul_m3_m3m3_uniq(float R[3][3], const float A[3][3], const float B[3][3]);
|
|
|
|
void mul_m3_m3_pre(float R[3][3], const float A[3][3]);
|
|
|
|
void mul_m3_m3_post(float R[3][3], const float B[3][3]);
|
|
|
|
void mul_m4_m4m4_uniq(float R[4][4], const float A[4][4], const float B[4][4]);
|
2019-08-20 21:09:55 +08:00
|
|
|
void mul_m4_m4m4_db_uniq(double R[4][4], const double A[4][4], const double B[4][4]);
|
|
|
|
void mul_m4db_m4db_m4fl_uniq(double R[4][4], const double A[4][4], const float B[4][4]);
|
2016-09-25 18:48:11 +02:00
|
|
|
void mul_m4_m4_pre(float R[4][4], const float A[4][4]);
|
|
|
|
void mul_m4_m4_post(float R[4][4], const float B[4][4]);
|
2016-09-25 14:27:48 +02:00
|
|
|
|
2014-07-21 18:55:12 +10:00
|
|
|
/* mul_m3_series */
|
2017-08-04 15:05:02 +10:00
|
|
|
void _va_mul_m3_series_3(float R[3][3], const float M1[3][3], const float M2[3][3]) ATTR_NONNULL();
|
2019-04-14 18:13:39 +03:00
|
|
|
void _va_mul_m3_series_4(float R[3][3],
|
2017-08-04 15:05:02 +10:00
|
|
|
const float M1[3][3],
|
|
|
|
const float M2[3][3],
|
|
|
|
const float M3[3][3]) ATTR_NONNULL();
|
|
|
|
void _va_mul_m3_series_5(float R[3][3],
|
|
|
|
const float M1[3][3],
|
|
|
|
const float M2[3][3],
|
|
|
|
const float M3[3][3],
|
|
|
|
const float M4[3][3]) ATTR_NONNULL();
|
|
|
|
void _va_mul_m3_series_6(float R[3][3],
|
|
|
|
const float M1[3][3],
|
|
|
|
const float M2[3][3],
|
|
|
|
const float M3[3][3],
|
|
|
|
const float M4[3][3],
|
|
|
|
const float M5[3][3]) ATTR_NONNULL();
|
|
|
|
void _va_mul_m3_series_7(float R[3][3],
|
|
|
|
const float M1[3][3],
|
|
|
|
const float M2[3][3],
|
|
|
|
const float M3[3][3],
|
|
|
|
const float M4[3][3],
|
|
|
|
const float M5[3][3],
|
|
|
|
const float M6[3][3]) ATTR_NONNULL();
|
|
|
|
void _va_mul_m3_series_8(float R[3][3],
|
|
|
|
const float M1[3][3],
|
|
|
|
const float M2[3][3],
|
|
|
|
const float M3[3][3],
|
|
|
|
const float M4[3][3],
|
|
|
|
const float M5[3][3],
|
|
|
|
const float M6[3][3],
|
|
|
|
const float M7[3][3]) ATTR_NONNULL();
|
|
|
|
void _va_mul_m3_series_9(float R[3][3],
|
|
|
|
const float M1[3][3],
|
|
|
|
const float M2[3][3],
|
|
|
|
const float M3[3][3],
|
|
|
|
const float M4[3][3],
|
|
|
|
const float M5[3][3],
|
|
|
|
const float M6[3][3],
|
|
|
|
const float M7[3][3],
|
|
|
|
const float M8[3][3]) ATTR_NONNULL();
|
2014-07-21 18:55:12 +10:00
|
|
|
/* mul_m4_series */
|
2017-08-04 15:05:02 +10:00
|
|
|
void _va_mul_m4_series_3(float R[4][4], const float M1[4][4], const float M2[4][4]) ATTR_NONNULL();
|
|
|
|
void _va_mul_m4_series_4(float R[4][4],
|
|
|
|
const float M1[4][4],
|
|
|
|
const float M2[4][4],
|
|
|
|
const float M3[4][4]) ATTR_NONNULL();
|
|
|
|
void _va_mul_m4_series_5(float R[4][4],
|
|
|
|
const float M1[4][4],
|
|
|
|
const float M2[4][4],
|
|
|
|
const float M3[4][4],
|
|
|
|
const float M4[4][4]) ATTR_NONNULL();
|
|
|
|
void _va_mul_m4_series_6(float R[4][4],
|
|
|
|
const float M1[4][4],
|
|
|
|
const float M2[4][4],
|
|
|
|
const float M3[4][4],
|
|
|
|
const float M4[4][4],
|
|
|
|
const float M5[4][4]) ATTR_NONNULL();
|
|
|
|
void _va_mul_m4_series_7(float R[4][4],
|
|
|
|
const float M1[4][4],
|
|
|
|
const float M2[4][4],
|
|
|
|
const float M3[4][4],
|
|
|
|
const float M4[4][4],
|
|
|
|
const float M5[4][4],
|
|
|
|
const float M6[4][4]) ATTR_NONNULL();
|
|
|
|
void _va_mul_m4_series_8(float R[4][4],
|
|
|
|
const float M1[4][4],
|
|
|
|
const float M2[4][4],
|
|
|
|
const float M3[4][4],
|
|
|
|
const float M4[4][4],
|
|
|
|
const float M5[4][4],
|
|
|
|
const float M6[4][4],
|
|
|
|
const float M7[4][4]) ATTR_NONNULL();
|
|
|
|
void _va_mul_m4_series_9(float R[4][4],
|
|
|
|
const float M1[4][4],
|
|
|
|
const float M2[4][4],
|
|
|
|
const float M3[4][4],
|
|
|
|
const float M4[4][4],
|
|
|
|
const float M5[4][4],
|
|
|
|
const float M6[4][4],
|
|
|
|
const float M7[4][4],
|
|
|
|
const float M8[4][4]) ATTR_NONNULL();
|
2014-07-21 18:55:12 +10:00
|
|
|
|
|
|
|
#define mul_m3_series(...) VA_NARGS_CALL_OVERLOAD(_va_mul_m3_series_, __VA_ARGS__)
|
|
|
|
#define mul_m4_series(...) VA_NARGS_CALL_OVERLOAD(_va_mul_m4_series_, __VA_ARGS__)
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
void mul_m4_v3(const float M[4][4], float r[3]);
|
|
|
|
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3]);
|
2019-08-20 21:09:55 +08:00
|
|
|
void mul_v3_m4v3_db(double r[3], const double mat[4][4], const double vec[3]);
|
|
|
|
void mul_v4_m4v3_db(double r[4], const double mat[4][4], const double vec[3]);
|
2016-09-24 16:21:38 +02:00
|
|
|
void mul_v2_m4v3(float r[2], const float M[4][4], const float v[3]);
|
|
|
|
void mul_v2_m2v2(float r[2], const float M[2][2], const float v[2]);
|
2020-02-20 13:25:53 +11:00
|
|
|
void mul_m2_v2(const float M[2][2], float v[2]);
|
2016-09-24 16:21:38 +02:00
|
|
|
void mul_mat3_m4_v3(const float M[4][4], float r[3]);
|
|
|
|
void mul_v3_mat3_m4v3(float r[3], const float M[4][4], const float v[3]);
|
2019-08-20 21:09:55 +08:00
|
|
|
void mul_v3_mat3_m4v3_db(double r[3], const double M[4][4], const double v[3]);
|
2016-09-24 16:21:38 +02:00
|
|
|
void mul_m4_v4(const float M[4][4], float r[4]);
|
|
|
|
void mul_v4_m4v4(float r[4], const float M[4][4], const float v[4]);
|
2016-09-25 19:01:18 +02:00
|
|
|
void mul_v4_m4v3(float r[4], const float M[4][4], const float v[3]); /* v has implicit w = 1.0f */
|
2016-09-24 16:21:38 +02:00
|
|
|
void mul_project_m4_v3(const float M[4][4], float vec[3]);
|
|
|
|
void mul_v3_project_m4_v3(float r[3], const float mat[4][4], const float vec[3]);
|
|
|
|
void mul_v2_project_m4_v3(float r[2], const float M[4][4], const float vec[3]);
|
|
|
|
|
|
|
|
void mul_m3_v2(const float m[3][3], float r[2]);
|
|
|
|
void mul_v2_m3v2(float r[2], const float m[3][3], const float v[2]);
|
|
|
|
void mul_m3_v3(const float M[3][3], float r[3]);
|
|
|
|
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3]);
|
|
|
|
void mul_v2_m3v3(float r[2], const float M[3][3], const float a[3]);
|
|
|
|
void mul_transposed_m3_v3(const float M[3][3], float r[3]);
|
|
|
|
void mul_transposed_mat3_m4_v3(const float M[4][4], float r[3]);
|
|
|
|
void mul_m3_v3_double(const float M[3][3], double r[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
Action Constraint: introduce a mix mode setting.
Currently the action channels are applied after the existing
transformation, as if the action controlled a child of the
bone. This is not very natural, but more importantly, the
transform tools are not designed to work conveniently with an
additional 'pseudo-child' transformation, resulting in effects
like an unexpected pivot location.
Implementing a Before mode that integrates the action channels
as if applied to a parent allows using the special transform
tool code intended for dealing with such constraints.
Note that in either mode, Action constraints should be added
in reverse order, putting a new constraint before the existing
ones that the Action was keyframed to work together.
In order to implement the option, extract a utility from
the Copy Transform constraint code for combining transforms
with special anti-shear scale handling that matches the
Aligned Inherit Scale mode.
The Before mode also requires switching the constraint to
the Local owner space, while the After mode can still use the
World space for efficiency as before. Since the constraint
doesn't have an Owner space option in the UI, this has to be
handled in an RNA setter.
For full backward compatibility, the original simple matrix
multiplication mode is preserved as the third option, but it
is not recommended due to creating shear.
Differential Revision: https://developer.blender.org/D6297
2019-11-23 13:11:39 +03:00
|
|
|
void mul_m4_m4m4_aligned_scale(float R[4][4], const float A[4][4], const float B[4][4]);
|
|
|
|
|
2009-11-10 19:13:05 +00:00
|
|
|
void mul_m3_fl(float R[3][3], float f);
|
|
|
|
void mul_m4_fl(float R[4][4], float f);
|
|
|
|
void mul_mat3_m4_fl(float R[4][4], float f);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2014-10-30 10:26:22 +01:00
|
|
|
void negate_m3(float R[3][3]);
|
2014-10-30 15:26:41 +01:00
|
|
|
void negate_mat3_m4(float R[4][4]);
|
2014-05-30 00:26:05 +10:00
|
|
|
void negate_m4(float R[4][4]);
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
bool invert_m3_ex(float m[3][3], const float epsilon);
|
2016-09-24 16:21:38 +02:00
|
|
|
bool invert_m3_m3_ex(float m1[3][3], const float m2[3][3], const float epsilon);
|
2012-11-07 09:28:59 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
bool invert_m3(float R[3][3]);
|
2016-09-24 16:21:38 +02:00
|
|
|
bool invert_m3_m3(float R[3][3], const float A[3][3]);
|
2014-04-01 11:34:00 +11:00
|
|
|
bool invert_m4(float R[4][4]);
|
2016-09-24 16:21:38 +02:00
|
|
|
bool invert_m4_m4(float R[4][4], const float A[4][4]);
|
2019-05-05 16:04:10 +02:00
|
|
|
bool invert_m4_m4_fallback(float R[4][4], const float A[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2016-06-14 16:43:14 +10:00
|
|
|
/* double arithmetic (mixed float/double) */
|
2016-09-24 16:21:38 +02:00
|
|
|
void mul_m4_v4d(const float M[4][4], double r[4]);
|
|
|
|
void mul_v4d_m4v4d(double r[4], const float M[4][4], const double v[4]);
|
2012-03-08 11:57:51 +00:00
|
|
|
|
2016-06-14 16:43:14 +10:00
|
|
|
/* double matrix functions (no mixing types) */
|
2016-09-24 16:21:38 +02:00
|
|
|
void mul_v3_m3v3_db(double r[3], const double M[3][3], const double a[3]);
|
|
|
|
void mul_m3_v3_db(const double M[3][3], double r[3]);
|
2016-06-14 16:43:14 +10:00
|
|
|
|
2009-11-09 22:42:41 +00:00
|
|
|
/****************************** Linear Algebra *******************************/
|
|
|
|
|
|
|
|
void transpose_m3(float R[3][3]);
|
2020-09-04 20:59:13 +02:00
|
|
|
void transpose_m3_m3(float R[3][3], const float M[3][3]);
|
|
|
|
void transpose_m3_m4(float R[3][3], const float M[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
void transpose_m4(float R[4][4]);
|
2020-09-04 20:59:13 +02:00
|
|
|
void transpose_m4_m4(float R[4][4], const float M[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
bool compare_m4m4(const float mat1[4][4], const float mat2[4][4], float limit);
|
Blender Internal Render in viewport
Because of our release soon, feature has been added behind the Debug Menu.
CTRL+ALT+D and set it to -1. Or commandline --debug-value -1.
When debug set to -1, you can put the viewport to 'render' mode, just like
for Cycles. Notes for testers: (and please no bugs in tracker for this :)
- It renders without AA, MBlur, Panorama, Sequence, Composite
- Only active render layer gets rendered. Select another layer will re-render.
- But yes: it works for FreeStyle renders!
- Also does great for local view.
- BI is not well suited for incremental renders on view changes. This only
works for non-raytrace scenes, or zoom in ortho or camera mode, or for
Material changes. In most cases a full re-render is being done.
- ESC works to stop the preview render.
- Borders render as well. (CTRL+B)
- Force a refresh with arrow key left/right. A lot of settings don't trigger
re-render yet.
Tech notes:
- FreeStyle is adding a lot of temp objects/meshes in the Main database. This
caused DepsGraph to trigger changes (and redraws). I've prepended the names
for these temp objects with char number 27 (ESC), and made these names be
ignored for tag update checking.
- Fixed some bugs that were noticable with such excessive re-renders, like
for opening file window, quit during renders.
2013-04-16 17:39:20 +00:00
|
|
|
|
2020-02-20 12:48:42 +11:00
|
|
|
void normalize_m2_ex(float R[2][2], float r_scale[2]) ATTR_NONNULL();
|
|
|
|
void normalize_m2(float R[2][2]) ATTR_NONNULL();
|
2020-09-04 20:59:13 +02:00
|
|
|
void normalize_m2_m2_ex(float R[2][2], const float M[2][2], float r_scale[2]) ATTR_NONNULL();
|
|
|
|
void normalize_m2_m2(float R[2][2], const float M[2][2]) ATTR_NONNULL();
|
2015-10-15 21:03:27 +11:00
|
|
|
void normalize_m3_ex(float R[3][3], float r_scale[3]) ATTR_NONNULL();
|
|
|
|
void normalize_m3(float R[3][3]) ATTR_NONNULL();
|
2020-09-04 20:59:13 +02:00
|
|
|
void normalize_m3_m3_ex(float R[3][3], const float M[3][3], float r_scale[3]) ATTR_NONNULL();
|
|
|
|
void normalize_m3_m3(float R[3][3], const float M[3][3]) ATTR_NONNULL();
|
2015-10-15 21:03:27 +11:00
|
|
|
void normalize_m4_ex(float R[4][4], float r_scale[3]) ATTR_NONNULL();
|
|
|
|
void normalize_m4(float R[4][4]) ATTR_NONNULL();
|
2020-09-04 20:59:13 +02:00
|
|
|
void normalize_m4_m4_ex(float R[4][4], const float M[4][4], float r_scale[3]) ATTR_NONNULL();
|
|
|
|
void normalize_m4_m4(float R[4][4], const float M[4][4]) ATTR_NONNULL();
|
2009-11-09 22:42:41 +00:00
|
|
|
|
|
|
|
void orthogonalize_m3(float R[3][3], int axis);
|
|
|
|
void orthogonalize_m4(float R[4][4], int axis);
|
|
|
|
|
Armature: add Inherit Scale options to remove shear or average the scale.
As an inherent property of matrix-based transformation math, non-
uniform scaling of a parent bone induces shear into the transform
matrix of any rotated child. Such matrices cannot be cleanly
decomposed into a combination of location/rotation/scale, which
causes issues for rigging and animation tools.
Blender bones have options to exclude rotation and/or scale from the
inherited transformation, but don't have any support for removing the
often undesired shear component. That goal requires replacing simple
parenting with a combination of multiple bones and constraints. The
same is true about the goal of inheriting some scale, but completely
avoiding shear.
This patch replaces the old Inherit Scale checkbox with a enum that
supports multiple options:
* Full: inherit all effects of scale, like with enabled Inherit Scale.
* Fix Shear: removes shear from the final inherited transformation.
The cleanup math is specifically designed to preserve the main
axis of the bone, its length and total volume, and minimally
affect roll on average. It however will not prevent reappearance
of shear due to local rotation of the child or its children.
* Average: inherit uniform scale that represents the parent volume.
This is the simplest foolproof solution that will inherit some
scale without ever causing shear.
* None: completely remove scale and shear.
* None (Legacy): old disabled Inherit Scale checkbox.
This mode does not handle parent shear in any way, so the child
is likely to end up having both scale and shear. It is retained
for backward compatibility.
Since many rigging-related addons access the use_inherit_scale
property from Python, it is retained as a backward compatibility
stub that provides the old functionality.
As a side effect of reworking the code, this also fixes a matrix
multiplication order bug in the Inherit Rotation code, which caused
the parent local scale to be applied in world space. In rigger
opinion this option is useless in production rigs, so this fix
should not be a problem.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5588
2019-09-04 10:10:27 +03:00
|
|
|
void orthogonalize_m3_stable(float R[3][3], int axis, bool normalize);
|
|
|
|
void orthogonalize_m4_stable(float R[4][4], int axis, bool normalize);
|
|
|
|
|
2021-04-01 21:16:09 +11:00
|
|
|
bool orthogonalize_m3_zero_axes(float R[3][3], const float unit_length);
|
|
|
|
bool orthogonalize_m4_zero_axes(float R[4][4], const float unit_length);
|
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
bool is_orthogonal_m3(const float mat[3][3]);
|
|
|
|
bool is_orthogonal_m4(const float mat[4][4]);
|
|
|
|
bool is_orthonormal_m3(const float mat[3][3]);
|
|
|
|
bool is_orthonormal_m4(const float mat[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
bool is_uniform_scaled_m3(const float mat[3][3]);
|
|
|
|
bool is_uniform_scaled_m4(const float m[4][4]);
|
2012-05-01 11:01:24 +00:00
|
|
|
|
2015-12-07 12:35:36 +01:00
|
|
|
/* Note: 'adjoint' here means the adjugate (adjunct, "classical adjoint") matrix!
|
|
|
|
* Nowadays 'adjoint' usually refers to the conjugate transpose,
|
|
|
|
* which for real-valued matrices is simply the transpose.
|
|
|
|
*/
|
2020-09-04 20:59:13 +02:00
|
|
|
void adjoint_m2_m2(float R[2][2], const float M[2][2]);
|
|
|
|
void adjoint_m3_m3(float R[3][3], const float M[3][3]);
|
|
|
|
void adjoint_m4_m4(float R[4][4], const float M[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
float determinant_m2(float a, float b, float c, float d);
|
|
|
|
float determinant_m3(
|
2020-09-04 20:59:13 +02:00
|
|
|
float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3);
|
2016-09-24 16:21:38 +02:00
|
|
|
float determinant_m3_array(const float m[3][3]);
|
2019-05-05 13:25:43 +03:00
|
|
|
float determinant_m4_mat3_array(const float m[4][4]);
|
2020-09-04 20:59:13 +02:00
|
|
|
float determinant_m4(const float m[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2012-12-14 21:41:22 +00:00
|
|
|
#define PSEUDOINVERSE_EPSILON 1e-8f
|
|
|
|
|
2010-06-22 15:20:06 +00:00
|
|
|
void svd_m4(float U[4][4], float s[4], float V[4][4], float A[4][4]);
|
2016-09-24 16:21:38 +02:00
|
|
|
void pseudoinverse_m4_m4(float Ainv[4][4], const float A[4][4], float epsilon);
|
|
|
|
void pseudoinverse_m3_m3(float Ainv[3][3], const float A[3][3], float epsilon);
|
2010-06-22 15:20:06 +00:00
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
bool has_zero_axis_m4(const float matrix[4][4]);
|
2013-10-18 23:38:51 +00:00
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
void invert_m4_m4_safe(float Ainv[4][4], const float A[4][4]);
|
2014-03-25 16:05:28 +06:00
|
|
|
|
2020-08-25 12:35:44 +10:00
|
|
|
void invert_m3_m3_safe_ortho(float Ainv[3][3], const float A[3][3]);
|
|
|
|
void invert_m4_m4_safe_ortho(float Ainv[4][4], const float A[4][4]);
|
|
|
|
|
2009-11-09 22:42:41 +00:00
|
|
|
/****************************** Transformations ******************************/
|
|
|
|
|
|
|
|
void scale_m3_fl(float R[3][3], float scale);
|
|
|
|
void scale_m4_fl(float R[4][4], float scale);
|
|
|
|
|
2019-05-05 13:25:43 +03:00
|
|
|
float mat3_to_volume_scale(const float M[3][3]);
|
|
|
|
float mat4_to_volume_scale(const float M[4][4]);
|
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
float mat3_to_scale(const float M[3][3]);
|
|
|
|
float mat4_to_scale(const float M[4][4]);
|
2017-04-26 11:55:50 +02:00
|
|
|
float mat4_to_xy_scale(const float M[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2010-10-22 03:56:50 +00:00
|
|
|
void size_to_mat3(float R[3][3], const float size[3]);
|
|
|
|
void size_to_mat4(float R[4][4], const float size[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
void mat3_to_size(float size[3], const float M[3][3]);
|
|
|
|
void mat4_to_size(float size[3], const float M[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
void mat4_to_size_fix_shear(float size[3], const float M[4][4]);
|
Armature: add Inherit Scale options to remove shear or average the scale.
As an inherent property of matrix-based transformation math, non-
uniform scaling of a parent bone induces shear into the transform
matrix of any rotated child. Such matrices cannot be cleanly
decomposed into a combination of location/rotation/scale, which
causes issues for rigging and animation tools.
Blender bones have options to exclude rotation and/or scale from the
inherited transformation, but don't have any support for removing the
often undesired shear component. That goal requires replacing simple
parenting with a combination of multiple bones and constraints. The
same is true about the goal of inheriting some scale, but completely
avoiding shear.
This patch replaces the old Inherit Scale checkbox with a enum that
supports multiple options:
* Full: inherit all effects of scale, like with enabled Inherit Scale.
* Fix Shear: removes shear from the final inherited transformation.
The cleanup math is specifically designed to preserve the main
axis of the bone, its length and total volume, and minimally
affect roll on average. It however will not prevent reappearance
of shear due to local rotation of the child or its children.
* Average: inherit uniform scale that represents the parent volume.
This is the simplest foolproof solution that will inherit some
scale without ever causing shear.
* None: completely remove scale and shear.
* None (Legacy): old disabled Inherit Scale checkbox.
This mode does not handle parent shear in any way, so the child
is likely to end up having both scale and shear. It is retained
for backward compatibility.
Since many rigging-related addons access the use_inherit_scale
property from Python, it is retained as a backward compatibility
stub that provides the old functionality.
As a side effect of reworking the code, this also fixes a matrix
multiplication order bug in the Inherit Rotation code, which caused
the parent local scale to be applied in world space. In rigger
opinion this option is useless in production rigs, so this fix
should not be a problem.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5588
2019-09-04 10:10:27 +03:00
|
|
|
|
2020-11-02 22:15:52 +01:00
|
|
|
void translate_m3(float mat[3][3], float tx, float ty);
|
2009-11-09 22:42:41 +00:00
|
|
|
void translate_m4(float mat[4][4], float tx, float ty, float tz);
|
2020-11-02 22:15:52 +01:00
|
|
|
void rotate_m3(float mat[3][3], const float angle);
|
2010-10-22 10:17:55 +00:00
|
|
|
void rotate_m4(float mat[4][4], const char axis, const float angle);
|
2020-11-02 22:15:52 +01:00
|
|
|
void rescale_m3(float mat[3][3], const float scale[2]);
|
2019-09-04 12:06:59 +03:00
|
|
|
void rescale_m4(float mat[4][4], const float scale[3]);
|
2020-11-02 22:15:52 +01:00
|
|
|
void transform_pivot_set_m3(float mat[3][3], const float pivot[2]);
|
2013-07-30 10:58:36 +00:00
|
|
|
void transform_pivot_set_m4(float mat[4][4], const float pivot[3]);
|
2010-11-22 10:39:28 +00:00
|
|
|
|
2021-03-08 12:45:06 -05:00
|
|
|
void mat4_to_rot(float rot[3][3], const float wmat[4][4]);
|
2016-09-24 16:21:38 +02:00
|
|
|
void mat3_to_rot_size(float rot[3][3], float size[3], const float mat3[3][3]);
|
|
|
|
void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], const float wmat[4][4]);
|
|
|
|
void mat4_to_loc_quat(float loc[3], float quat[4], const float wmat[4][4]);
|
|
|
|
void mat4_decompose(float loc[3], float quat[4], float size[3], const float wmat[4][4]);
|
2010-10-26 12:48:07 +00:00
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
void mat3_polar_decompose(const float mat3[3][3], float r_U[3][3], float r_P[3][3]);
|
2015-10-09 20:57:37 +02:00
|
|
|
|
2020-11-02 22:15:52 +01:00
|
|
|
void loc_rot_size_to_mat3(float R[3][3],
|
|
|
|
const float loc[2],
|
|
|
|
const float angle,
|
|
|
|
const float size[2]);
|
2019-09-04 12:06:59 +03:00
|
|
|
void loc_rot_size_to_mat4(float R[4][4],
|
|
|
|
const float loc[3],
|
|
|
|
const float rot[3][3],
|
|
|
|
const float size[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
void loc_eul_size_to_mat4(float R[4][4],
|
2012-05-12 20:39:39 +00:00
|
|
|
const float loc[3],
|
|
|
|
const float eul[3],
|
|
|
|
const float size[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
void loc_eulO_size_to_mat4(
|
2012-05-12 20:39:39 +00:00
|
|
|
float R[4][4], const float loc[3], const float eul[3], const float size[3], const short order);
|
2009-11-09 22:42:41 +00:00
|
|
|
void loc_quat_size_to_mat4(float R[4][4],
|
2012-05-12 20:39:39 +00:00
|
|
|
const float loc[3],
|
|
|
|
const float quat[4],
|
|
|
|
const float size[3]);
|
2010-10-22 03:56:50 +00:00
|
|
|
void loc_axisangle_size_to_mat4(float R[4][4],
|
2012-05-12 20:39:39 +00:00
|
|
|
const float loc[3],
|
|
|
|
const float axis[4],
|
|
|
|
const float angle,
|
|
|
|
const float size[3]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
void blend_m3_m3m3(float out[3][3],
|
|
|
|
const float dst[3][3],
|
|
|
|
const float src[3][3],
|
|
|
|
const float srcweight);
|
|
|
|
void blend_m4_m4m4(float out[4][4],
|
|
|
|
const float dst[4][4],
|
|
|
|
const float src[4][4],
|
|
|
|
const float srcweight);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
void interp_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3], const float t);
|
|
|
|
void interp_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4], const float t);
|
2015-10-09 20:57:37 +02:00
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
bool is_negative_m3(const float mat[3][3]);
|
|
|
|
bool is_negative_m4(const float mat[4][4]);
|
2013-07-26 11:15:22 +00:00
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
bool is_zero_m3(const float mat[3][3]);
|
|
|
|
bool is_zero_m4(const float mat[4][4]);
|
2010-01-30 13:15:39 +00:00
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
bool equals_m3m3(const float mat1[3][3], const float mat2[3][3]);
|
|
|
|
bool equals_m4m4(const float mat1[4][4], const float mat2[4][4]);
|
2016-05-12 12:07:31 +02:00
|
|
|
|
2014-08-01 16:28:31 +02:00
|
|
|
/* SpaceTransform helper */
|
|
|
|
typedef struct SpaceTransform {
|
|
|
|
float local2target[4][4];
|
|
|
|
float target2local[4][4];
|
|
|
|
|
|
|
|
} SpaceTransform;
|
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
void BLI_space_transform_from_matrices(struct SpaceTransform *data,
|
|
|
|
const float local[4][4],
|
|
|
|
const float target[4][4]);
|
|
|
|
void BLI_space_transform_global_from_matrices(struct SpaceTransform *data,
|
|
|
|
const float local[4][4],
|
|
|
|
const float target[4][4]);
|
2014-08-01 16:28:31 +02:00
|
|
|
void BLI_space_transform_apply(const struct SpaceTransform *data, float co[3]);
|
|
|
|
void BLI_space_transform_invert(const struct SpaceTransform *data, float co[3]);
|
|
|
|
void BLI_space_transform_apply_normal(const struct SpaceTransform *data, float no[3]);
|
|
|
|
void BLI_space_transform_invert_normal(const struct SpaceTransform *data, float no[3]);
|
|
|
|
|
|
|
|
#define BLI_SPACE_TRANSFORM_SETUP(data, local, target) \
|
|
|
|
BLI_space_transform_from_matrices((data), (local)->obmat, (target)->obmat)
|
|
|
|
|
2009-11-09 22:42:41 +00:00
|
|
|
/*********************************** Other ***********************************/
|
|
|
|
|
2016-09-24 16:21:38 +02:00
|
|
|
void print_m3(const char *str, const float M[3][3]);
|
|
|
|
void print_m4(const char *str, const float M[4][4]);
|
2009-11-09 22:42:41 +00:00
|
|
|
|
2014-03-30 13:03:30 +11:00
|
|
|
#define print_m3_id(M) print_m3(STRINGIFY(M), M)
|
|
|
|
#define print_m4_id(M) print_m4(STRINGIFY(M), M)
|
|
|
|
|
2009-11-09 22:42:41 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|