diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-01-31 09:23:30 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-01-31 17:17:21 +0300 |
commit | 9e9cd77b8de68015a98659671272cc9d78710e69 (patch) | |
tree | a705baa2b3d4c2667085815c865a826c1f884173 /source/blender/editors | |
parent | 535de7ec1fee94eae1769630b512c6ef4eb5bcad (diff) |
Compiler warning: double-promotion
Diffstat (limited to 'source/blender/editors')
18 files changed, 42 insertions, 41 deletions
diff --git a/source/blender/editors/include/BIF_gl.h b/source/blender/editors/include/BIF_gl.h index b06af01bab6..3b7d7bac44f 100644 --- a/source/blender/editors/include/BIF_gl.h +++ b/source/blender/editors/include/BIF_gl.h @@ -35,10 +35,6 @@ #include "GPU_glew.h" -/* hacking pointsize and linewidth */ -#define glPointSize(f) glPointSize(U.pixelsize * (f)) -#define glLineWidth(f) glLineWidth(U.pixelsize * (f)) - /* * these should be phased out. cpack should be replaced in * code with calls to glColor3ub. - zr @@ -51,7 +47,6 @@ * */ void cpack(unsigned int x); - #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) # define glMultMatrixf(x) \ glMultMatrixf(_Generic((x), \ @@ -71,9 +66,14 @@ void cpack(unsigned int x); float (*)[4]: (float *)(x), \ float [4][4]: (float *)(x)) \ ) +/* hacking pointsize and linewidth */ +#define glPointSize(f) glPointSize(U.pixelsize * _Generic((f), double: (float)(f), default: (f))) +#define glLineWidth(f) glLineWidth(U.pixelsize * _Generic((f), double: (float)(f), default: (f))) #else # define glMultMatrixf(x) glMultMatrixf((float *)(x)) # define glLoadMatrixf(x) glLoadMatrixf((float *)(x)) +#define glPointSize(f) glPointSize(U.pixelsize * (f)) +#define glLineWidth(f) glLineWidth(U.pixelsize * (f)) #endif #define GLA_PIXEL_OFS 0.375f diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 5c5bd2c7584..e03ea5efba4 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -822,8 +822,8 @@ static void vectorscope_draw_target(float centerx, float centery, float diam, co if (u > 0 && v >= 0) tangle = atanf(v / u); 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; + else if (u == 0 && v > 0.0f) tangle = M_PI_2; + else if (u == 0 && v < 0.0f) tangle = -M_PI_2; tampli = sqrtf(u * u + v * v); /* small target vary by 2.5 degree and 2.5 IRE unit */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 4b62d16a982..96973194576 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -8906,7 +8906,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle block->pie_data.duration_gesture = duration; } - if (len_sq < 1.0) { + if (len_sq < 1.0f) { uiBut *but = ui_but_find_active_in_region(menu->region); if (but) { diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index d0637a23a70..d165e2719c5 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1490,7 +1490,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) } BLF_enable(fontid, BLF_ROTATION); - BLF_rotation(fontid, M_PI / 2); + BLF_rotation(fontid, M_PI_2); //UI_fontstyle_set(&style->widget); ui_fontscale(&fstyle_points, aspect / (U.pixelsize * 1.1f)); BLF_size(fontid, fstyle_points, U.dpi); diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index c42c911cd5c..2f46c0906ae 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -224,7 +224,7 @@ void UI_fontstyle_draw_rotated(const uiFontStyle *fs, const rcti *rect, const ch /* rotate counter-clockwise for now (assumes left-to-right language)*/ xofs += height; yofs = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX) + 5; - angle = (float)M_PI / 2.0f; + angle = M_PI_2; /* translate rect to vertical */ txtrect.xmin = rect->xmin - BLI_rcti_size_y(rect); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index f1a495f248f..9b22f8a1e7f 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2210,7 +2210,7 @@ void ui_hsvcircle_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f; float ang, radius_t; - ang = 2.0f * (float)M_PI * hsv[0] + 0.5f * (float)M_PI; + ang = 2.0f * (float)M_PI * hsv[0] + (float)M_PI_2; if ((but->flag & UI_BUT_COLOR_CUBIC) && (U.color_picker_type == USER_CP_CIRCLE_HSV)) radius_t = (1.0f - pow3f(1.0f - hsv[1])); @@ -3007,11 +3007,8 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat float height = rect->ymax - rect->ymin; /* find color luminance and change it slightly */ float bw = rgb_to_bw(col); - - if (bw > 0.5) - bw -= 0.5; - else - bw += 0.5; + + bw += (bw < 0.5f) ? 0.5f : -0.5f; glColor4f(bw, bw, bw, 1.0); glBegin(GL_TRIANGLES); @@ -3947,7 +3944,7 @@ void ui_draw_pie_center(uiBlock *block) int subd = 40; float angle = atan2f(pie_dir[1], pie_dir[0]); - float range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? ((float)M_PI / 2.0f) : ((float)M_PI / 4.0f); + float range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_2 : M_PI_4; glPushMatrix(); glTranslatef(cx, cy, 0.0f); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index de46d47e5a3..12ee3199f43 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1851,7 +1851,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v /* draw vertical steps */ if (dfac > 0.0f) { - BLF_rotation_default(M_PI / 2); + BLF_rotation_default(M_PI_2); BLF_enable_default(BLF_ROTATION); for (; fac < vert.ymax - 10; fac += dfac, val += grid->dy) { diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index c3edd63b2d4..2fde09570c0 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -162,14 +162,13 @@ void ED_object_rotation_from_view(bContext *C, float rot[3], const char align_ax BLI_assert(align_axis >= 'X' && align_axis <= 'Z'); if (rv3d) { - const float pi_2 = (float)M_PI / 2.0f; float quat[4]; switch (align_axis) { case 'X': { float quat_y[4]; - axis_angle_to_quat(quat_y, rv3d->viewinv[1], -pi_2); + axis_angle_to_quat(quat_y, rv3d->viewinv[1], -M_PI_2); mul_qt_qtqt(quat, rv3d->viewquat, quat_y); quat[0] = -quat[0]; @@ -182,7 +181,7 @@ void ED_object_rotation_from_view(bContext *C, float rot[3], const char align_ax quat[0] = -quat[0]; quat_to_eul(rot, quat); - rot[0] -= pi_2; + rot[0] -= (float)M_PI_2; break; } case 'Z': diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 79bf8c893df..59568789a1b 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -290,7 +290,7 @@ static bool paint_brush_update(bContext *C, ups->anchored_size = ups->pixel_radius = sqrtf(dx * dx + dy * dy); - ups->brush_rotation = ups->brush_rotation_sec = atan2f(dx, dy) + M_PI; + ups->brush_rotation = ups->brush_rotation_sec = atan2f(dx, dy) + (float)M_PI; if (brush->flag & BRUSH_EDGE_TO_EDGE) { halfway[0] = dx * 0.5f + stroke->initial_mouse[0]; @@ -999,7 +999,8 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str return false; } -static void paint_stroke_line_constrain (bContext *C, PaintStroke *stroke, float mouse[2]) { +static void paint_stroke_line_constrain (bContext *C, PaintStroke *stroke, float mouse[2]) +{ if (stroke->constrain_line) { wmWindow *win = CTX_wm_window(C); ARegion *ar = CTX_wm_region(C); @@ -1011,20 +1012,20 @@ static void paint_stroke_line_constrain (bContext *C, PaintStroke *stroke, float len = len_v2(line); /* divide angle by PI/8 */ - angle = 4.0 * angle / M_PI; + angle = 4.0f * angle / (float)M_PI; /* now take residue, if less than */ - res = angle - floor(angle); + res = angle - floorf(angle); - if (res <= 0.5) { - angle = floor(angle) * M_PI / 4.0; + if (res <= 0.5f) { + angle = floorf(angle) * (float)M_PI_4; } else { - angle = (floor(angle) + 1.0) * M_PI / 4.0; + angle = (floorf(angle) + 1.0f) * (float)M_PI_4; } - line[0] = len * cos(angle) + stroke->last_mouse_position[0] + ar->winrct.xmin; - line[1] = len * sin(angle) + stroke->last_mouse_position[1] + ar->winrct.ymin; + line[0] = len * cosf(angle) + stroke->last_mouse_position[0] + ar->winrct.xmin; + line[1] = len * sinf(angle) + stroke->last_mouse_position[1] + ar->winrct.ymin; WM_cursor_warp(win, line[0], line[1]); } diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 9093734f25f..2d8a0a3da29 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -848,11 +848,13 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) * NOTE: we need to scale the y-values to be valid for the units */ glBegin(GL_LINES); + { t = v2d->cur.xmin; glVertex2f(t, t * unitfac); t = v2d->cur.xmax; glVertex2f(t, t * unitfac); + } glEnd(); /* cleanup line drawing */ @@ -875,6 +877,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) setlinestyle(5); glBegin(GL_LINES); + { /* x-axis lookup */ co[0] = x; @@ -894,6 +897,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) co[0] = x; glVertex2fv(co); + } glEnd(); setlinestyle(0); diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c index 57c81e919e5..c8834d394f5 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview.c +++ b/source/blender/editors/space_sequencer/sequencer_preview.c @@ -117,7 +117,7 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p BLI_freelinkN(&pj->previews, previewjb); previewjb = preview_next; pj->processed++; - *progress = (pj->total > 0) ? (float)pj->processed / (float)pj->total : 1.0; + *progress = (pj->total > 0) ? (float)pj->processed / (float)pj->total : 1.0f; *do_update = true; BLI_mutex_unlock(pj->mutex); } diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 691da78f26b..f33f074e6c5 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1619,7 +1619,7 @@ static void draw_pose_dofs(Object *ob) for (a = -16; a <= 16; a++) { /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ float fac = ((float)a) / 16.0f * 0.5f; - phi = (float)(0.5 * M_PI) + fac * (pchan->limitmax[0] - pchan->limitmin[0]); + phi = (float)M_PI_2 + fac * (pchan->limitmax[0] - pchan->limitmin[0]); i = (a == -16) ? 2 : 3; corner[i][0] = 0.0f; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index b8107834782..67c6eb405d7 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2822,7 +2822,7 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar, bool { /* clear background */ if (scene->world && ((v3d->flag3 & V3D_SHOW_WORLD) || force)) { - float alpha = (force) ? 1.0f : 0.0; + float alpha = (force) ? 1.0f : 0.0f; bool glsl = GPU_glsl_support() && BKE_scene_use_new_shading_nodes(scene) && scene->world->nodetree && scene->world->use_nodes; if (glsl) { diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 4b1d99b6165..7a1cd88ba49 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1034,7 +1034,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) * - of rotation is linearly proportional * - to the distance that the mouse is * - dragged. */ - phi = si * (float)(M_PI / 2.0); + phi = si * (float)M_PI_2; q1[0] = cosf(phi); mul_v3_fl(q1 + 1, sinf(phi)); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 5df348408df..0457f5f2d52 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -344,8 +344,8 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_all", NDOF_MOTION, 0, KM_CTRL | KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_selected", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "use_all_regions", false); - RNA_float_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", NDOF_BUTTON_ROLL_CCW, KM_PRESS, 0, 0)->ptr, "angle", M_PI / -2); - RNA_float_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", NDOF_BUTTON_ROLL_CW, KM_PRESS, 0, 0)->ptr, "angle", M_PI / 2); + RNA_float_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", NDOF_BUTTON_ROLL_CCW, KM_PRESS, 0, 0)->ptr, "angle", -M_PI_2); + RNA_float_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", NDOF_BUTTON_ROLL_CW, KM_PRESS, 0, 0)->ptr, "angle", M_PI_2); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT); diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index d8f17315c01..ccb81c7342b 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -208,7 +208,7 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3], viewAxisCorrectCenter(t, t_con_center); angle = fabsf(angle_v3v3(axis, t->viewinv[2])); - if (angle > (float)M_PI / 2.0f) { + if (angle > (float)M_PI_2) { angle = (float)M_PI - angle; } angle = RAD2DEGF(angle); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index f2869843dd5..38190d407ab 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -177,7 +177,7 @@ static void axis_angle_to_gimbal_axis(float gmat[3][3], const float axis[3], con mul_qt_v3(quat, gmat[0]); /* Y-axis */ - axis_angle_to_quat(quat, axis, M_PI / 2.0); + axis_angle_to_quat(quat, axis, M_PI_2); copy_v3_v3(gmat[1], gmat[0]); mul_qt_v3(quat, gmat[1]); diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 569fe1c326d..00615f9bef7 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -2672,8 +2672,8 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart) } for (i = 0; i < ninterior; i++) { - sys->lambdaPlanar[i] += nlGetVariable(0, i); - sys->lambdaLength[i] += nlGetVariable(0, ninterior + i); + sys->lambdaPlanar[i] += (float)nlGetVariable(0, i); + sys->lambdaLength[i] += (float)nlGetVariable(0, ninterior + i); } } @@ -4561,7 +4561,7 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate) box->index = i; /* warning this index skips PCHART_NOPACK boxes */ if (margin > 0.0f) - area += sqrtf(box->w * box->h); + area += (double)sqrtf(box->w * box->h); } if (margin > 0.0f) { |