From 8d7c3f8a7e6de7625b3631cd91242fbefa98cf3a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 14:52:16 +0000 Subject: interface: floats were being implicitly promoted to doubles, adjust to use floats (in most cases) otherwise cast to double. --- source/blender/blenlib/BLI_math_rotation.h | 4 + source/blender/blenlib/BLI_utildefines.h | 1 + source/blender/editors/include/ED_sequencer.h | 2 +- source/blender/editors/interface/interface.c | 98 +++++++++++----------- source/blender/editors/interface/interface_draw.c | 80 +++++++++--------- .../blender/editors/interface/interface_handlers.c | 84 +++++++++---------- source/blender/editors/interface/interface_panel.c | 10 +-- .../blender/editors/interface/interface_regions.c | 8 +- .../editors/interface/interface_templates.c | 2 +- .../blender/editors/interface/interface_widgets.c | 44 +++++----- source/blender/editors/interface/resources.c | 67 ++++++++------- source/blender/editors/interface/view2d.c | 12 +-- source/blender/editors/interface/view2d_ops.c | 12 +-- source/blender/makesdna/DNA_scene_types.h | 6 +- 14 files changed, 217 insertions(+), 213 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index 11849e0be6d..0385ad5846f 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -39,6 +39,10 @@ extern "C" { #define RAD2DEG(_rad) ((_rad)*(180.0/M_PI)) #define DEG2RAD(_deg) ((_deg)*(M_PI/180.0)) + +#define RAD2DEGF(_rad) ((_rad)*(float)(180.0/M_PI)) +#define DEG2RADF(_deg) ((_deg)*(float)(M_PI/180.0)) + /******************************** Quaternions ********************************/ /* stored in (w, x, y, z) order */ diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 55f227f0284..bee5c031fc9 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -125,6 +125,7 @@ #define CLAMPTEST(a, b, c) if((b)<(c)) {CLAMP(a, b, c);} else {CLAMP(a, c, b);} #define IS_EQ(a,b) ((fabs((double)(a)-(b)) >= (double) FLT_EPSILON) ? 0 : 1) +#define IS_EQF(a,b) ((fabsf((float)(a)-(b)) >= (float) FLT_EPSILON) ? 0 : 1) #define IS_EQT(a, b, c) ((a > b)? (((a-b) <= c)? 1:0) : ((((b-a) <= c)? 1:0))) #define IN_RANGE(a, b, c) ((b < c)? ((b 0)? (szoom) : (szoom == 0)? (1.0) : (-1.0/szoom) +#define SEQ_ZOOM_FAC(szoom) ((szoom) > 0.0f)? (szoom) : ((szoom) == 0.0f)? (1.0f) : (-1.0f/(szoom)) /* in space_sequencer.c, for rna update function */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index b4b96f46173..93537928c92 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -120,8 +120,8 @@ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y gy += block->panel->ofsy; } - *x= ((float)sx) + ((float)getsizex)*(0.5+ 0.5*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0])); - *y= ((float)sy) + ((float)getsizey)*(0.5+ 0.5*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1])); + *x= ((float)sx) + ((float)getsizex)*(0.5f+ 0.5f*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0])); + *y= ((float)sy) + ((float)getsizey)*(0.5f+ 0.5f*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1])); } void ui_block_to_window(const ARegion *ar, uiBlock *block, int *x, int *y) @@ -161,13 +161,13 @@ void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y sx= ar->winrct.xmin; sy= ar->winrct.ymin; - a= .5*((float)getsizex)*block->winmat[0][0]; - b= .5*((float)getsizex)*block->winmat[1][0]; - c= .5*((float)getsizex)*(1.0+block->winmat[3][0]); + a= 0.5f*((float)getsizex)*block->winmat[0][0]; + b= 0.5f*((float)getsizex)*block->winmat[1][0]; + c= 0.5f*((float)getsizex)*(1.0f+block->winmat[3][0]); - d= .5*((float)getsizey)*block->winmat[0][1]; - e= .5*((float)getsizey)*block->winmat[1][1]; - f= .5*((float)getsizey)*(1.0+block->winmat[3][1]); + d= 0.5f*((float)getsizey)*block->winmat[0][1]; + e= 0.5f*((float)getsizey)*block->winmat[1][1]; + f= 0.5f*((float)getsizey)*(1.0f+block->winmat[3][1]); px= *x - sx; py= *y - sy; @@ -455,10 +455,10 @@ static void ui_draw_linkline(uiLinkLine *line) if(line->from==NULL || line->to==NULL) return; - rect.xmin= (line->from->x1+line->from->x2)/2.0; - rect.ymin= (line->from->y1+line->from->y2)/2.0; - rect.xmax= (line->to->x1+line->to->x2)/2.0; - rect.ymax= (line->to->y1+line->to->y2)/2.0; + rect.xmin= (line->from->x1+line->from->x2)/2.0f; + rect.ymin= (line->from->y1+line->from->y2)/2.0f; + rect.xmax= (line->to->x1+line->to->x2)/2.0f; + rect.ymax= (line->to->y1+line->to->y2)/2.0f; if(line->flag & UI_SELECT) glColor3ub(100,100,100); @@ -800,7 +800,7 @@ void uiEndBlock(const bContext *C, uiBlock *block) else if(block->dobounds == UI_BLOCK_BOUNDS_POPUP_CENTER) ui_centered_bounds_block(C, block); else if(block->dobounds) ui_popup_bounds_block(C, block, block->dobounds); - if(block->minx==0.0 && block->maxx==0.0) uiBoundsBlock(block, 0); + if(block->minx==0.0f && block->maxx==0.0f) uiBoundsBlock(block, 0); if(block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block); block->endblock= 1; @@ -817,10 +817,10 @@ void ui_fontscale(short *points, float aspect) aspect= sqrt(aspect); pointsf /= aspect; - if(aspect > 1.0) - *points= ceil(pointsf); + if(aspect > 1.0f) + *points= ceilf(pointsf); else - *points= floor(pointsf); + *points= floorf(pointsf); } } @@ -836,14 +836,14 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u gx= (but?but->x1:block->minx) + (block->panel?block->panel->ofsx:0.0f); gy= (but?but->y1:block->miny) + (block->panel?block->panel->ofsy:0.0f); - rect->xmin= floor(getsizex*(0.5+ 0.5*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0]))); - rect->ymin= floor(getsizey*(0.5+ 0.5*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1]))); + rect->xmin= floorf(getsizex*(0.5f+ 0.5f*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0]))); + rect->ymin= floorf(getsizey*(0.5f+ 0.5f*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1]))); gx= (but?but->x2:block->maxx) + (block->panel?block->panel->ofsx:0.0f); gy= (but?but->y2:block->maxy) + (block->panel?block->panel->ofsy:0.0f); - rect->xmax= floor(getsizex*(0.5+ 0.5*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0]))); - rect->ymax= floor(getsizey*(0.5+ 0.5*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1]))); + rect->xmax= floorf(getsizex*(0.5f+ 0.5f*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0]))); + rect->ymax= floorf(getsizey*(0.5f+ 0.5f*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1]))); } @@ -943,7 +943,7 @@ static void ui_is_but_sel(uiBut *but) case ICONTOG: case OPTION: value= ui_get_but_val(but); - if(value!=but->hardmin) push= 1; + if(value != (double)but->hardmin) push= 1; break; case ICONTOGN: case TOGN: @@ -959,7 +959,7 @@ static void ui_is_but_sel(uiBut *but) if((int)value & (int)but->hardmax) push= 1; } else { - if(value == but->hardmax) push= 1; + if(value == (double)but->hardmax) push= 1; } break; case COL: @@ -1125,9 +1125,9 @@ void ui_get_but_vectorf(uiBut *but, float *vec) } else if(but->pointype == CHA) { char *cp= (char *)but->poin; - vec[0]= ((float)cp[0])/255.0; - vec[1]= ((float)cp[1])/255.0; - vec[2]= ((float)cp[2])/255.0; + vec[0]= ((float)cp[0])/255.0f; + vec[1]= ((float)cp[1])/255.0f; + vec[2]= ((float)cp[2])/255.0f; } else if(but->pointype == FLO) { float *fp= (float *)but->poin; @@ -1164,9 +1164,9 @@ void ui_set_but_vectorf(uiBut *but, float *vec) } else if(but->pointype == CHA) { char *cp= (char *)but->poin; - cp[0]= (char)(0.5 +vec[0]*255.0); - cp[1]= (char)(0.5 +vec[1]*255.0); - cp[2]= (char)(0.5 +vec[2]*255.0); + cp[0]= (char)(0.5f + vec[0]*255.0f); + cp[1]= (char)(0.5f + vec[1]*255.0f); + cp[2]= (char)(0.5f + vec[2]*255.0f); } else if(but->pointype == FLO) { float *fp= (float *)but->poin; @@ -1401,7 +1401,7 @@ static double ui_get_but_scale_unit(uiBut *but, double value) int unit_type= uiButGetUnitType(but); if(unit_type == PROP_UNIT_LENGTH) { - return value * scene->unit.scale_length; + return value * (double)scene->unit.scale_length; } else if(unit_type == PROP_UNIT_AREA) { return value * pow(scene->unit.scale_length, 2); @@ -1441,7 +1441,7 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va int unit_type= uiButGetUnitType(but); int precision= but->a2; - if(scene->unit.scale_length<0.0001) scene->unit.scale_length= 1.0; // XXX do_versions + if(scene->unit.scale_length<0.0001f) scene->unit.scale_length= 1.0f; // XXX do_versions /* Sanity checks */ if(precision>7) precision= 7; @@ -1458,8 +1458,8 @@ static float ui_get_but_step_unit(uiBut *but, float step_default) step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, step_default), scene->unit.system, unit_type); - if(step > 0.0) { /* -1 is an error value */ - return (step/ui_get_but_scale_unit(but, 1.0))*100; + if(step > 0.0f) { /* -1 is an error value */ + return (float)((double)step/ui_get_but_scale_unit(but, 1.0))*100.0f; } else { return step_default; @@ -1633,8 +1633,8 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) if(but->type==NUMABS) value= fabs(value); /* not that we use hard limits here */ - if(valuehardmin) value= but->hardmin; - if(value>but->hardmax) value= but->hardmax; + if(value < (double)but->hardmin) value= but->hardmin; + if(value > (double)but->hardmax) value= but->hardmax; ui_set_but_val(but, value); return 1; @@ -1705,8 +1705,8 @@ void ui_set_but_soft_range(uiBut *but, double value) float fmin, fmax, fstep, fprecision; RNA_property_float_ui_range(&but->rnapoin, but->rnaprop, &fmin, &fmax, &fstep, &fprecision); - softmin= (fmin == -FLT_MAX)? -1e4: fmin; - softmax= (fmax == FLT_MAX)? 1e4: fmax; + softmin= (fmin == -FLT_MAX)? (float)-1e4: fmin; + softmax= (fmax == FLT_MAX)? (float)1e4: fmax; /*step= fstep;*/ /*UNUSED*/ /*precision= fprecision;*/ /*UNUSED*/ } @@ -1720,8 +1720,8 @@ void ui_set_but_soft_range(uiBut *but, double value) else softmin= soft_range_round_down(value, softmin); - if(softmin < but->hardmin) - softmin= but->hardmin; + if(softmin < (double)but->hardmin) + softmin= (double)but->hardmin; } else if(value-1e-10 > softmax) { if(value < 0.0) @@ -1729,7 +1729,7 @@ void ui_set_but_soft_range(uiBut *but, double value) else softmax= soft_range_round_up(value, softmax); - if(softmax > but->hardmax) + if(softmax > (double)but->hardmax) softmax= but->hardmax; } @@ -1932,14 +1932,14 @@ void ui_check_but(uiBut *but) case NUMSLI: case HSVSLI: value= ui_get_but_val(but); - if(value < but->hardmin) ui_set_but_val(but, but->hardmin); - else if(value > but->hardmax) ui_set_but_val(but, but->hardmax); + if(value < (double)but->hardmin) ui_set_but_val(but, but->hardmin); + else if(value > (double)but->hardmax) ui_set_but_val(but, but->hardmax); break; case NUMABS: value= fabs( ui_get_but_val(but) ); - if(value < but->hardmin) ui_set_but_val(but, but->hardmin); - else if(value > but->hardmax) ui_set_but_val(but, but->hardmax); + if(value < (double)but->hardmin) ui_set_but_val(but, but->hardmin); + else if(value > (double)but->hardmax) ui_set_but_val(but, but->hardmax); break; case ICONTOG: @@ -2008,7 +2008,7 @@ void ui_check_but(uiBut *but) else sprintf(but->drawstr, "%s%.4f", but->str, value); } else { - if(but->hardmax<10.001) sprintf(but->drawstr, "%s%.3f", but->str, value); + if(but->hardmax<10.001f) sprintf(but->drawstr, "%s%.3f", but->str, value); else sprintf(but->drawstr, "%s%.2f", but->str, value); } } @@ -2248,23 +2248,23 @@ static void ui_block_do_align_but(uiBut *first, int nr) if(prev) { // simple cases if(rows==0) { - but->x1= (prev->x2+but->x1)/2.0; + but->x1= (prev->x2+but->x1)/2.0f; prev->x2= but->x1; } else if(cols==0) { - but->y2= (prev->y1+but->y2)/2.0; + but->y2= (prev->y1+but->y2)/2.0f; prev->y1= but->y2; } else { if(buts_are_horiz(prev, but)) { - but->x1= (prev->x2+but->x1)/2.0; + but->x1= (prev->x2+but->x1)/2.0f; prev->x2= but->x1; /* copy height too */ but->y2= prev->y2; } else if(prev->prev && buts_are_horiz(prev->prev, prev)==0) { /* the previous button is a single one in its row */ - but->y2= (prev->y1+but->y2)/2.0; + but->y2= (prev->y1+but->y2)/2.0f; prev->y1= but->y2; but->x1= prev->x1; @@ -3046,7 +3046,7 @@ void uiBlockFlipOrder(uiBlock *block) if(but->y2 > maxy) maxy= but->y2; } /* mirror trick */ - centy= (miny+maxy)/2.0; + centy= (miny+maxy)/2.0f; for(but= block->buttons.first; but; but= but->next) { but->y1 = centy-(but->y1-centy); but->y2 = centy-(but->y2-centy); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 659bb41eec0..f8ce278814f 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -144,9 +144,9 @@ static void round_box_shade_col(float *col1, float *col2, float fac) { float col[3]; - col[0]= (fac*col1[0] + (1.0-fac)*col2[0]); - col[1]= (fac*col1[1] + (1.0-fac)*col2[1]); - col[2]= (fac*col1[2] + (1.0-fac)*col2[2]); + col[0]= (fac*col1[0] + (1.0f-fac)*col2[0]); + col[1]= (fac*col1[1] + (1.0f-fac)*col2[1]); + col[2]= (fac*col1[2] + (1.0f-fac)*col2[2]); glColor3fv(col); } @@ -170,12 +170,12 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl glGetFloatv(GL_CURRENT_COLOR, color); /* 'shade' defines strength of shading */ - coltop[0]= color[0]+shadetop; if(coltop[0]>1.0) coltop[0]= 1.0; - coltop[1]= color[1]+shadetop; if(coltop[1]>1.0) coltop[1]= 1.0; - coltop[2]= color[2]+shadetop; if(coltop[2]>1.0) coltop[2]= 1.0; - coldown[0]= color[0]+shadedown; if(coldown[0]<0.0) coldown[0]= 0.0; - coldown[1]= color[1]+shadedown; if(coldown[1]<0.0) coldown[1]= 0.0; - coldown[2]= color[2]+shadedown; if(coldown[2]<0.0) coldown[2]= 0.0; + coltop[0]= color[0]+shadetop; if(coltop[0]>1.0f) coltop[0]= 1.0f; + coltop[1]= color[1]+shadetop; if(coltop[1]>1.0f) coltop[1]= 1.0f; + coltop[2]= color[2]+shadetop; if(coltop[2]>1.0f) coltop[2]= 1.0f; + coldown[0]= color[0]+shadedown; if(coldown[0]<0.0f) coldown[0]= 0.0f; + coldown[1]= color[1]+shadedown; if(coldown[1]<0.0f) coldown[1]= 0.0f; + coldown[2]= color[2]+shadedown; if(coldown[2]<0.0f) coldown[2]= 0.0f; glShadeModel(GL_SMOOTH); glBegin(mode); @@ -277,12 +277,12 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float glGetFloatv(GL_CURRENT_COLOR, color); /* 'shade' defines strength of shading */ - colLeft[0]= color[0]+shadeLeft; if(colLeft[0]>1.0) colLeft[0]= 1.0; - colLeft[1]= color[1]+shadeLeft; if(colLeft[1]>1.0) colLeft[1]= 1.0; - colLeft[2]= color[2]+shadeLeft; if(colLeft[2]>1.0) colLeft[2]= 1.0; - colRight[0]= color[0]+shadeRight; if(colRight[0]<0.0) colRight[0]= 0.0; - colRight[1]= color[1]+shadeRight; if(colRight[1]<0.0) colRight[1]= 0.0; - colRight[2]= color[2]+shadeRight; if(colRight[2]<0.0) colRight[2]= 0.0; + colLeft[0]= color[0]+shadeLeft; if(colLeft[0]>1.0f) colLeft[0]= 1.0f; + colLeft[1]= color[1]+shadeLeft; if(colLeft[1]>1.0f) colLeft[1]= 1.0f; + colLeft[2]= color[2]+shadeLeft; if(colLeft[2]>1.0f) colLeft[2]= 1.0f; + colRight[0]= color[0]+shadeRight; if(colRight[0]<0.0f) colRight[0]= 0.0f; + colRight[1]= color[1]+shadeRight; if(colRight[1]<0.0f) colRight[1]= 0.0f; + colRight[2]= color[2]+shadeRight; if(colRight[2]<0.0f) colRight[2]= 0.0f; glShadeModel(GL_SMOOTH); glBegin(mode); @@ -951,9 +951,9 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), /* min max */ for (c=0; c<3; c++) { if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) - glColor3f(colors[c][0]*0.75, colors[c][1]*0.75, colors[c][2]*0.75); + glColor3f(colors[c][0]*0.75f, colors[c][1]*0.75f, colors[c][2]*0.75f); else - glColor3f(colorsycc[c][0]*0.75, colorsycc[c][1]*0.75, colorsycc[c][2]*0.75); + glColor3f(colorsycc[c][0]*0.75f, colorsycc[c][1]*0.75f, colorsycc[c][2]*0.75f); min= yofs+scopes->minmax[c][0]*h; max= yofs+scopes->minmax[c][1]*h; CLAMP(min, rect.ymin, rect.ymax); @@ -986,15 +986,15 @@ static void vectorscope_draw_target(float centerx, float centery, float diam, fl rgb_to_yuv(r,g,b, &y, &u, &v); if (u>0 && v>=0) tangle=atanf(v/u); - else if (u>0 && v<0) tangle=atanf(v/u)+2*M_PI; - else if (u<0) tangle=atanf(v/u)+M_PI; - else if (u==0 && v>0) tangle=M_PI/2.0f; - else if (u==0 && v<0) tangle=-M_PI/2.0f; + else if (u>0 && v<0) tangle= atanf(v/u) + 2.0f * (float)M_PI; + else if (u<0) tangle=atanf(v/u) + (float)M_PI; + else if (u==0 && v > 0.0f) tangle= (float)M_PI/2.0f; + else if (u==0 && v < 0.0f) tangle=-(float)M_PI/2.0f; tampli= sqrtf(u*u+v*v); /* small target vary by 2.5 degree and 2.5 IRE unit */ glColor4f(1.0f, 1.0f, 1.0, 0.12f); - dangle= 2.5*M_PI/180.0f; + dangle= 2.5f*(float)M_PI/180.0f; dampli= 2.5f/200.0f; glBegin(GL_LINE_STRIP); glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle+dangle), polar_to_y(centery,diam,tampli+dampli,tangle+dangle)); @@ -1005,9 +1005,9 @@ static void vectorscope_draw_target(float centerx, float centery, float diam, fl glEnd(); /* big target vary by 10 degree and 20% amplitude */ glColor4f(1.0f, 1.0f, 1.0, 0.12f); - dangle= 10*M_PI/180.0f; - dampli= 0.2*tampli; - dangle2= 5.0f*M_PI/180.0f; + dangle= 10.0f*(float)M_PI/180.0f; + dampli= 0.2f*tampli; + dangle2= 5.0f*(float)M_PI/180.0f; dampli2= 0.5f*dampli; glBegin(GL_LINE_STRIP); glVertex2f(polar_to_x(centerx,diam,tampli+dampli-dampli2,tangle+dangle), polar_to_y(centery,diam,tampli+dampli-dampli2,tangle+dangle)); @@ -1131,13 +1131,13 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect) sizey= rect->ymax-y1; /* first background, to show tranparency */ - dx= sizex/12.0; + dx= sizex/12.0f; v1[0]= x1; for(a=0; a<12; a++) { if(a & 1) glColor3f(0.3, 0.3, 0.3); else glColor3f(0.8, 0.8, 0.8); - glRectf(v1[0], y1, v1[0]+dx, y1+0.5*sizey); + glRectf(v1[0], y1, v1[0]+dx, y1+0.5f*sizey); if(a & 1) glColor3f(0.8, 0.8, 0.8); else glColor3f(0.3, 0.3, 0.3); - glRectf(v1[0], y1+0.5*sizey, v1[0]+dx, y1+sizey); + glRectf(v1[0], y1+0.5f*sizey, v1[0]+dx, y1+sizey); v1[0]+= dx; } @@ -1178,9 +1178,9 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect) /* help lines */ v1[0]= v2[0]=v3[0]= x1; v1[1]= y1; - v1a[1]= y1+0.25*sizey; - v2[1]= y1+0.5*sizey; - v2a[1]= y1+0.75*sizey; + v1a[1]= y1+0.25f*sizey; + v2[1]= y1+0.5f*sizey; + v2a[1]= y1+0.75f*sizey; v3[1]= y1+sizey; @@ -1330,7 +1330,7 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o glBegin(GL_LINES); dx= step*zoomx; fx= rect->xmin + zoomx*(-offsx); - if(fx > rect->xmin) fx -= dx*( floor(fx-rect->xmin)); + if(fx > rect->xmin) fx -= dx*(floorf(fx-rect->xmin)); while(fx < rect->xmax) { glVertex2f(fx, rect->ymin); glVertex2f(fx, rect->ymax); @@ -1339,7 +1339,7 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o dy= step*zoomy; fy= rect->ymin + zoomy*(-offsy); - if(fy > rect->ymin) fy -= dy*( floor(fy-rect->ymin)); + if(fy > rect->ymin) fy -= dy*(floorf(fy-rect->ymin)); while(fy < rect->ymax) { glVertex2f(rect->xmin, fy); glVertex2f(rect->xmax, fy); @@ -1379,8 +1379,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glScissor(scissor_new.xmin, scissor_new.ymin, scissor_new.xmax-scissor_new.xmin, scissor_new.ymax-scissor_new.ymin); /* calculate offset and zoom */ - zoomx= (rect->xmax-rect->xmin-2.0*but->aspect)/(cumap->curr.xmax - cumap->curr.xmin); - zoomy= (rect->ymax-rect->ymin-2.0*but->aspect)/(cumap->curr.ymax - cumap->curr.ymin); + zoomx= (rect->xmax-rect->xmin-2.0f*but->aspect)/(cumap->curr.xmax - cumap->curr.xmin); + zoomy= (rect->ymax-rect->ymin-2.0f*but->aspect)/(cumap->curr.ymax - cumap->curr.ymin); offsx= cumap->curr.xmin-but->aspect/zoomx; offsy= cumap->curr.ymin-but->aspect/zoomy; @@ -1540,9 +1540,9 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s glBegin(GL_POLYGON); glColor4ub(0, 0, 0, alpha); glVertex2f(maxx, miny); - glVertex2f(maxx, maxy-0.3*shadsize); + glVertex2f(maxx, maxy-0.3f*shadsize); glColor4ub(0, 0, 0, 0); - glVertex2f(maxx+shadsize, maxy-0.75*shadsize); + glVertex2f(maxx+shadsize, maxy-0.75f*shadsize); glVertex2f(maxx+shadsize, miny); glEnd(); @@ -1552,18 +1552,18 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s glVertex2f(maxx, miny); glColor4ub(0, 0, 0, 0); glVertex2f(maxx+shadsize, miny); - glVertex2f(maxx+0.7*shadsize, miny-0.7*shadsize); + glVertex2f(maxx+0.7f*shadsize, miny-0.7f*shadsize); glVertex2f(maxx, miny-shadsize); glEnd(); /* bottom quad */ glBegin(GL_POLYGON); glColor4ub(0, 0, 0, alpha); - glVertex2f(minx+0.3*shadsize, miny); + glVertex2f(minx+0.3f*shadsize, miny); glVertex2f(maxx, miny); glColor4ub(0, 0, 0, 0); glVertex2f(maxx, miny-shadsize); - glVertex2f(minx+0.5*shadsize, miny-shadsize); + glVertex2f(minx+0.5f*shadsize, miny-shadsize); glEnd(); glDisable(GL_BLEND); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 91380d20f41..648eee07ca0 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1296,7 +1296,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho while (i > 0) { i--; - if (BLF_width(fstyle->uifont_id, origstr+i) > (startx - x)*0.25) break; // 0.25 == scale factor for less sensitivity + if (BLF_width(fstyle->uifont_id, origstr+i) > (startx - x)*0.25f) break; // 0.25 == scale factor for less sensitivity } but->ofs = i; but->pos = but->ofs; @@ -1968,7 +1968,7 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data) softmax= but->softmax; softrange= softmax - softmin; - data->dragfstart= (softrange == 0.0)? 0.0: (data->value - softmin)/softrange; + data->dragfstart= (softrange == 0.0f)? 0.0f: ((float)data->value - softmin)/softrange; data->dragf= data->dragfstart; } @@ -2318,13 +2318,13 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa } if(snap==1) { - if(softrange < 2.10) tempf= 0.1*floor(10*tempf); - else if(softrange < 21.0) tempf= floor(tempf); - else tempf= 10.0*floor(tempf/10.0); + if(softrange < 2.10f) tempf= 0.1f*floorf(10.0f*tempf); + else if(softrange < 21.0f) tempf= floorf(tempf); + else tempf= 10.0f*floorf(tempf/10.0f); } else if(snap==2) { - if(softrange < 2.10) tempf= 0.01*floor(100.0*tempf); - else if(softrange < 21.0) tempf= 0.1*floor(10.0*tempf); + if(softrange < 2.10f) tempf= 0.01f*floorf(100.0f*tempf); + else if(softrange < 21.0f) tempf= 0.1f*floorf(10.0f*tempf); else tempf= floor(tempf); } @@ -2380,8 +2380,8 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i /* Mouse location isn't screen clamped to the screen so use a linear mapping * 2px == 1-int, or 1px == 1-ClickStep */ if(ui_is_but_float(but)) { - fac *= 0.01*but->a1; - tempf = data->startvalue + ((mx - data->dragstartx) * fac); + fac *= 0.01f*but->a1; + tempf = (float)data->startvalue + ((float)(mx - data->dragstartx) * fac); tempf= ui_numedit_apply_snapf(but, tempf, softmin, softmax, softrange, snap); #if 1 /* fake moving the click start, nicer for dragging back after passing the limit */ @@ -2396,7 +2396,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i CLAMP(tempf, softmin, softmax); #endif - if(tempf != data->value) { + if(tempf != (float)data->value) { data->dragchange= 1; data->value= tempf; changed= 1; @@ -2407,7 +2407,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i else if(softrange > 32) fac= 1.0/2.0; /* 2px == 1 */ else fac= 1.0/16.0; /* 16px == 1? */ - temp= data->startvalue + ((mx - data->dragstartx) * fac); + temp= data->startvalue + (((double)mx - data->dragstartx) * (double)fac); temp= ui_numedit_apply_snap(temp, softmin, softmax, snap); #if 1 /* fake moving the click start, nicer for dragging back after passing the limit */ @@ -2445,22 +2445,22 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i if(softrange > 11) { /* non linear change in mouse input- good for high precicsion */ - data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.002); + data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabsf(data->dragstartx-mx)*0.002f); } else if (softrange > 129) { /* only scale large int buttons */ /* non linear change in mouse input- good for high precicsionm ints need less fine tuning */ - data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.004); + data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabsf(data->dragstartx-mx)*0.004f); } else { /*no scaling */ data->dragf+= ((float)(mx-data->draglastx))/deler ; } - CLAMP(data->dragf, 0.0, 1.0); + CLAMP(data->dragf, 0.0f, 1.0f); data->draglastx= mx; tempf= (softmin + data->dragf*softrange); if(!ui_is_but_float(but)) { - temp= floor(tempf+.5); + temp= floorf(tempf + 0.5f); temp= ui_numedit_apply_snap(temp, softmin, softmax, snap); @@ -2479,7 +2479,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i CLAMP(tempf, softmin, softmax); - if(tempf != data->value) { + if(tempf != (float)data->value) { data->dragchange= 1; data->value= tempf; changed= 1; @@ -2609,7 +2609,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if(mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - tempf= data->value - 0.01*but->a1; + tempf= (float)data->value - 0.01f * but->a1; if (tempf < softmin) tempf = softmin; data->value= tempf; @@ -2618,7 +2618,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton else if(mx > but->x1 + (2*((but->x2 - but->x1)/3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - tempf= data->value + 0.01*but->a1; + tempf= (float)data->value + 0.01f * but->a1; if (tempf > softmax) tempf = softmax; data->value= tempf; @@ -2643,23 +2643,23 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i softmax= but->softmax; softrange= softmax - softmin; - if(but->type==NUMSLI) deler= ((but->x2-but->x1) - 5.0*but->aspect); - else if(but->type==HSVSLI) deler= ((but->x2-but->x1)/2 - 5.0*but->aspect); + if(but->type==NUMSLI) deler= ((but->x2-but->x1) - 5.0f*but->aspect); + else if(but->type==HSVSLI) deler= ((but->x2-but->x1)/2.0f - 5.0f*but->aspect); else if(but->type==SCROLL) { int horizontal= (but->x2 - but->x1 > but->y2 - but->y1); float size= (horizontal)? (but->x2-but->x1): -(but->y2-but->y1); deler= size*(but->softmax - but->softmin)/(but->softmax - but->softmin + but->a1); } - else deler= (but->x2-but->x1- 5.0*but->aspect); + else deler= (but->x2-but->x1- 5.0f*but->aspect); f= (float)(mx-data->dragstartx)/deler + data->dragfstart; if(shift) - f= (f-data->dragfstart)/10.0 + data->dragfstart; + f= (f-data->dragfstart)/10.0f + data->dragfstart; - CLAMP(f, 0.0, 1.0); + CLAMP(f, 0.0f, 1.0f); tempf= softmin + f*softrange; - temp= floor(tempf+.5); + temp= floorf(tempf+0.5f); if(ctrl) { if(tempf==softmin || tempf==softmax); @@ -2667,14 +2667,14 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i if(shift) { if(tempf==softmin || tempf==softmax); - else if(softmax-softmin < 2.10) tempf= 0.01*floor(100.0*tempf); - else if(softmax-softmin < 21.0) tempf= 0.1*floor(10.0*tempf); - else tempf= floor(tempf); + else if(softmax-softmin < 2.10f) tempf= 0.01f * floorf(100.0f*tempf); + else if(softmax-softmin < 21.0f) tempf= 0.1f * floorf(10.0f*tempf); + else tempf= floorf(tempf); } else { - if(softmax-softmin < 2.10) tempf= 0.1*floor(10*tempf); - else if(softmax-softmin < 21.0) tempf= floor(tempf); - else tempf= 10.0*floor(tempf/10.0); + if(softmax-softmin < 2.10f) tempf= 0.1f * floorf(10.0f*tempf); + else if(softmax-softmin < 21.0f) tempf= floorf(tempf); + else tempf= 10.0f*floorf(tempf/10.0f); } } else { @@ -2697,7 +2697,7 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i else { CLAMP(tempf, softmin, softmax); - if(tempf != data->value) { + if(tempf != (float)data->value) { data->value= tempf; data->dragchange= 1; changed= 1; @@ -2814,8 +2814,8 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton data->cancel= 1; } else { - if(f=softmin && tempf<=softmax) data->value= tempf; @@ -2983,7 +2983,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i mdy= (rad*fp[1]); } else if(fp[2]> -1.0f) { - mrad= rad/sqrt(fp[0]*fp[0] + fp[1]*fp[1]); + mrad= rad/sqrtf(fp[0]*fp[0] + fp[1]*fp[1]); mdx= 2.0f*mrad*fp[0] - (rad*fp[0]); mdy= 2.0f*mrad*fp[1] - (rad*fp[1]); @@ -3002,7 +3002,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i } else { /* outer circle */ - mrad= rad/sqrt(mrad); // veclen + mrad= rad/sqrtf(mrad); // veclen dx*= (2.0f*mrad - 1.0f); dy*= (2.0f*mrad - 1.0f); @@ -3081,8 +3081,8 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, /* relative position within box */ x= ((float)mx-but->x1)/(but->x2-but->x1); y= ((float)my-but->y1)/(but->y2-but->y1); - CLAMP(x, 0.0, 1.0); - CLAMP(y, 0.0, 1.0); + CLAMP(x, 0.0f, 1.0f); + CLAMP(y, 0.0f, 1.0f); switch((int)but->a1) { case UI_GRAD_SV: @@ -3226,7 +3226,7 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx } if(U.uiflag & USER_CONTINUOUS_MOUSE) { - float fac= shift ? 0.05 : 1.0f; + float fac= shift ? 0.05f : 1.0f; /* slow down the mouse, this is fairly picky */ mx = (data->dragstartx*(1.0f-fac) + mx*fac); my = (data->dragstarty*(1.0f-fac) + my*fac); @@ -3374,7 +3374,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx dx= ((float)(mx - data->draglastx))/(but->x2-but->x1); data->dragcbd->pos += dx; - CLAMP(data->dragcbd->pos, 0.0, 1.0); + CLAMP(data->dragcbd->pos, 0.0f, 1.0f); ui_colorband_update(data->coba); data->dragcbd= data->coba->data + data->coba->cur; /* because qsort */ @@ -3479,8 +3479,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, cmp[a].x+= fx; cmp[a].y+= fy; if(snap) { - cmp[a].x= 0.125f*floor(0.5f + 8.0f*cmp[a].x); - cmp[a].y= 0.125f*floor(0.5f + 8.0f*cmp[a].y); + cmp[a].x= 0.125f*floorf(0.5f + 8.0f*cmp[a].x); + cmp[a].y= 0.125f*floorf(0.5f + 8.0f*cmp[a].y); } if(cmp[a].x!=origx || cmp[a].y!=origy) moved_point= 1; @@ -3687,7 +3687,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx hist->height = (but->y2 - but->y1) + (data->dragstarty - my); } else { /* scale histogram values */ - yfac = MIN2(powf(hist->ymax, 2.f), 1.f) * 0.5; + yfac = MIN2(powf(hist->ymax, 2.f), 1.f) * 0.5f; hist->ymax += dy * yfac; CLAMP(hist->ymax, 1.f, 100.f); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index f3d1dd25c2f..25dbcf81c26 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -377,7 +377,7 @@ static void ui_draw_anti_x(float x1, float y1, float x2, float y2) static void ui_draw_x_icon(float x, float y) { - ui_draw_anti_x(x, y, x+9.375, y+9.375); + ui_draw_anti_x(x, y, x+9.375f, y+9.375f); } @@ -737,8 +737,8 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag) for(a=0; apa->flag & PNL_SELECT)==0) { if((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) { - ps->orig->ofsx= floor(0.5 + fac*ps->pa->ofsx + (1.0-fac)*ps->orig->ofsx); - ps->orig->ofsy= floor(0.5 + fac*ps->pa->ofsy + (1.0-fac)*ps->orig->ofsy); + ps->orig->ofsx= floorf(0.5f + fac*(float)ps->pa->ofsx + (1.0f-fac)*(float)ps->orig->ofsx); + ps->orig->ofsy= floorf(0.5f + fac*(float)ps->pa->ofsy + (1.0f-fac)*(float)ps->orig->ofsy); done= 1; } } @@ -886,9 +886,9 @@ static void check_panel_overlap(ARegion *ar, Panel *panel) else if(panel->flag & PNL_CLOSEDY) safey= 0.05; if(pa->ofsx > panel->ofsx- safex*panel->sizex) - if(pa->ofsx+pa->sizex < panel->ofsx+ (1.0+safex)*panel->sizex) + if(pa->ofsx+pa->sizex < panel->ofsx+ (1.0f+safex)*panel->sizex) if(pa->ofsy > panel->ofsy- safey*panel->sizey) - if(pa->ofsy+pa->sizey < panel->ofsy+ (1.0+safey)*panel->sizey) + if(pa->ofsy+pa->sizey < panel->ofsy+ (1.0f+safey)*panel->sizey) pa->flag |= PNL_OVERLAP; } } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index d2b1a4d8db8..4a0584bca7b 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1185,9 +1185,9 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, if(block->direction & UI_CENTER) center= ysize/2; else center= 0; - if( butrct.xmin-xsize > 0.0) left= 1; + if( butrct.xmin-xsize > 0.0f) left= 1; if( butrct.xmax+xsize < winx) right= 1; - if( butrct.ymin-ysize+center > 0.0) down= 1; + if( butrct.ymin-ysize+center > 0.0f) down= 1; if( butrct.ymax+ysize-center < winy) top= 1; dir1= block->direction & UI_DIRECTION; @@ -1300,8 +1300,8 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, /* safety calculus */ if(but) { - float midx= (butrct.xmin+butrct.xmax)/2.0; - float midy= (butrct.ymin+butrct.ymax)/2.0; + float midx= (butrct.xmin+butrct.xmax)/2.0f; + float midy= (butrct.ymin+butrct.ymax)/2.0f; /* when you are outside parent button, safety there should be smaller */ diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index d13de5cf0c6..2f442d930de 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2423,7 +2423,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) rti= (ReportTimerInfo *)reports->reporttimer->customdata; - if (!rti || rti->widthfac==0.0 || !report) return; + if (!rti || rti->widthfac==0.0f || !report) return; ui_abs= uiLayoutAbsolute(layout, 0); block= uiLayoutGetBlock(ui_abs); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 50d0359883b..b57d8fda712 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -173,7 +173,7 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y /* for each AA step */ for(j=0; j<8; j++) { - glTranslatef(1.0*jit[j][0], 1.0*jit[j][1], 0.0f); + glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); glBegin(GL_POLYGON); glVertex2f(x1, y1); @@ -181,7 +181,7 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y glVertex2f(x3, y3); glEnd(); - glTranslatef(-1.0*jit[j][0], -1.0*jit[j][1], 0.0f); + glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f); } glDisable(GL_BLEND); @@ -696,7 +696,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) /* for each AA step */ if(wtb->outline) { for(j=0; j<8; j++) { - glTranslatef(1.0*jit[j][0], 1.0*jit[j][1], 0.0f); + glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); /* outline */ glColor4ub(wcol->outline[0], wcol->outline[1], wcol->outline[2], 32); @@ -720,7 +720,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glEnd(); } - glTranslatef(-1.0*jit[j][0], -1.0*jit[j][1], 0.0f); + glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f); } } @@ -728,7 +728,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) if(wtb->tria1.tot || wtb->tria2.tot) { /* for each AA step */ for(j=0; j<8; j++) { - glTranslatef(1.0*jit[j][0], 1.0*jit[j][1], 0.0f); + glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); if(wtb->tria1.tot) { glColor4ub(wcol->item[0], wcol->item[1], wcol->item[2], 32); @@ -739,7 +739,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) widget_trias_draw(&wtb->tria2); } - glTranslatef(-1.0*jit[j][0], -1.0*jit[j][1], 0.0f); + glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f); } } @@ -1700,7 +1700,7 @@ void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float else *valdist= 1.0f; - *valrad= atan2(mx, my)/(2.0f*M_PI) + 0.5f; + *valrad= atan2f(mx, my)/(2.0f*(float)M_PI) + 0.5f; } static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) @@ -1715,7 +1715,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) color_profile = BLI_PR_NONE; - radstep= 2.0f*M_PI/(float)tot; + radstep= 2.0f*(float)M_PI/(float)tot; centx= (float)(rect->xmin + rect->xmax)/2; centy= (float)(rect->ymin + rect->ymax)/2; @@ -1773,14 +1773,14 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) glPopMatrix(); /* cursor */ - ang= 2.0f*M_PI*hsvo[0] + 0.5f*M_PI; + ang= 2.0f*(float)M_PI*hsvo[0] + 0.5f*(float)M_PI; if(but->flag & UI_BUT_COLOR_CUBIC) - radius= (1.0f - pow(1.0f - hsvo[1], 3.0f)) *radius; + radius= (1.0f - powf(1.0f - hsvo[1], 3.0f)) *radius; else radius= hsvo[1] * radius; - ui_hsv_cursor(centx + cos(-ang)*radius, centy + sin(-ang)*radius); + ui_hsv_cursor(centx + cosf(-ang)*radius, centy + sinf(-ang)*radius); } @@ -1845,7 +1845,7 @@ void ui_draw_gradient(rcti *rect, float *hsv, int type, float alpha) /* old below */ - for(dx=0.0; dx<1.0; dx+= 0.05) { + for(dx=0.0f; dx<1.0f; dx+= 0.05f) { // previous color VECCOPY(col0[0], col1[0]); VECCOPY(col0[1], col1[1]); @@ -1894,7 +1894,7 @@ void ui_draw_gradient(rcti *rect, float *hsv, int type, float alpha) // rect sx1= rect->xmin + dx*(rect->xmax-rect->xmin); - sx2= rect->xmin + (dx+0.05)*(rect->xmax-rect->xmin); + sx2= rect->xmin + (dx+0.05f)*(rect->xmax-rect->xmin); sy= rect->ymin; dy= (rect->ymax-rect->ymin)/3.0; @@ -1959,8 +1959,8 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) /* cursor */ x= rect->xmin + x*(rect->xmax-rect->xmin); y= rect->ymin + y*(rect->ymax-rect->ymin); - CLAMP(x, rect->xmin+3.0, rect->xmax-3.0); - CLAMP(y, rect->ymin+3.0, rect->ymax-3.0); + CLAMP(x, rect->xmin+3.0f, rect->xmax-3.0f); + CLAMP(y, rect->ymin+3.0f, rect->ymax-3.0f); ui_hsv_cursor(x, y); @@ -2009,7 +2009,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) /* cursor */ x= rect->xmin + 0.5f * (rect->xmax-rect->xmin); y= rect->ymin + v * (rect->ymax-rect->ymin); - CLAMP(y, rect->ymin+3.0, rect->ymax-3.0); + CLAMP(y, rect->ymin+3.0f, rect->ymax-3.0f); ui_hsv_cursor(x, y); @@ -2039,7 +2039,7 @@ static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int round { uiWidgetBase wtb; float rad= 0.5f*(rect->ymax - rect->ymin); - float textofs = rad*0.75; + float textofs = rad*0.75f; if(state & UI_SELECT) SWAP(short, wcol->shadetop, wcol->shadedown); @@ -2210,8 +2210,8 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat if(horizontal) { fac= (rect->xmax - rect->xmin)/(size); - rect1.xmin= rect1.xmin + ceil(fac*(value - but->softmin)); - rect1.xmax= rect1.xmin + ceil(fac*(but->a1 - but->softmin)); + rect1.xmin= rect1.xmin + ceilf(fac*((float)value - but->softmin)); + rect1.xmax= rect1.xmin + ceilf(fac*(but->a1 - but->softmin)); /* ensure minimium size */ min= rect->ymax - rect->ymin; @@ -2227,8 +2227,8 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat } else { fac= (rect->ymax - rect->ymin)/(size); - rect1.ymax= rect1.ymax - ceil(fac*(value - but->softmin)); - rect1.ymin= rect1.ymax - ceil(fac*(but->a1 - but->softmin)); + rect1.ymax= rect1.ymax - ceilf(fac*((float)value - but->softmin)); + rect1.ymin= rect1.ymax - ceilf(fac*(but->a1 - but->softmin)); /* ensure minimium size */ min= rect->xmax - rect->xmin; @@ -2325,7 +2325,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s rect1= *rect; value= ui_get_but_val(but); - fac= (value-but->softmin)*(rect1.xmax - rect1.xmin - offs)/(but->softmax - but->softmin); + fac= ((float)value-but->softmin)*(rect1.xmax - rect1.xmin - offs)/(but->softmax - but->softmin); /* left part of slider, always rounded */ rect1.xmax= rect1.xmin + ceil(offs+1.0f); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 81e093c07ff..d272b03fc22 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -784,10 +784,10 @@ void UI_ThemeColorBlend(int colorid1, int colorid2, float fac) cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); - if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; - r= floor((1.0-fac)*cp1[0] + fac*cp2[0]); - g= floor((1.0-fac)*cp1[1] + fac*cp2[1]); - b= floor((1.0-fac)*cp1[2] + fac*cp2[2]); + CLAMP(fac, 0.0f, 1.0f); + r= floorf((1.0f-fac)*cp1[0] + fac*cp2[0]); + g= floorf((1.0f-fac)*cp1[1] + fac*cp2[1]); + b= floorf((1.0f-fac)*cp1[2] + fac*cp2[2]); glColor3ub(r, g, b); } @@ -801,10 +801,10 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset) cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); - if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; - r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]); - g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]); - b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]); + CLAMP(fac, 0.0f, 1.0f); + r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]); + g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]); + b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]); CLAMP(r, 0, 255); CLAMP(g, 0, 255); @@ -822,11 +822,11 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); - if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; - r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]); - g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]); - b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]); - a= alphaoffset+floor((1.0-fac)*cp1[3] + fac*cp2[3]); + CLAMP(fac, 0.0f, 1.0f); + r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]); + g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]); + b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]); + a= alphaoffset + floorf((1.0f-fac)*cp1[3] + fac*cp2[3]); CLAMP(r, 0, 255); CLAMP(g, 0, 255); @@ -864,9 +864,9 @@ void UI_GetThemeColor3fv(int colorid, float *col) const unsigned char *cp; cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); - col[0]= ((float)cp[0])/255.0; - col[1]= ((float)cp[1])/255.0; - col[2]= ((float)cp[2])/255.0; + col[0]= ((float)cp[0])/255.0f; + col[1]= ((float)cp[1])/255.0f; + col[2]= ((float)cp[2])/255.0f; } // get the color, range 0.0-1.0, complete with shading offset @@ -884,9 +884,9 @@ void UI_GetThemeColorShade3fv(int colorid, int offset, float *col) b= offset + (int) cp[2]; CLAMP(b, 0, 255); - col[0]= ((float)r)/255.0; - col[1]= ((float)g)/255.0; - col[2]= ((float)b)/255.0; + col[0]= ((float)r)/255.0f; + col[1]= ((float)g)/255.0f; + col[2]= ((float)b)/255.0f; } // get the color, in char pointer @@ -927,11 +927,10 @@ void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4]) void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset) { int r, g, b; - - if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; - r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]); - g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]); - b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]); + CLAMP(fac, 0.0f, 1.0f); + r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]); + g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]); + b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]); r= r<0?0:(r>255?255:r); g= g<0?0:(g>255?255:g); @@ -944,16 +943,16 @@ void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char c void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3], float fac, int offset) { int r, g, b; - - if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; - r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]); - g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]); - b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]); - - r= r<0?0:(r>255?255:r); - g= g<0?0:(g>255?255:g); - b= b<0?0:(b>255?255:b); - + + CLAMP(fac, 0.0f, 1.0f); + r= offset+floor((1.0f-fac)*cp1[0] + fac*cp2[0]); + g= offset+floor((1.0f-fac)*cp1[1] + fac*cp2[1]); + b= offset+floor((1.0f-fac)*cp1[2] + fac*cp2[2]); + + CLAMP(r, 0, 255); + CLAMP(g, 0, 255); + CLAMP(b, 0, 255); + col[0] = r; col[1] = g; col[2] = b; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 8c397d9c14f..32301dd6423 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -996,12 +996,12 @@ void UI_view2d_view_ortho(View2D *v2d) /* XXX ton: this flag set by outliner, for icons */ if(v2d->flag & V2D_PIXELOFS_X) { - curmasked.xmin= floor(curmasked.xmin) - 0.001f; - curmasked.xmax= floor(curmasked.xmax) - 0.001f; + curmasked.xmin= floorf(curmasked.xmin) - 0.001f; + curmasked.xmax= floorf(curmasked.xmax) - 0.001f; } if(v2d->flag & V2D_PIXELOFS_Y) { - curmasked.ymin= floor(curmasked.ymin) - 0.001f; - curmasked.ymax= floor(curmasked.ymax) - 0.001f; + curmasked.ymin= floorf(curmasked.ymin) - 0.001f; + curmasked.ymax= floorf(curmasked.ymax) - 0.001f; } /* set matrix on all appropriate axes */ @@ -1815,8 +1815,8 @@ void UI_view2d_listview_view_to_cell(View2D *v2d, short columnwidth, short rowhe float viewx, float viewy, int *column, int *row) { /* adjust view coordinates to be all positive ints, corrected for the start offset */ - const int x= (int)(floor(fabs(viewx) + 0.5f) - startx); - const int y= (int)(floor(fabs(viewy) + 0.5f) - starty); + const int x= (int)(floorf(fabsf(viewx) + 0.5f) - startx); + const int y= (int)(floorf(fabsf(viewy) + 0.5f) - starty); /* sizes must not be negative */ if ( (v2d == NULL) || ((columnwidth <= 0) && (rowheight <= 0)) ) { diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 10aac4ce0a6..123f9e2044f 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -607,7 +607,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax-v2d->cur.xmin); - float mval_faci = 1.0 - mval_fac; + float mval_faci = 1.0f - mval_fac; float ofs= (mval_fac * dx) - (mval_faci * dx); v2d->cur.xmin += ofs + dx; @@ -632,7 +632,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax-v2d->cur.ymin); - float mval_faci = 1.0 - mval_fac; + float mval_faci = 1.0f - mval_fac; float ofs= (mval_fac * dy) - (mval_faci * dy); v2d->cur.ymin += ofs + dy; @@ -817,7 +817,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax-v2d->cur.xmin); - float mval_faci = 1.0 - mval_fac; + float mval_faci = 1.0f - mval_fac; float ofs= (mval_fac * dx) - (mval_faci * dx); v2d->cur.xmin += ofs + dx; @@ -836,7 +836,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax-v2d->cur.ymin); - float mval_faci = 1.0 - mval_fac; + float mval_faci = 1.0f - mval_fac; float ofs= (mval_fac * dy) - (mval_faci * dy); v2d->cur.ymin += ofs + dy; @@ -1448,9 +1448,9 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event) /* single-click was in empty space outside bubble, so scroll by 1 'page' */ if (ELEM(vsm->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) { if (vsm->zone == SCROLLHANDLE_MIN_OUTSIDE) - vsm->delta = -vsm->scrollbarwidth * 0.8; + vsm->delta = -vsm->scrollbarwidth * 0.8f; else if (vsm->zone == SCROLLHANDLE_MAX_OUTSIDE) - vsm->delta = vsm->scrollbarwidth * 0.8; + vsm->delta = vsm->scrollbarwidth * 0.8f; scroller_activate_apply(C, op); scroller_activate_exit(C, op); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index bd2cce041dd..b1586068220 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1063,9 +1063,9 @@ typedef struct Scene { #define PRVRANGEON (scene->r.flag & SCER_PRV_RANGE) #define PSFRA ((PRVRANGEON)? (scene->r.psfra): (scene->r.sfra)) #define PEFRA ((PRVRANGEON)? (scene->r.pefra): (scene->r.efra)) -#define FRA2TIME(a) ((((double) scene->r.frs_sec_base) * (a)) / scene->r.frs_sec) -#define TIME2FRA(a) ((((double) scene->r.frs_sec) * (a)) / scene->r.frs_sec_base) -#define FPS (((double) scene->r.frs_sec) / scene->r.frs_sec_base) +#define FRA2TIME(a) ((((double) scene->r.frs_sec_base) * (double)(a)) / (double)scene->r.frs_sec) +#define TIME2FRA(a) ((((double) scene->r.frs_sec) * (double)(a)) / (double)scene->r.frs_sec_base) +#define FPS (((double) scene->r.frs_sec) / (double)scene->r.frs_sec_base) #define RAD_PHASE_PATCHES 1 #define RAD_PHASE_FACES 2 -- cgit v1.2.3