Compiler warning: double-promotion

This commit is contained in:
Campbell Barton 2015-01-31 17:23:30 +11:00
parent 535de7ec1f
commit 9e9cd77b8d
41 changed files with 94 additions and 92 deletions

View File

@ -2206,7 +2206,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
float range = bulge_max - 1.0f;
float scale = (range > 0.0f) ? 1.0f / range : 0.0f;
float soft = 1.0f + range * atanf((bulge - 1.0f) * scale) / (0.5f * M_PI);
float soft = 1.0f + range * atanf((bulge - 1.0f) * scale) / (float)M_PI_2;
bulge = interpf(soft, hard, ikData->bulge_smooth);
}
@ -2218,7 +2218,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
float range = 1.0f - bulge_min;
float scale = (range > 0.0f) ? 1.0f / range : 0.0f;
float soft = 1.0f - range * atanf((1.0f - bulge) * scale) / (0.5f * M_PI);
float soft = 1.0f - range * atanf((1.0f - bulge) * scale) / (float)M_PI_2;
bulge = interpf(soft, hard, ikData->bulge_smooth);
}

View File

@ -2715,7 +2715,7 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
float range = bulge_max - 1.0f;
float scale = (range > 0.0f) ? 1.0f / range : 0.0f;
float soft = 1.0f + range * atanf((bulge - 1.0f) * scale) / (0.5f * M_PI);
float soft = 1.0f + range * atanf((bulge - 1.0f) * scale) / (float)M_PI_2;
bulge = interpf(soft, hard, data->bulge_smooth);
}
@ -2727,7 +2727,7 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
float range = 1.0f - bulge_min;
float scale = (range > 0.0f) ? 1.0f / range : 0.0f;
float soft = 1.0f - range * atanf((1.0f - bulge) * scale) / (0.5f * M_PI);
float soft = 1.0f - range * atanf((1.0f - bulge) * scale) / (float)M_PI_2;
bulge = interpf(soft, hard, data->bulge_smooth);
}

View File

