diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-03-08 15:57:51 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-03-08 15:57:51 +0400 |
commit | c6d80d1db12b0ae4e80c5332b31149414733c0e3 (patch) | |
tree | c11a5a50ca80bdd16e1be93e10d6bad33d30684f /source/blender/blenlib/intern/math_matrix.c | |
parent | fc170e6a4ed0bbea917ef1f9886a2b461811d50a (diff) |
Fix ##30455: Orthographic grid alignment jumps/shifts when zooming
Issue was caused by precision errors with floats.
Made internal grid drawing stuff using doubles and also added some
functions to multiply double vector by float matrix which also makes
all intermediate calculation in doubles.
Diffstat (limited to 'source/blender/blenlib/intern/math_matrix.c')
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 69e4102b497..b777b394005 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -373,6 +373,25 @@ void mul_m4_v4(float mat[4][4], float r[4]) mul_v4_m4v4(r, mat, r); } +void mul_v4d_m4v4d(double r[4], float mat[4][4], double v[4]) +{ + double x, y, z; + + x= v[0]; + y= v[1]; + z= v[2]; + + r[0]= x*(double)mat[0][0] + y*(double)mat[1][0] + z*(double)mat[2][0] + (double)mat[3][0]*v[3]; + r[1]= x*(double)mat[0][1] + y*(double)mat[1][1] + z*(double)mat[2][1] + (double)mat[3][1]*v[3]; + r[2]= x*(double)mat[0][2] + y*(double)mat[1][2] + z*(double)mat[2][2] + (double)mat[3][2]*v[3]; + r[3]= x*(double)mat[0][3] + y*(double)mat[1][3] + z*(double)mat[2][3] + (double)mat[3][3]*v[3]; +} + +void mul_m4_v4d(float mat[4][4], double r[4]) +{ + mul_v4d_m4v4d(r, mat, r); +} + void mul_v3_m3v3(float r[3], float M[3][3], float a[3]) { r[0]= M[0][0]*a[0] + M[1][0]*a[1] + M[2][0]*a[2]; |