[Bf-blender-cvs] [b8b4122] master: Code Cleanup: use iroundf
Campbell Barton
noreply at git.blender.org
Wed Jan 15 03:42:31 CET 2014
Commit: b8b412230b1e1ed43295d5c299477a2cba73355e
Author: Campbell Barton
Date: Wed Jan 15 13:00:03 2014 +1100
https://developer.blender.org/rBb8b412230b1e1ed43295d5c299477a2cba73355e
Code Cleanup: use iroundf
also increase precision of rctf print functions
===================================================================
M source/blender/blenlib/intern/rct.c
M source/blender/editors/animation/anim_markers.c
M source/blender/editors/animation/anim_ops.c
M source/blender/editors/armature/pose_slide.c
M source/blender/editors/gpencil/drawgpencil.c
M source/blender/editors/interface/interface_handlers.c
M source/blender/editors/interface/interface_panel.c
M source/blender/editors/screen/glutil.c
M source/blender/editors/space_action/action_edit.c
M source/blender/editors/space_clip/clip_ops.c
M source/blender/editors/space_graph/graph_edit.c
M source/blender/editors/space_graph/graph_ops.c
M source/blender/editors/transform/transform_conversions.c
M source/blender/modifiers/intern/MOD_meshcache_util.c
M source/blender/render/intern/source/imagetexture.c
M source/blender/windowmanager/intern/wm_gesture.c
===================================================================
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index c59a019..51bd9ee 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -552,7 +552,7 @@ void BLI_rctf_rcti_copy(rctf *dst, const rcti *src)
void print_rctf(const char *str, const rctf *rect)
{
- printf("%s: xmin %.3f, xmax %.3f, ymin %.3f, ymax %.3f (%.3fx%.3f)\n", str,
+ printf("%s: xmin %.8f, xmax %.8f, ymin %.8f, ymax %.8f (%.12fx%.12f)\n", str,
rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_rctf_size_x(rect), BLI_rctf_size_y(rect));
}
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index e65ca3d..f95807b 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -144,7 +144,7 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f
(side == 'L' && marker->frame < cfra) ||
(side == 'R' && marker->frame >= cfra))
{
- marker->frame += (int)floorf(value + 0.5f);
+ marker->frame += iroundf(value);
changed_tot++;
}
break;
@@ -152,7 +152,7 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f
case TFM_TIME_SCALE:
{
/* rescale the distance between the marker and the current frame */
- marker->frame = cfra + (int)floorf(((float)(marker->frame - cfra) * value) + 0.5f);
+ marker->frame = cfra + iroundf((float)(marker->frame - cfra) * value);
changed_tot++;
break;
}
@@ -190,7 +190,7 @@ TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x)
int ED_markers_find_nearest_marker_time(ListBase *markers, float x)
{
TimeMarker *nearest = ED_markers_find_nearest_marker(markers, x);
- return (nearest) ? (nearest->frame) : (int)floor(x + 0.5f);
+ return (nearest) ? (nearest->frame) : iroundf(x);
}
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index af9b587..48b310b 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -35,6 +35,7 @@
#include "BLI_sys_types.h"
#include "BLI_utildefines.h"
+#include "BLI_math_base.h"
#include "DNA_anim_types.h"
#include "DNA_scene_types.h"
@@ -126,7 +127,7 @@ static int frame_from_event(bContext *C, const wmEvent *event)
UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], &viewx, NULL);
/* round result to nearest int (frames are ints!) */
- frame = (int)floor(viewx + 0.5f);
+ frame = iroundf(viewx);
if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) {
CLAMP(frame, PSFRA, PEFRA);
@@ -223,8 +224,8 @@ static int previewrange_define_exec(bContext *C, wmOperator *op)
if (efra < sfra) efra = sfra;
scene->r.flag |= SCER_PRV_RANGE;
- scene->r.psfra = (int)floor(sfra + 0.5f);
- scene->r.pefra = (int)floor(efra + 0.5f);
+ scene->r.psfra = iroundf(sfra);
+ scene->r.pefra = iroundf(efra);
/* send notifiers */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 8265270..ec49dad 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -1129,7 +1129,7 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
/* stop on matching marker if there is one */
for (ce = modeData.sel_markers.first; ce; ce = ce->next) {
- if (ce->cfra == (int)(floor(bezt->vec[1][0] + 0.5f)))
+ if (ce->cfra == iroundf(bezt->vec[1][0]))
break;
}
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 294a509..971ab4d 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -784,10 +784,10 @@ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, bool only3d)
rctf rectf;
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &rectf, TRUE); /* no shift */
- offsx = floorf(rectf.xmin + 0.5f);
- offsy = floorf(rectf.ymin + 0.5f);
- winx = floorf((rectf.xmax - rectf.xmin) + 0.5f);
- winy = floorf((rectf.ymax - rectf.ymin) + 0.5f);
+ offsx = iroundf(rectf.xmin);
+ offsy = iroundf(rectf.ymin);
+ winx = iroundf(rectf.xmax - rectf.xmin);
+ winy = iroundf(rectf.ymax - rectf.ymin);
}
else {
offsx = 0;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index ae45666..2e02e44 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3660,7 +3660,7 @@ static int ui_do_but_LISTBOX(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
int newsize = *size;
int diff = dragy - my;
- diff = (int)floorf(((float)diff / (float)UI_UNIT_Y) + 0.5f);
+ diff = iroundf((float)diff / (float)UI_UNIT_Y);
/* If we are not in autosize mode, default behavior... */
if (*size > 0) {
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index bc257e8..054f113 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -821,8 +821,8 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
for (a = 0; a < tot; a++, ps++) {
if ((ps->pa->flag & PNL_SELECT) == 0) {
if ((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->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);
+ ps->orig->ofsx = iroundf(fac * (float)ps->pa->ofsx + (1.0f - fac) * (float)ps->orig->ofsx);
+ ps->orig->ofsy = iroundf(fac * (float)ps->pa->ofsy + (1.0f - fac) * (float)ps->orig->ofsy);
done = true;
}
}
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 9cdb6de..123ca68 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -874,7 +874,7 @@ void bglBegin(int mode)
glGetFloatv(GL_POINT_SIZE_RANGE, value);
if (value[1] < 2.0f) {
glGetFloatv(GL_POINT_SIZE, value);
- pointhack = floor(value[0] + 0.5f);
+ pointhack = iroundf(value[0]);
if (pointhack > 4) pointhack = 4;
}
else {
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 7142a63..e2ca45b 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -337,8 +337,8 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
/* set the range directly */
get_keyframe_extents(&ac, &min, &max, FALSE);
scene->r.flag |= SCER_PRV_RANGE;
- scene->r.psfra = (int)floor(min + 0.5f);
- scene->r.pefra = (int)floor(max + 0.5f);
+ scene->r.psfra = iroundf(min);
+ scene->r.pefra = iroundf(max);
/* set notifier that things have changed */
// XXX err... there's nothing for frame ranges yet, but this should do fine too
@@ -1372,7 +1372,7 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
/* set the new current frame value, based on the average time */
if (ked.i1) {
Scene *scene = ac.scene;
- CFRA = (int)floor((ked.f1 / ked.i1) + 0.5f);
+ CFRA = iroundf(ked.f1 / ked.i1);
SUBFRA = 0.f;
}
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 9aa6eab..e02fca8 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -868,7 +868,7 @@ static int frame_from_event(bContext *C, const wmEvent *event)
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy);
- framenr = (int) floor(viewx + 0.5f);
+ framenr = iroundf(viewx);
}
return framenr;
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 0f3ba98..68d82cd 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -189,8 +189,8 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
/* set the range directly */
get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, FALSE, FALSE);
scene->r.flag |= SCER_PRV_RANGE;
- scene->r.psfra = (int)floor(min + 0.5f);
- scene->r.pefra = (int)floor(max + 0.5f);
+ scene->r.psfra = iroundf(min);
+ scene->r.pefra = iroundf(max);
/* set notifier that things have changed */
// XXX err... there's nothing for frame ranges yet, but this should do fine too
@@ -1825,7 +1825,7 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = ac.scene;
/* take the average values, rounding to the nearest int for the current frame */
- CFRA = (int)floor((ked.f1 / ked.i1) + 0.5f);
+ CFRA = iroundf(ked.f1 / ked.i1);
SUBFRA = 0.f;
sipo->cursorVal = ked.f2 / (float)ked.i1;
}
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 74114f8..4409a5b 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -37,6 +37,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLI_math_base.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -123,7 +124,7 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, const wmEvent
/* store the values in the operator properties */
/* frame is rounded to the nearest int, since frames are ints */
- RNA_int_set(op->ptr, "frame", (int)floor(viewx + 0.5f));
+ RNA_int_set(op->ptr, "frame", iroundf(viewx));
RNA_float_set(op->ptr, "value", viewy);
}
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 2b8e57f..d19bf8d 100644
--- a/source/blend
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list