@ -1742,7 +1742,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
/* half a circle */
fp = dl->verts;
dangle = (0.5 * M_PI / (dnr - 1));
dangle = ((float)M_PI_2 / (dnr - 1));
angle = -(nr - 1) * dangle;
for (a = 0; a < nr; a++) {
@ -1801,7 +1801,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
/* half a circle */
fp = dl->verts;
angle = 0.0;
dangle = (0.5 * M_PI / (dnr - 1));
dangle = ((float)M_PI_2 / (dnr - 1));
for (a = 0; a < nr; a++) {
fp[0] = 0.0;
@ -1943,7 +1943,7 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2,
t02 = x1 * x2 + y1 * y2;
if (fabsf(t02) >= 1.0f)
t02 = 0.5 * M_PI;
t02 = M_PI_2;
else
t02 = (saacos(t02)) / 2.0f;
@ -2476,7 +2476,7 @@ static void make_bevel_list_2D(BevList *bl)
/* first */
bevp = bl->bevpoints;
angle = atan2f(bevp->dir[0], bevp->dir[1]) - (float)(M_PI / 2.0f);
angle = atan2f(bevp->dir[0], bevp->dir[1]) - (float)M_PI_2;
bevp->sina = sinf(angle);
bevp->cosa = cosf(angle);
vec_to_quat(bevp->quat, bevp->dir, 5, 1);
@ -2484,7 +2484,7 @@ static void make_bevel_list_2D(BevList *bl)
/* last */
bevp = bl->bevpoints;
bevp += (bl->nr - 1);
angle = atan2f(bevp->dir[0], bevp->dir[1]) - (float)(M_PI / 2.0f);
angle = atan2f(bevp->dir[0], bevp->dir[1]) - (float)M_PI_2;
bevp->sina = sinf(angle);
bevp->cosa = cosf(angle);
vec_to_quat(bevp->quat, bevp->dir, 5, 1);

View File

@ -4059,8 +4059,8 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
normalize_v3(nor);
/* make sure that we get a proper side vector */
if (fabsf(dot_v3v3(nor, vec)) > 0.999999) {
if (fabsf(dot_v3v3(nor, xvec)) > 0.999999) {
if (fabsf(dot_v3v3(nor, vec)) > 0.999999f) {
if (fabsf(dot_v3v3(nor, xvec)) > 0.999999f) {
nor[0] = 0.0f;
nor[1] = 1.0f;
nor[2] = 0.0f;

View File

@ -138,14 +138,15 @@ static void do_kink_spiral_deform(ParticleKey *state, const float dir[3], const
* and goes up to the Golden Spiral for 1.0
* http://en.wikipedia.org/wiki/Golden_spiral
*/
const float b = shape * (1.0f + sqrtf(5.0f)) / M_PI * 0.25f;
const float b = shape * (1.0f + sqrtf(5.0f)) / (float)M_PI * 0.25f;
/* angle of the spiral against the curve (rotated opposite to make a smooth transition) */
const float start_angle = (b != 0.0f ? atanf(1.0f / b) : -M_PI*0.5f) + (b > 0.0f ? -M_PI*0.5f : M_PI*0.5f);
const float start_angle = ((b != 0.0f) ? atanf(1.0f / b) :
(float)-M_PI_2) + (b > 0.0f ? -(float)M_PI_2 : (float)M_PI_2);
float spiral_axis[3], rot[3][3];
float vec[3];
float theta = freq * time * 2.0f*M_PI;
float theta = freq * time * 2.0f * (float)M_PI;
float radius = amplitude * expf(b * theta);
/* a bit more intuitive than using negative frequency for this */
@ -269,7 +270,7 @@ static void do_kink_spiral(ParticleThreadContext *ctx, ParticleTexture *ptex, co
normalize_v3(kink);
if (kink_axis_random > 0.0f) {
float a = kink_axis_random * (psys_frand(ctx->sim.psys, 7112 + seed) * 2.0f - 1.0f) * M_PI;
float a = kink_axis_random * (psys_frand(ctx->sim.psys, 7112 + seed) * 2.0f - 1.0f) * (float)M_PI;
float rot[3][3];
axis_angle_normalized_to_mat3(rot, dir, a);

View File

@ -760,7 +760,7 @@ void default_mtex(MTex *mtex)
mtex->fieldfac = 1.0f;
mtex->normapspace = MTEX_NSPACE_TANGENT;
mtex->brush_map_mode = MTEX_MAP_MODE_TILED;
mtex->random_angle = 2.0f * M_PI;
mtex->random_angle = 2.0f * (float)M_PI;
mtex->brush_angle_mode = 0;
}

View File

@ -451,8 +451,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
br->mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
}
br->mtex.random_angle = 2.0f * M_PI;
br->mask_mtex.random_angle = 2.0f * M_PI;
br->mtex.random_angle = 2.0 * M_PI;
br->mask_mtex.random_angle = 2.0 * M_PI;
}
#undef BRUSH_RAKE

View File

@ -475,7 +475,7 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op)
{
BMOpSlot *einput = BMO_slot_get(op->slots_in, "edges");
BMOpSlot *vinput = BMO_slot_get(op->slots_in, "verts");
const float angle_max = (float)M_PI / 2.0f;
const float angle_max = M_PI_2;
const float angle_limit = min_ff(angle_max, BMO_slot_float_get(op->slots_in, "angle_limit"));
const bool do_dissolve_boundaries = BMO_slot_bool_get(op->slots_in, "use_dissolve_boundaries");
const BMO_Delimit delimit = BMO_slot_int_get(op->slots_in, "delimit");

View File

@ -608,10 +608,10 @@ static void calc_solidify_normals(BMesh *bm)
}
else {
/* only one face attached to that edge */
/* an edge without another attached- the weight on this is
* undefined, M_PI / 2 is 90d in radians and that seems good enough */
/* an edge without another attached- the weight on this is undefined,
* M_PI_2 is 90d in radians and that seems good enough */
copy_v3_v3(edge_normal, f1->no);
mul_v3_fl(edge_normal, M_PI / 2);
mul_v3_fl(edge_normal, M_PI_2);
}
add_v3_v3(e->v1->no, edge_normal);

View File

@ -529,7 +529,7 @@ static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op,
const float dist = BMO_slot_float_get(op->slots_in, "dist");
const float dist_sq = dist * dist;
const float dist3 = (M_SQRT3 + 0.00005f) * dist; /* Just above sqrt(3) */
const float dist3 = ((float)M_SQRT3 + 0.00005f) * dist; /* Just above sqrt(3) */
/* Test whether keep_verts arg exists and is non-empty */
if (BMO_slot_exists(op->slots_in, "keep_verts")) {

View File

@ -412,10 +412,10 @@ void bmo_similar_edges_exec(BMesh *bm, BMOperator *op)
/* compute the angle between the two edges */
angle = angle_normalized_v3v3(e_ext[i].dir, e_ext[indices[idx]].dir);
if (angle > (float)(M_PI / 2.0)) /* use the smallest angle between the edges */
if (angle > (float)M_PI_2) /* use the smallest angle between the edges */
angle = fabsf(angle - (float)M_PI);
if (angle / (float)(M_PI / 2.0) <= thresh) {
if (angle / (float)M_PI_2 <= thresh) {
BMO_elem_flag_enable(bm, e, EDGE_MARK);
cont = false;
}

View File

@ -541,7 +541,7 @@ static void bm_isect_tri_tri(
if (((1 << i_b_e0) | (1 << i_b_e1)) & b_mask)
continue;
fac = line_point_factor_v3(fv_a[i_a]->co, fv_b[i_b_e0]->co, fv_b[i_b_e1]->co);
if ((fac > 0.0f - s->epsilon.eps) && (fac < 1.0 + s->epsilon.eps)) {
if ((fac > 0.0f - s->epsilon.eps) && (fac < 1.0f + s->epsilon.eps)) {
float ix[3];
interp_v3_v3v3(ix, fv_b[i_b_e0]->co, fv_b[i_b_e1]->co, fac);
if (len_squared_v3v3(ix, fv_a[i_a]->co) <= s->epsilon.eps2x_sq) {
@ -579,7 +579,7 @@ static void bm_isect_tri_tri(
if (((1 << i_a_e0) | (1 << i_a_e1)) & a_mask)
continue;
fac = line_point_factor_v3(fv_b[i_b]->co, fv_a[i_a_e0]->co, fv_a[i_a_e1]->co);
if ((fac > 0.0 - s->epsilon.eps) && (fac < 1.0 + s->epsilon.eps)) {
if ((fac > 0.0f - s->epsilon.eps) && (fac < 1.0f + s->epsilon.eps)) {
float ix[3];
interp_v3_v3v3(ix, fv_a[i_a_e0]->co, fv_a[i_a_e1]->co, fac);
if (len_squared_v3v3(ix, fv_b[i_b]->co) <= s->epsilon.eps2x_sq) {

View File

@ -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

View File

@ -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 */

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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) {

View File

@ -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':

View File

@ -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]);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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) {

View File

@ -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));

View File

@ -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);

View File

@ -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);

View File

@ -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]);

View File

@ -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) {

View File

@ -3207,7 +3207,7 @@ static void rna_def_scene_game_recast_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "slope_max", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "agentmaxslope");
RNA_def_property_range(prop, 0, M_PI / 2);
RNA_def_property_range(prop, 0, M_PI_2);
RNA_def_property_ui_text(prop, "Max Slope", "Maximum walkable slope angle");
RNA_def_property_update(prop, NC_SCENE, NULL);

View File

@ -201,7 +201,7 @@ static void dm_mvert_map_doubles(
const float dist,
const bool with_follow)
{
const float dist3 = (M_SQRT3 + 0.00005f) * dist; /* Just above sqrt(3) */
const float dist3 = ((float)M_SQRT3 + 0.00005f) * dist; /* Just above sqrt(3) */
int i_source, i_target, i_target_low_bound, target_end, source_end;
SortVertsElem *sorted_verts_target, *sorted_verts_source;
SortVertsElem *sve_source, *sve_target, *sve_target_low_bound;

View File

@ -466,13 +466,13 @@ static void validate_solution(LaplacianSystem *sys, short flag, float lambda, fl
if (sys->zerola[i] == 0) {
lam = sys->numNeEd[i] == sys->numNeFa[i] ? (lambda >= 0.0f ? 1.0f : -1.0f) : (lambda_border >= 0.0f ? 1.0f : -1.0f);
if (flag & MOD_LAPLACIANSMOOTH_X) {
sys->vertexCos[i][0] += lam * (nlGetVariable(0, i) - sys->vertexCos[i][0]);
sys->vertexCos[i][0] += lam * ((float)nlGetVariable(0, i) - sys->vertexCos[i][0]);
}
if (flag & MOD_LAPLACIANSMOOTH_Y) {
sys->vertexCos[i][1] += lam * (nlGetVariable(1, i) - sys->vertexCos[i][1]);
sys->vertexCos[i][1] += lam * ((float)nlGetVariable(1, i) - sys->vertexCos[i][1]);
}
if (flag & MOD_LAPLACIANSMOOTH_Z) {
sys->vertexCos[i][2] += lam * (nlGetVariable(2, i) - sys->vertexCos[i][2]);
sys->vertexCos[i][2] += lam * ((float)nlGetVariable(2, i) - sys->vertexCos[i][2]);
}
}
}

View File

@ -48,9 +48,9 @@ static void node_shader_exec_gamma(void *UNUSED(data), int UNUSED(thread), bNode
nodestack_get_vec(col, SOCK_VECTOR, in[0]);
nodestack_get_vec(&gamma, SOCK_FLOAT, in[1]);
out[0]->vec[0] = col[0] > 0.0 ? pow(col[0], gamma) : col[0];
out[0]->vec[1] = col[1] > 0.0 ? pow(col[1], gamma) : col[1];
out[0]->vec[2] = col[2] > 0.0 ? pow(col[2], gamma) : col[2];
out[0]->vec[0] = col[0] > 0.0f ? powf(col[0], gamma) : col[0];
out[0]->vec[1] = col[1] > 0.0f ? powf(col[1], gamma) : col[1];
out[0]->vec[2] = col[2] > 0.0f ? powf(col[2], gamma) : col[2];
}
static int node_shader_gpu_gamma(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)

View File

@ -941,7 +941,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z,
result->status = conjgrad_loopcount < conjgrad_looplimit ? BPH_SOLVER_SUCCESS : BPH_SOLVER_NO_CONVERGENCE;
result->iterations = conjgrad_loopcount;
result->error = bnorm2 > 0.0f ? sqrt(delta_new / bnorm2) : 0.0f;
result->error = bnorm2 > 0.0f ? sqrtf(delta_new / bnorm2) : 0.0f;
return conjgrad_loopcount < conjgrad_looplimit; // true means we reached desired accuracy in given time - ie stable
}
@ -1470,8 +1470,8 @@ static void edge_wind_vertex(const float dir[3], float length, float radius, con
/* angle of wind direction to edge */
cos_alpha = dot_v3v3(wind, dir) / windlen;
sin_alpha = sqrt(1.0 - cos_alpha*cos_alpha);
cross_section = radius * (M_PI * radius * sin_alpha + length * cos_alpha);
sin_alpha = sqrtf(1.0f - cos_alpha * cos_alpha);
cross_section = radius * ((float)M_PI * radius * sin_alpha + length * cos_alpha);
mul_v3_v3fl(f, wind, density * cross_section);
}

View File

@ -157,7 +157,7 @@ float RE_filter_value(int type, float x)
{
const float two_gaussfac2 = 2.0f * gaussfac * gaussfac;
x *= 3.0f * gaussfac;
return 1.0f / sqrtf(M_PI * two_gaussfac2) * expf(-x*x / two_gaussfac2);
return 1.0f / sqrtf((float)M_PI * two_gaussfac2) * expf(-x*x / two_gaussfac2);
}
case R_FILTER_MITCH:

View File

@ -155,7 +155,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3])
x = max_ff(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2]));
/* 1.0/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */
inpr = 1.0 / (sqrtf(1.0f + x * x));
inpr = 1.0f / (sqrtf(1.0f + x * x));
}
else inpr= 0.0;
}
@ -201,7 +201,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3])
/* dot product and reflectivity*/
inp = 1.0 - fabsf(dot_v3v3(vn, lv));
inp = 1.0f - fabsf(dot_v3v3(vn, lv));
/* inp= cos(0.5*M_PI-acos(inp)); */
@ -361,7 +361,7 @@ int shadeHaloFloat(HaloRen *har, float col[4], int zz,
else dist= dist/har->radsq;
if (har->type & HA_FLARECIRC) {
dist = 0.5 + fabsf(dist - 0.5f);
dist = 0.5f + fabsf(dist - 0.5f);
}
if (har->hard>=30) {

View File

@ -1273,7 +1273,7 @@ static float get_avg_speed(ShadeInput *shi)
post_x = (shi->winspeed[2] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[2];
post_y = (shi->winspeed[3] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[3];
speedavg = (sqrtf(pre_x * pre_x + pre_y * pre_y) + sqrtf(post_x * post_x + post_y * post_y)) / 2.0;
speedavg = (sqrtf(pre_x * pre_x + pre_y * pre_y) + sqrtf(post_x * post_x + post_y * post_y)) / 2.0f;
return speedavg;
}

View File

@ -220,10 +220,10 @@ static int blend(Tex *tex, const float texvec[3], TexResult *texres)
texres->tin= (2.0f+x+y)/4.0f;
}
else if (tex->stype==TEX_RAD) { /* radial */
texres->tin = (atan2f(y, x) / (2 * M_PI) + 0.5f);
texres->tin = (atan2f(y, x) / (float)(2 * M_PI) + 0.5f);
}
else { /* sphere TEX_SPHERE */
texres->tin = 1.0 - sqrtf(x * x + y * y + texvec[2] * texvec[2]);
texres->tin = 1.0f - sqrtf(x * x + y * y + texvec[2] * texvec[2]);
if (texres->tin<0.0f) texres->tin= 0.0f;
if (tex->stype==TEX_HALO) texres->tin*= texres->tin; /* halo */
}
@ -274,7 +274,7 @@ static int clouds(Tex *tex, const float texvec[3], TexResult *texres)
/* creates a sine wave */
static float tex_sin(float a)
{
a = 0.5 + 0.5 * sinf(a);
a = 0.5f + 0.5f * sinf(a);
return a;
}

View File

@ -254,14 +254,14 @@ void GetSkyXYZRadiance(struct SunSky *sunsky, float theta, float phi, float colo
float hfade = 1, nfade = 1;
if (theta > (0.5f * (float)M_PI)) {
if (theta > (float)M_PI_2) {
hfade = 1.0f - (theta * (float)M_1_PI - 0.5f) * 2.0f;
hfade = hfade * hfade * (3.0f - 2.0f * hfade);
theta = 0.5 * M_PI;
theta = M_PI_2;
}
if (sunsky->theta > (0.5f * (float)M_PI)) {
if (theta <= 0.5f * (float)M_PI) {
if (sunsky->theta > (float)M_PI_2) {
if (theta <= (float)M_PI_2) {
nfade = 1.0f - (0.5f - theta * (float)M_1_PI) * 2.0f;
nfade *= 1.0f - (sunsky->theta * (float)M_1_PI - 0.5f) * 2.0f;
nfade = nfade * nfade * (3.0f - 2.0f * nfade);

View File

@ -4423,7 +4423,7 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even
if (snap) new_value = ((int)ceil(new_value * 10.f) * 10.0f) / 100.f;
break;
case PROP_ANGLE:
new_value = atan2f(delta[1], delta[0]) + M_PI + angle_precision;
new_value = atan2f(delta[1], delta[0]) + (float)M_PI + angle_precision;
new_value = fmod(new_value, 2.0f * (float)M_PI);
if (new_value < 0.0f)
new_value += 2.0f * (float)M_PI;