Revision: 49580
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49580
Author:   campbellbarton
Date:     2012-08-05 17:27:52 +0000 (Sun, 05 Aug 2012)
Log Message:
-----------
use define for 0.375 = GLA_PIXEL_OFS, used all over the interface.
also use M_SQRT1_2 in math_rotation.c

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/math_rotation.c
    trunk/blender/source/blender/editors/animation/anim_draw.c
    trunk/blender/source/blender/editors/include/BIF_gl.h
    trunk/blender/source/blender/editors/include/BIF_glutil.h
    trunk/blender/source/blender/editors/interface/view2d.c
    trunk/blender/source/blender/editors/screen/area.c
    trunk/blender/source/blender/editors/screen/glutil.c
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/editors/space_text/text_draw.c
    trunk/blender/source/blender/windowmanager/intern/wm_draw.c
    trunk/blender/source/blender/windowmanager/intern/wm_subwindow.c

Modified: trunk/blender/source/blender/blenlib/intern/math_rotation.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_rotation.c 2012-08-05 
17:24:10 UTC (rev 49579)
+++ trunk/blender/source/blender/blenlib/intern/math_rotation.c 2012-08-05 
17:27:52 UTC (rev 49580)
@@ -1660,12 +1660,12 @@
 {
        /* 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 @@
         * 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);
        }
 }

Modified: trunk/blender/source/blender/editors/animation/anim_draw.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_draw.c  2012-08-05 
17:24:10 UTC (rev 49579)
+++ trunk/blender/source/blender/editors/animation/anim_draw.c  2012-08-05 
17:27:52 UTC (rev 49580)
@@ -100,7 +100,7 @@
                }
                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 @@
                                /* 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 @@
        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));
        }
 } 
 

Modified: trunk/blender/source/blender/editors/include/BIF_gl.h
===================================================================
--- trunk/blender/source/blender/editors/include/BIF_gl.h       2012-08-05 
17:24:10 UTC (rev 49579)
+++ trunk/blender/source/blender/editors/include/BIF_gl.h       2012-08-05 
17:27:52 UTC (rev 49580)
@@ -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__ */
 

Modified: trunk/blender/source/blender/editors/include/BIF_glutil.h
===================================================================
--- trunk/blender/source/blender/editors/include/BIF_glutil.h   2012-08-05 
17:24:10 UTC (rev 49579)
+++ trunk/blender/source/blender/editors/include/BIF_glutil.h   2012-08-05 
17:27:52 UTC (rev 49580)
@@ -116,8 +116,8 @@
  *
  * \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

Modified: trunk/blender/source/blender/editors/interface/view2d.c
===================================================================
--- trunk/blender/source/blender/editors/interface/view2d.c     2012-08-05 
17:24:10 UTC (rev 49579)
+++ trunk/blender/source/blender/editors/interface/view2d.c     2012-08-05 
17:27:52 UTC (rev 49580)
@@ -980,7 +980,7 @@
        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 @@
        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);

Modified: trunk/blender/source/blender/editors/screen/area.c
===================================================================
--- trunk/blender/source/blender/editors/screen/area.c  2012-08-05 17:24:10 UTC 
(rev 49579)
+++ trunk/blender/source/blender/editors/screen/area.c  2012-08-05 17:27:52 UTC 
(rev 49580)
@@ -107,7 +107,7 @@
        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();
 }
 

Modified: trunk/blender/source/blender/editors/screen/glutil.c
===================================================================
--- trunk/blender/source/blender/editors/screen/glutil.c        2012-08-05 
17:24:10 UTC (rev 49579)
+++ trunk/blender/source/blender/editors/screen/glutil.c        2012-08-05 
17:27:52 UTC (rev 49580)
@@ -674,7 +674,7 @@
        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 @@
        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();

Modified: trunk/blender/source/blender/editors/space_node/drawnode.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/drawnode.c  2012-08-05 
17:24:10 UTC (rev 49579)
+++ trunk/blender/source/blender/editors/space_node/drawnode.c  2012-08-05 
17:27:52 UTC (rev 49580)
@@ -3025,7 +3025,7 @@
                        
                        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;

Modified: trunk/blender/source/blender/editors/space_text/text_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_draw.c 2012-08-05 
17:24:10 UTC (rev 49579)
+++ trunk/blender/source/blender/editors/space_text/text_draw.c 2012-08-05 
17:27:52 UTC (rev 49580)
@@ -50,7 +50,6 @@
 #include "BKE_suggestions.h"
 #include "BKE_text.h"
 
-
 #include "BIF_gl.h"
 
 #include "ED_datafiles.h"
@@ -1854,7 +1853,7 @@
        /* 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);

Modified: trunk/blender/source/blender/windowmanager/intern/wm_draw.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_draw.c 2012-08-05 
17:24:10 UTC (rev 49579)
+++ trunk/blender/source/blender/windowmanager/intern/wm_draw.c 2012-08-05 
17:27:52 UTC (rev 49580)
@@ -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 @@
                        /* 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) {

Modified: trunk/blender/source/blender/windowmanager/intern/wm_subwindow.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_subwindow.c    
2012-08-05 17:24:10 UTC (rev 49579)
+++ trunk/blender/source/blender/windowmanager/intern/wm_subwindow.c    
2012-08-05 17:27:52 UTC (rev 49580)
@@ -141,7 +141,7 @@
                        int width, height;
 

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to