Page MenuHome

view_icon.patch

File Metadata

Author
Davide Vercelli (unclezeiv)
Created
Nov 13 2013, 1:07 PM

view_icon.patch

diff -u -r1.184 drawview.c
--- drawview.c 15 Jan 2006 13:30:56 -0000 1.184
+++ drawview.c 23 Jan 2006 16:06:39 -0000
@@ -1108,27 +1108,75 @@
else sprintf(info, "(%d) %s", CFRA, ob->id.name+2);
BIF_ThemeColor(TH_TEXT_HI);
- glRasterPos2i(30, 10);
+ glRasterPos2i(40, 10);
BMF_DrawString(G.fonts, info);
}
-static void draw_view_icon(void)
+/* Draw a live substitute of the view icon, which is always shown */
+static void draw_view_axis()
{
- BIFIconID icon;
-
- if(G.vd->view==7) icon= ICON_AXIS_TOP;
- else if(G.vd->view==1) icon= ICON_AXIS_FRONT;
- else if(G.vd->view==3) icon= ICON_AXIS_SIDE;
- else return ;
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- BIF_draw_icon(5.0, 5.0, icon);
-
- glBlendFunc(GL_ONE, GL_ZERO);
- glDisable(GL_BLEND);
+ const float k = 8.5; // axis size
+ const float tag = 1.5; // placement of axis tag along axis
+ const float toll = 0.5; // used to see when view is quasi-orthogonal
+ const float start = 16.0f; // axis center in screen coordinates, x=y
+
+ unsigned char col[3];
+ float vec[4];
+ float dx, dy;
+ int i;
+
+ /* X */
+ vec[0] = vec[3] = 1;
+ vec[1] = vec[2] = 0;
+ QuatMulVecf(G.vd->viewquat, vec);
+
+ // Not using make_axis_color but the original icon's fixed colors
+ col[0] = 99;
+ col[1] = col[2] = 20;
+ glColor3ubv(col);
+
+ dx = vec[0] * k;
+ dy = vec[1] * k;
+ fdrawline(start, start, start + dx, start + dy);
+ if (fabs(dx) > toll || fabs(dy) > toll) {
+ glRasterPos2i(start + dx * tag - 2, start + dy * tag - 2);
+ BMF_DrawString(G.fonts, "x");
+ }
+
+ /* Y */
+ vec[1] = vec[3] = 1;
+ vec[0] = vec[2] = 0;
+ QuatMulVecf(G.vd->viewquat, vec);
+
+ col[1] = 99;
+ col[0] = col[2] = 20;
+ glColor3ubv(col);
+
+ dx = vec[0] * k;
+ dy = vec[1] * k;
+ fdrawline(start, start, start + dx, start + dy);
+ if (fabs(dx) > toll || fabs(dy) > toll) {
+ glRasterPos2i(start + dx * tag - 2, start + dy * tag - 2);
+ BMF_DrawString(G.fonts, "y");
+ }
+
+ /* Z */
+ vec[2] = vec[3] = 1;
+ vec[1] = vec[0] = 0;
+ QuatMulVecf(G.vd->viewquat, vec);
+
+ col[2] = 99;
+ col[0] = col[1] = 20;
+ glColor3ubv(col);
+
+ dx = vec[0] * k;
+ dy = vec[1] * k;
+ fdrawline(start, start, start + dx, start + dy);
+ if (fabs(dx) > toll || fabs(dy) > toll) {
+ glRasterPos2i(start + dx * tag - 2, start + dy * tag - 2);
+ BMF_DrawString(G.fonts, "z");
+ }
}
/* ******************* view3d space & buttons ************** */
@@ -2299,7 +2347,7 @@
if(v3d->persp>1) drawviewborder();
if(!(G.f & G_PLAYANIM)) drawcursor(v3d);
- draw_view_icon();
+ draw_view_axis();
ob= OBACT;
if(ob && (U.uiflag & USER_DRAWVIEWINFO))

Event Timeline