diff options
author | Mike Erwin <significant.bit@gmail.com> | 2016-09-25 15:27:48 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2016-09-25 15:27:48 +0300 |
commit | 5c6baf1ee9754e39392926cd077bb2097baf39b9 (patch) | |
tree | 06019e8c6e19fdf7a24d66c2c18aace9f1b95b35 /source/blender/blenlib/BLI_math_matrix.h | |
parent | addc666999255ae908cec63af18da2db4001e90b (diff) |
specialize mat4 multiply routines
mul_m4_m4m4(R, A, B) gives us R = AB in general. Existing code assumed the worst, that A and B both alias the output R. For safety it makes internal copies of A and B before calculating & writing R.
This is the least common case. Usually all 3 matrices differ. Often we see M = AM or M = MB, but never M = MM.
With this revision mul_m4_m4m4 is called in exactly the same way but copies inputs only when needed. If you know the inputs are independent of the output use the "uniq" variant to skip the saftety checks.
Diffstat (limited to 'source/blender/blenlib/BLI_math_matrix.h')
-rw-r--r-- | source/blender/blenlib/BLI_math_matrix.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 6388105032a..a5868e00c8e 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -72,6 +72,11 @@ 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]); void mul_m3_m3m4(float R[3][3], const float A[4][4], const float B[3][3]); +/* special matrix multiplies */ +void mul_m4_m4m4_uniq(float R[4][4], const float A[4][4], const float B[4][4]); /* R <-- AB, R is neither A nor B */ +void mul_m4_m4_pre(float R[4][4], const float A[4][4]); /* R <-- AR */ +void mul_m4_m4_post(float R[4][4], const float B[4][4]); /* R <-- RB */ + /* mul_m3_series */ void _va_mul_m3_series_3(float R[3][3], float M1[3][3], float M2[3][3]) ATTR_NONNULL(); void _va_mul_m3_series_4(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3]) ATTR_NONNULL(); |