[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35819] trunk/blender/source/blender: interface: floats were being implicitly promoted to doubles, adjust to use floats (in most cases) otherwise cast to double.
Campbell Barton
ideasman42 at gmail.com
Sun Mar 27 16:52:17 CEST 2011
Revision: 35819
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35819
Author: campbellbarton
Date: 2011-03-27 14:52:16 +0000 (Sun, 27 Mar 2011)
Log Message:
-----------
interface: floats were being implicitly promoted to doubles, adjust to use floats (in most cases) otherwise cast to double.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_math_rotation.h
trunk/blender/source/blender/blenlib/BLI_utildefines.h
trunk/blender/source/blender/editors/include/ED_sequencer.h
trunk/blender/source/blender/editors/interface/interface.c
trunk/blender/source/blender/editors/interface/interface_draw.c
trunk/blender/source/blender/editors/interface/interface_handlers.c
trunk/blender/source/blender/editors/interface/interface_panel.c
trunk/blender/source/blender/editors/interface/interface_regions.c
trunk/blender/source/blender/editors/interface/interface_templates.c
trunk/blender/source/blender/editors/interface/interface_widgets.c
trunk/blender/source/blender/editors/interface/resources.c
trunk/blender/source/blender/editors/interface/view2d.c
trunk/blender/source/blender/editors/interface/view2d_ops.c
trunk/blender/source/blender/makesdna/DNA_scene_types.h
Modified: trunk/blender/source/blender/blenlib/BLI_math_rotation.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_rotation.h 2011-03-27 13:49:56 UTC (rev 35818)
+++ trunk/blender/source/blender/blenlib/BLI_math_rotation.h 2011-03-27 14:52:16 UTC (rev 35819)
@@ -39,6 +39,10 @@
#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 */
Modified: trunk/blender/source/blender/blenlib/BLI_utildefines.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_utildefines.h 2011-03-27 13:49:56 UTC (rev 35818)
+++ trunk/blender/source/blender/blenlib/BLI_utildefines.h 2011-03-27 14:52:16 UTC (rev 35819)
@@ -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<a && a<c)? 1:0) : ((c<a && a<b)? 1:0))
Modified: trunk/blender/source/blender/editors/include/ED_sequencer.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_sequencer.h 2011-03-27 13:49:56 UTC (rev 35818)
+++ trunk/blender/source/blender/editors/include/ED_sequencer.h 2011-03-27 14:52:16 UTC (rev 35819)
@@ -29,7 +29,7 @@
#ifndef ED_SEQUENCER_H
#define ED_SEQUENCER_H
-#define SEQ_ZOOM_FAC(szoom) (szoom > 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 */
Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c 2011-03-27 13:49:56 UTC (rev 35818)
+++ trunk/blender/source/blender/editors/interface/interface.c 2011-03-27 14:52:16 UTC (rev 35819)
@@ -120,8 +120,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
else
softmax= soft_range_round_up(value, softmax);
- if(softmax > but->hardmax)
+ if(softmax > (double)but->hardmax)
softmax= but->hardmax;
}
@@ -1932,14 +1932,14 @@
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 @@
else sprintf(but->drawstr, "%s%.4f", but->str, value);
}
else {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list