diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-05-25 01:58:12 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-05-25 01:58:12 +0400 |
commit | fda16e7381c5ce4c96fcd05cf9422ebda6bfbe1c (patch) | |
tree | ab4459b3ca3b49bb61fd2491790b21d96555025c | |
parent | 19e1d05461abafc32b5d952d5121f765f4208f94 (diff) |
remove some float/double conversions
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 35 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 6 |
2 files changed, 21 insertions, 20 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index bec07d81b84..f2e585c8f79 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -264,7 +264,8 @@ static void drawgrid_draw(ARegion *ar, double wx, double wy, double x, double y, glDisableClientState(GL_VERTEX_ARRAY); } -#define GRID_MIN_PX 6.0f +#define GRID_MIN_PX_D 6.0 +#define GRID_MIN_PX_F 6.0f static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit) { @@ -316,16 +317,16 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** while (i--) { double scalar = bUnit_GetScaler(usys, i); - dx_scalar = dx * scalar / unit->scale_length; - if (dx_scalar < (GRID_MIN_PX * 2.0)) + dx_scalar = dx * scalar / (double)unit->scale_length; + if (dx_scalar < (GRID_MIN_PX_D * 2.0)) continue; /* Store the smallest drawn grid size units name so users know how big each grid cell is */ if (*grid_unit == NULL) { *grid_unit = bUnit_GetNameDisplay(usys, i); - rv3d->gridview = (float)((scalar * v3d->grid) / (double)unit->scale_length); + rv3d->gridview = (float)((scalar * (double)v3d->grid) / (double)unit->scale_length); } - blend_fac = 1.0f - ((GRID_MIN_PX * 2.0f) / (float)dx_scalar); + blend_fac = 1.0f - ((GRID_MIN_PX_F * 2.0f) / (float)dx_scalar); /* tweak to have the fade a bit nicer */ blend_fac = (blend_fac * blend_fac) * 2.0f; @@ -341,25 +342,25 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** else { short sublines = v3d->gridsubdiv; - if (dx < GRID_MIN_PX) { + if (dx < GRID_MIN_PX_D) { rv3d->gridview *= sublines; dx *= sublines; - if (dx < GRID_MIN_PX) { + if (dx < GRID_MIN_PX_D) { rv3d->gridview *= sublines; dx *= sublines; - if (dx < GRID_MIN_PX) { + if (dx < GRID_MIN_PX_D) { rv3d->gridview *= sublines; dx *= sublines; - if (dx < GRID_MIN_PX) ; + if (dx < GRID_MIN_PX_D) ; else { UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx); } } else { // start blending out - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6.0f)); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX_D * 6.0)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); @@ -367,7 +368,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** } } else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10)) - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6.0f)); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX_D * 6.0)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); @@ -375,32 +376,32 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** } } else { - if (dx > (GRID_MIN_PX * 10)) { // start blending in + if (dx > (GRID_MIN_PX_D * 10.0)) { // start blending in rv3d->gridview /= sublines; dx /= sublines; - if (dx > (GRID_MIN_PX * 10)) { // start blending in + if (dx > (GRID_MIN_PX_D * 10.0)) { // start blending in rv3d->gridview /= sublines; dx /= sublines; - if (dx > (GRID_MIN_PX * 10)) { + if (dx > (GRID_MIN_PX_D * 10.0)) { UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx); } else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6)); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX_D * 6.0)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx * sublines); } } else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6)); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX_D * 6.0)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx * sublines); } } else { - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6)); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX_D * 6.0)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx * sublines); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index d9e4619fb59..1b06f42fd2c 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3722,9 +3722,9 @@ void flushTransGraphData(TransInfo *t) switch (sipo->autosnap) { case SACTSNAP_FRAME: /* snap to nearest frame (or second if drawing seconds) */ if (sipo->flag & SIPO_DRAWTIME) - td2d->loc[0] = floorf((td2d->loc[0] / secf) + 0.5) * secf; + td2d->loc[0] = floor(((double)td2d->loc[0] / secf) + 0.5) * secf; else - td2d->loc[0] = floorf(td2d->loc[0] + 0.5); + td2d->loc[0] = floor((double)td2d->loc[0] + 0.5); break; case SACTSNAP_MARKER: /* snap to nearest marker */ @@ -3732,7 +3732,7 @@ void flushTransGraphData(TransInfo *t) break; } } - + /* we need to unapply the nla-mapping from the time in some situations */ if (adt) td2d->loc2d[0]= BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP); |