interface: floats were being implicitly promoted to doubles, adjust to use floats (in most cases) otherwise cast to double.
This commit is contained in:
@@ -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(value<but->hardmin) 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);
|
||||
|
||||
Reference in New Issue
Block a user