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:
authorCampbell Barton <ideasman42@gmail.com>2012-08-05 21:27:52 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-05 21:27:52 +0400
commit887d517e3b745945d3c8f7e2dc6e1d791067d1e8 (patch)
treed4c962031f7efb788d7b63705f155f92f4867219 /source/blender
parentdfdfa06c27c6dc44cb3f05e0355279d9e16eab93 (diff)
use define for 0.375 = GLA_PIXEL_OFS, used all over the interface.
also use M_SQRT1_2 in math_rotation.c
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenlib/intern/math_rotation.c12
-rw-r--r--source/blender/editors/animation/anim_draw.c6
-rw-r--r--source/blender/editors/include/BIF_gl.h2
-rw-r--r--source/blender/editors/include/BIF_glutil.h4
-rw-r--r--source/blender/editors/interface/view2d.c8
-rw-r--r--source/blender/editors/screen/area.c2
-rw-r--r--source/blender/editors/screen/glutil.c4
-rw-r--r--source/blender/editors/space_node/drawnode.c2
-rw-r--r--source/blender/editors/space_text/text_draw.c3
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c7
-rw-r--r--source/blender/windowmanager/intern/wm_subwindow.c8
11 files changed, 30 insertions, 28 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index a2da9f5f791..69f837c7652 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1660,12 +1660,12 @@ void quat_apply_track(float quat[4], short axis, short upflag)
{
/* rotations are hard coded to match vec_to_quat */
const float quat_track[][4] = {
- {0.70710676908493, 0.0, -0.70710676908493, 0.0}, /* pos-y90 */
+ {M_SQRT1_2, 0.0, -M_SQRT1_2, 0.0}, /* pos-y90 */
{0.5, 0.5, 0.5, 0.5}, /* Quaternion((1,0,0), radians(90)) * Quaternion((0,1,0), radians(90)) */
- {0.70710676908493, 0.0, 0.0, 0.70710676908493}, /* pos-z90 */
- {0.70710676908493, 0.0, 0.70710676908493, 0.0}, /* neg-y90 */
+ {M_SQRT1_2, 0.0, 0.0, M_SQRT1_2}, /* pos-z90 */
+ {M_SQRT1_2, 0.0, M_SQRT1_2, 0.0}, /* neg-y90 */
{0.5, -0.5, -0.5, 0.5}, /* Quaternion((1,0,0), radians(-90)) * Quaternion((0,1,0), radians(-90)) */
- {-3.0908619663705394e-08, 0.70710676908493, 0.70710676908493, 3.0908619663705394e-08} /* no rotation */
+ {-3.0908619663705394e-08, M_SQRT1_2, M_SQRT1_2, 3.0908619663705394e-08} /* no rotation */
};
assert(axis >= 0 && axis <= 5);
@@ -1680,8 +1680,8 @@ void quat_apply_track(float quat[4], short axis, short upflag)
* up axis is used X->Y, Y->X, Z->X, if this first up axis isn used then rotate 90d
* the strange bit shift below just find the low axis {X:Y, Y:X, Z:X} */
if (upflag != (2 - axis) >> 1) {
- float q[4] = {0.70710676908493, 0.0, 0.0, 0.0}; /* assign 90d rotation axis */
- q[axis + 1] = ((axis == 1)) ? 0.70710676908493 : -0.70710676908493; /* flip non Y axis */
+ float q[4] = {M_SQRT1_2, 0.0, 0.0, 0.0}; /* assign 90d rotation axis */
+ q[axis + 1] = ((axis == 1)) ? M_SQRT1_2 : -M_SQRT1_2; /* flip non Y axis */
mul_qt_qtqt(quat, quat, q);
}
}
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 0d48bf19c9e..9c9d7f8e34a 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -100,7 +100,7 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t
}
else {
/* seconds (with pixel offset rounding) */
- seconds = (int)floor(cfra + 0.375f);
+ seconds = (int)floor(cfra + GLA_PIXEL_OFS);
}
switch (U.timecode_style) {
@@ -150,7 +150,7 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t
/* only show the original seconds display */
/* round to whole numbers if power is >= 1 (i.e. scale is coarse) */
if (power <= 0) sprintf(str, "%.*f", 1 - power, raw_seconds);
- else sprintf(str, "%d", (int)floor(raw_seconds + 0.375f));
+ else sprintf(str, "%d", (int)floor(raw_seconds + GLA_PIXEL_OFS));
}
break;
@@ -166,7 +166,7 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t
else {
/* round to whole numbers if power is >= 1 (i.e. scale is coarse) */
if (power <= 0) sprintf(str, "%.*f", 1 - power, cfra);
- else sprintf(str, "%d", (int)floor(cfra + 0.375f));
+ else sprintf(str, "%d", (int)floor(cfra + GLA_PIXEL_OFS));
}
}
diff --git a/source/blender/editors/include/BIF_gl.h b/source/blender/editors/include/BIF_gl.h
index a5e5d7ce2e0..479e0b65177 100644
--- a/source/blender/editors/include/BIF_gl.h
+++ b/source/blender/editors/include/BIF_gl.h
@@ -50,5 +50,7 @@
#define glMultMatrixf(x) glMultMatrixf( (float *)(x))
#define glLoadMatrixf(x) glLoadMatrixf( (float *)(x))
+#define GLA_PIXEL_OFS 0.375f
+
#endif /* #ifdef __BIF_GL_H__ */
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index b939ae47ead..577113927d1 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -116,8 +116,8 @@ void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y
*
* \attention This routine makes many assumptions: the rect data
* is expected to be in RGBA unsigned byte format, the coordinate
- * (0.375, 0.375) is assumed to be within the view frustum, and the
- * modelview and projection matrices are assumed to define a
+ * (GLA_PIXEL_OFS, GLA_PIXEL_OFS) is assumed to be within the view frustum,
+ * and the modelview and projection matrices are assumed to define a
* 1-to-1 mapping to screen space.
* \attention Furthermore, in the case of zoomed or unpixel aligned
* images extending outside the view frustum, but still within the
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index a693e9eb627..8ae08c08693 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -980,7 +980,7 @@ void UI_view2d_view_ortho(View2D *v2d)
rctf curmasked;
float xofs, yofs;
- /* pixel offsets (-0.375f) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
+ /* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
* but only applied where requested
*/
/* XXX brecht: instead of zero at least use a tiny offset, otherwise
@@ -1019,12 +1019,12 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, short xaxis)
rctf curmasked;
float xofs, yofs;
- /* pixel offsets (-0.375f) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
+ /* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
* but only applied where requested
*/
/* XXX temp (ton) */
- xofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? 0.375f : 0.0f;
- yofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_Y) ? 0.375f : 0.0f;
+ xofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? GLA_PIXEL_OFS : 0.0f;
+ yofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_Y) ? GLA_PIXEL_OFS : 0.0f;
/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
view2d_map_cur_using_mask(v2d, &curmasked);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 47a086a2779..b4f1f4b3022 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -107,7 +107,7 @@ void ED_region_pixelspace(ARegion *ar)
int width = ar->winrct.xmax - ar->winrct.xmin + 1;
int height = ar->winrct.ymax - ar->winrct.ymin + 1;
- wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f);
+ wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
glLoadIdentity();
}
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 5296c8615ab..a534124d2c0 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -674,7 +674,7 @@ void glaDefine2DArea(rcti *screen_rect)
glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
- /* The 0.375 magic number is to shift the matrix so that
+ /* The GLA_PIXEL_OFS magic number is to shift the matrix so that
* both raster and vertex integer coordinates fall at pixel
* centers properly. For a longer discussion see the OpenGL
* Programming Guide, Appendix H, Correctness Tips.
@@ -683,7 +683,7 @@ void glaDefine2DArea(rcti *screen_rect)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, sc_w, 0.0, sc_h, -1, 1);
- glTranslatef(0.375, 0.375, 0.0);
+ glTranslatef(GLA_PIXEL_OFS, GLA_PIXEL_OFS, 0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 7ddee03b08a..9f6d6d0170f 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3025,7 +3025,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
glaDefine2DArea(&ar->winrct);
/* ortho at pixel level curarea */
- wmOrtho2(-0.375, ar->winx - 0.375, -0.375, ar->winy - 0.375);
+ wmOrtho2(-GLA_PIXEL_OFS, ar->winx - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, ar->winy - GLA_PIXEL_OFS);
x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 8be5b644afb..6240d174575 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -50,7 +50,6 @@
#include "BKE_suggestions.h"
#include "BKE_text.h"
-
#include "BIF_gl.h"
#include "ED_datafiles.h"
@@ -1854,7 +1853,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
/* draw other stuff */
draw_brackets(st, ar);
draw_markers(st, ar);
- glTranslatef(0.375f, 0.375f, 0.0f); /* XXX scroll requires exact pixel space */
+ glTranslatef(GLA_PIXEL_OFS, GLA_PIXEL_OFS, 0.0f); /* XXX scroll requires exact pixel space */
draw_textscroll(st, &scroll, &back);
draw_documentation(st, ar);
draw_suggestion_list(st, ar);
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 8652870e280..66bb321e832 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -45,10 +45,11 @@
#include "BLI_utildefines.h"
#include "BLI_math_base.h"
+#include "BIF_gl.h"
+
#include "BKE_context.h"
#include "BKE_global.h"
-
#include "GHOST_C-api.h"
#include "ED_screen.h"
@@ -505,8 +506,8 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple)
/* wmOrtho for the screen has this same offset */
ratiox = sizex;
ratioy = sizey;
- halfx = 0.375f;
- halfy = 0.375f;
+ halfx = GLA_PIXEL_OFS;
+ halfy = GLA_PIXEL_OFS;
/* texture rectangle has unnormalized coordinates */
if (triple->target == GL_TEXTURE_2D) {
diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c
index 0b9dc441227..529910d220e 100644
--- a/source/blender/windowmanager/intern/wm_subwindow.c
+++ b/source/blender/windowmanager/intern/wm_subwindow.c
@@ -141,7 +141,7 @@ void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4])
int width, height;
wm_subwindow_getsize(win, swin->swinid, &width, &height);
- orthographic_m4(mat, -0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f, -100, 100);
+ orthographic_m4(mat, -GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS, -100, 100);
}
else
glGetFloatv(GL_PROJECTION_MATRIX, (float *)mat);
@@ -175,7 +175,7 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct)
/* extra service */
wm_subwindow_getsize(win, swin->swinid, &width, &height);
- wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f);
+ wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
glLoadIdentity();
return swin->swinid;
@@ -229,7 +229,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct)
/* extra service */
wmSubWindowSet(win, swinid);
wm_subwindow_getsize(win, swinid, &width, &height);
- wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f);
+ wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
}
else {
printf("%s: Internal error, bad winid: %d\n", __func__, swinid);
@@ -268,7 +268,7 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct)
else
glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
- wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f);
+ wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
glLoadIdentity();
glFlush();