diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-09-22 22:42:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-09-22 22:42:16 +0400 |
commit | 48918130a1566ce8aa4bf66d8b3bda35ec240acb (patch) | |
tree | 59a3315656f7d5e5bc68bfb0e12fee7c6a252c9f /source/blender | |
parent | bf7f88566cd6a23d2b180995210d20d433605555 (diff) |
remove redundant code & use GL_LINE_STRIP for object spiral drawing.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 57 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_header.c | 6 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadeinput.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 10 |
4 files changed, 46 insertions, 29 deletions
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 44d68ded679..65267bb481a 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -5112,6 +5112,7 @@ static void drawspiral(const float cent[3], float rad, float tmat[][4], int star const float tot_inv= (1.0f / (float)CIRCLE_RESOL); int a; char inverse= FALSE; + float x, y, fac; if (start < 0) { inverse = TRUE; @@ -5121,38 +5122,56 @@ static void drawspiral(const float cent[3], float rad, float tmat[][4], int star mul_v3_v3fl(vx, tmat[0], rad); mul_v3_v3fl(vy, tmat[1], rad); - copy_v3_v3(vec, cent); + glBegin(GL_LINE_STRIP); if (inverse==0) { + copy_v3_v3(vec, cent); + glVertex3fv(vec); + for(a=0; a<CIRCLE_RESOL; a++) { - if (a+start>31) + if (a+start>=CIRCLE_RESOL) start=-a + 1; - glBegin(GL_LINES); - glVertex3fv(vec); - vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)a * tot_inv) + cosval[a+start] * (vy[0] * (float)a * tot_inv); - vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)a * tot_inv) + cosval[a+start] * (vy[1] * (float)a * tot_inv); - vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)a * tot_inv) + cosval[a+start] * (vy[2] * (float)a * tot_inv); + + fac= (float)a * tot_inv; + x= sinval[a+start] * fac; + y= cosval[a+start] * fac; + + vec[0]= cent[0] + (x * vx[0] + y * vy[0]); + vec[1]= cent[1] + (x * vx[1] + y * vy[1]); + vec[2]= cent[2] + (x * vx[2] + y * vy[2]); + glVertex3fv(vec); - glEnd(); } } else { - a=0; - vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[0] * (float)(-a+31) * tot_inv); - vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[1] * (float)(-a+31) * tot_inv); - vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[2] * (float)(-a+31) * tot_inv); + a= 0; + + fac= (float)(CIRCLE_RESOL-1) * tot_inv; + x= sinval[start] * fac; + y= cosval[start] * fac; + + vec[0]= cent[0] + (x * vx[0] + y * vy[0]); + vec[1]= cent[1] + (x * vx[1] + y * vy[1]); + vec[2]= cent[2] + (x * vx[2] + y * vy[2]); + + glVertex3fv(vec); + for(a=0; a<CIRCLE_RESOL; a++) { - if (a+start>31) + if (a+start>=CIRCLE_RESOL) start=-a + 1; - glBegin(GL_LINES); - glVertex3fv(vec); - vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[0] * (float)(-a+31) * tot_inv); - vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[1] * (float)(-a+31) * tot_inv); - vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[2] * (float)(-a+31) * tot_inv); + + fac= (float)(-a+(CIRCLE_RESOL-1)) * tot_inv; + x= sinval[a+start] * fac; + y= cosval[a+start] * fac; + + vec[0]= cent[0] + (x * vx[0] + y * vy[0]); + vec[1]= cent[1] + (x * vx[1] + y * vy[1]); + vec[2]= cent[2] + (x * vx[2] + y * vy[2]); glVertex3fv(vec); - glEnd(); } } + + glEnd(); } /* draws a circle on x-z plane given the scaling of the circle, assuming that diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 0776ca752a9..44d85af858c 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -285,14 +285,14 @@ static char *view3d_modeselect_pup(Scene *scene) { Object *ob= OBACT; static char string[256]; - const char *title= N_("Mode: %%t"); + const char *title= N_("Mode: %t"); char *str = string; if(U.transopts&USER_TR_IFACE) title= BLF_gettext(title); - sprintf(str, title); - + BLI_strncpy(str, title, sizeof(string)); + str += modeselect_addmode(str, N_("Object Mode"), OB_MODE_OBJECT, ICON_OBJECT_DATA); if(ob==NULL || ob->data==NULL) return string; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index d8231c7e7d4..956a3d4de7c 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -1368,7 +1368,7 @@ void shade_samples_do_AO(ShadeSample *ssamp) if(((shi->passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) || (shi->passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) - for(sample=0, shi= ssamp->shi; sample<ssamp->tot; shi++, sample++) + for(sample=0; sample<ssamp->tot; shi++, sample++) if(!(shi->mode & MA_SHLESS)) ambient_occlusion(shi); /* stores in shi->ao[] */ } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index d9ca275c819..405960d0795 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -111,14 +111,12 @@ static void wm_window_check_position(rcti *rect) #endif if(rect->xmin < 0) { - d= rect->xmin; - rect->xmax -= d; - rect->xmin -= d; + rect->xmax -= rect->xmin; + rect->xmin = 0; } if(rect->ymin < 0) { - d= rect->ymin; - rect->ymax -= d; - rect->ymin -= d; + rect->ymax -= rect->ymin; + rect->ymin = 0; } if(rect->xmax > width) { d= rect->xmax - width; |