Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-01-17 17:41:27 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-01-18 14:29:53 +0300
commitcb5302f962185b827e8c8b40f7a10dceebe310f9 (patch)
treebc9d4428e37bb9711f29e2a499d7a44bd8b7871f /source/blender/blenlib/intern/math_matrix.c
parent91697b0fa0bbe494cbaf8cc501a90a435d24d41d (diff)
Math: Make it possible to use vector for both input and output
Avoids nasty code all over where such math is required, and compilers can easily deal with such situation. Don't prefer questionable micro-optimization which comes with a cost of nasty actual logic code.
Diffstat (limited to 'source/blender/blenlib/intern/math_matrix.c')
-rw-r--r--source/blender/blenlib/intern/math_matrix.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 15858e8797e..518161db565 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -656,28 +656,31 @@ void mul_v4_m4v3(float r[4], const float M[4][4], const float v[3])
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
{
- BLI_assert(r != a);
+ float t[3];
+ copy_v3_v3(t, a);
- r[0] = M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
- r[1] = M[0][1] * a[0] + M[1][1] * a[1] + M[2][1] * a[2];
- r[2] = M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2];
+ r[0] = M[0][0] * t[0] + M[1][0] * t[1] + M[2][0] * t[2];
+ r[1] = M[0][1] * t[0] + M[1][1] * t[1] + M[2][1] * t[2];
+ r[2] = M[0][2] * t[0] + M[1][2] * t[1] + M[2][2] * t[2];
}
void mul_v3_m3v3_db(double r[3], const double M[3][3], const double a[3])
{
- BLI_assert(r != a);
+ double t[3];
+ copy_v3_v3_db(t, a);
- r[0] = M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
- r[1] = M[0][1] * a[0] + M[1][1] * a[1] + M[2][1] * a[2];
- r[2] = M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2];
+ r[0] = M[0][0] * t[0] + M[1][0] * t[1] + M[2][0] * t[2];
+ r[1] = M[0][1] * t[0] + M[1][1] * t[1] + M[2][1] * t[2];
+ r[2] = M[0][2] * t[0] + M[1][2] * t[1] + M[2][2] * t[2];
}
void mul_v2_m3v3(float r[2], const float M[3][3], const float a[3])
{
- BLI_assert(r != a);
+ float t[3];
+ copy_v3_v3(t, a);
- r[0] = M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
- r[1] = M[0][1] * a[0] + M[1][1] * a[1] + M[2][1] * a[2];
+ r[0] = M[0][0] * t[0] + M[1][0] * t[1] + M[2][0] * t[2];
+ r[1] = M[0][1] * t[0] + M[1][1] * t[1] + M[2][1] * t[2];
}
void mul_m3_v3(const float M[3][3], float r[3])