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:
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h5
-rw-r--r--source/blender/blenlib/intern/math_matrix.c19
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c33
3 files changed, 39 insertions, 18 deletions
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 328b5614f52..de4bd203eb6 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -103,6 +103,11 @@ int invert_m3_m3(float R[3][3], float A[3][3]);
int invert_m4(float R[4][4]);
int invert_m4_m4(float R[4][4], float A[4][4]);
+/* double ariphmetics */
+void mul_m4_v4d(float M[4][4], double r[4]);
+void mul_v4d_m4v4d(double r[4], float M[4][4], double v[4]);
+
+
/****************************** Linear Algebra *******************************/
void transpose_m3(float R[3][3]);
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];
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 3a3d5a6683f..a9533b57d8f 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -225,21 +225,21 @@ int ED_view3d_clipping_test(RegionView3D *rv3d, const float vec[3], const int is
/* ********* end custom clipping *********** */
-static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, float dx)
+static void drawgrid_draw(ARegion *ar, double wx, double wy, double x, double y, double dx)
{
- float verts[2][2];
+ double verts[2][2];
x+= (wx);
y+= (wy);
/* set fixed 'Y' */
verts[0][1]= 0.0f;
- verts[1][1]= (float)ar->winy;
+ verts[1][1]= (double)ar->winy;
/* iter over 'X' */
- verts[0][0] = verts[1][0] = x-dx*floorf(x/dx);
+ verts[0][0] = verts[1][0] = x-dx*floor(x/dx);
glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, verts);
+ glVertexPointer(2, GL_DOUBLE, 0, verts);
while (verts[0][0] < ar->winx) {
glDrawArrays(GL_LINES, 0, 2);
@@ -248,10 +248,10 @@ static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, flo
/* set fixed 'X' */
verts[0][0]= 0.0f;
- verts[1][0]= (float)ar->winx;
+ verts[1][0]= (double)ar->winx;
/* iter over 'Y' */
- verts[0][1]= verts[1][1]= y-dx*floorf(y/dx);
+ verts[0][1]= verts[1][1]= y-dx*floor(y/dx);
while (verts[0][1] < ar->winy) {
glDrawArrays(GL_LINES, 0, 2);
verts[0][1] = verts[1][1] = verts[0][1] + dx;
@@ -266,16 +266,13 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
{
/* extern short bgpicmode; */
RegionView3D *rv3d= ar->regiondata;
- float wx, wy, x, y, fw, fx, fy, dx;
- float vec4[4];
+ double wx, wy, x, y, fw, fx, fy, dx;
+ double vec4[4];
unsigned char col[3], col2[3];
- vec4[0]=vec4[1]=vec4[2]=0.0;
- vec4[3]= 1.0;
- mul_m4_v4(rv3d->persmat, vec4);
- fx= vec4[0];
- fy= vec4[1];
- fw= vec4[3];
+ fx= rv3d->persmat[3][0];
+ fy= rv3d->persmat[3][1];
+ fw= rv3d->persmat[3][3];
wx= (ar->winx/2.0); /* because of rounding errors, grid at wrong location */
wy= (ar->winy/2.0);
@@ -287,7 +284,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
vec4[2]= 0.0;
vec4[3]= 1.0;
- mul_m4_v4(rv3d->persmat, vec4);
+ mul_m4_v4d(rv3d->persmat, vec4);
fx= vec4[0];
fy= vec4[1];
fw= vec4[3];
@@ -305,7 +302,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
* items are less useful when dealing with units */
void *usys;
int len, i;
- float dx_scalar;
+ double dx_scalar;
float blend_fac;
bUnit_GetSystem(&usys, &len, unit->system, B_UNIT_LENGTH);
@@ -313,7 +310,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
if (usys) {
i= len;
while (i--) {
- float scalar= bUnit_GetScaler(usys, i);
+ double scalar= bUnit_GetScaler(usys, i);
dx_scalar = dx * scalar / unit->scale_length;
if (dx_scalar < (GRID_MIN_PX*2))