From 2804caff4ce6c9f6d5ebdd101e77c92b7ac65db4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Apr 2013 04:22:38 +0000 Subject: code cleanup: use bools, (float)sin/(float)cos -> sinf/cosf, more meaningful var names. --- source/blender/blenkernel/intern/constraint.c | 4 +-- source/blender/blenkernel/intern/mball.c | 9 ++++--- source/blender/blenkernel/intern/object.c | 4 +-- source/blender/blenlib/intern/math_rotation.c | 10 ++++---- .../blender/editors/interface/interface_regions.c | 10 ++++---- source/blender/editors/space_view3d/drawarmature.c | 12 ++++----- source/blender/editors/space_view3d/view3d_edit.c | 17 +++++++------ source/blender/editors/transform/transform.c | 4 +-- .../editors/transform/transform_manipulator.c | 29 ++++++++++++---------- 9 files changed, 53 insertions(+), 46 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 4d9f0fc769c..12fa16e3273 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1204,8 +1204,8 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra vec_to_quat(quat, dir, (short)data->trackflag, (short)data->upflag); normalize_v3(dir); - q[0] = (float)cos(0.5 * vec[3]); - x1 = (float)sin(0.5 * vec[3]); + q[0] = cosf(0.5 * vec[3]); + x1 = sinf(0.5 * vec[3]); q[1] = -x1 * dir[0]; q[2] = -x1 * dir[1]; q[3] = -x1 * dir[2]; diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 72284130869..b93d924ddf9 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -1426,7 +1426,8 @@ static void converge(const float p1[3], const float p2[3], float v1, float v2, while (1) { if (i++ == RES) return; p[0] = 0.5f * (pos[0] + neg[0]); - if ((function(p[0], p[1], p[2])) > 0.0f) pos[0] = p[0]; else neg[0] = p[0]; + if ((function(p[0], p[1], p[2])) > 0.0f) pos[0] = p[0]; + else neg[0] = p[0]; } } @@ -1436,7 +1437,8 @@ static void converge(const float p1[3], const float p2[3], float v1, float v2, while (1) { if (i++ == RES) return; p[1] = 0.5f * (pos[1] + neg[1]); - if ((function(p[0], p[1], p[2])) > 0.0f) pos[1] = p[1]; else neg[1] = p[1]; + if ((function(p[0], p[1], p[2])) > 0.0f) pos[1] = p[1]; + else neg[1] = p[1]; } } @@ -1446,7 +1448,8 @@ static void converge(const float p1[3], const float p2[3], float v1, float v2, while (1) { if (i++ == RES) return; p[2] = 0.5f * (pos[2] + neg[2]); - if ((function(p[0], p[1], p[2])) > 0.0f) pos[2] = p[2]; else neg[2] = p[2]; + if ((function(p[0], p[1], p[2])) > 0.0f) pos[2] = p[2]; + else neg[2] = p[2]; } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index c2e3d7496e9..5e0ed369733 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1837,8 +1837,8 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4]) /* the tilt */ normalize_v3(dir); - q[0] = (float)cos(0.5 * vec[3]); - si = (float)sin(0.5 * vec[3]); + q[0] = cosf(0.5 * vec[3]); + si = sinf(0.5 * vec[3]); q[1] = -si * dir[0]; q[2] = -si * dir[1]; q[3] = -si * dir[2]; diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 26576b2dcb2..cf9280d418f 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -539,9 +539,9 @@ void QuatInterpolW(float *result, float quat1[4], float quat2[4], float t) if ((1.0f - cosom) > 0.0001f) { omega = (float)acos(cosom); - sinom = (float)sin(omega); - sc1 = (float)sin((1.0 - t) * omega) / sinom; - sc2 = (float)sin(t * omega) / sinom; + sinom = sinf(omega); + sc1 = sinf((1.0 - t) * omega) / sinom; + sc2 = sinf(t * omega) / sinom; } else { sc1 = 1.0f - t; @@ -558,8 +558,8 @@ void QuatInterpolW(float *result, float quat1[4], float quat2[4], float t) result[2] = quat2[1]; result[3] = -quat2[0]; - sc1 = (float)sin((1.0 - t) * M_PI_2); - sc2 = (float)sin(t * M_PI_2); + sc1 = sinf((1.0 - t) * M_PI_2); + sc2 = sinf(t * M_PI_2); result[0] = sc1 * quat1[0] + sc2 * result[0]; result[1] = sc1 * quat1[1] + sc2 * result[1]; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 8d7edf1b044..2ccba2e35f0 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -742,8 +742,8 @@ typedef struct uiSearchboxData { uiFontStyle fstyle; uiSearchItems items; int active; /* index in items array */ - int noback; /* when menu opened with enough space for this */ - int preview; /* draw thumbnail previews, rather than list */ + bool noback; /* when menu opened with enough space for this */ + bool preview; /* draw thumbnail previews, rather than list */ int prv_rows, prv_cols; } uiSearchboxData; @@ -1023,7 +1023,7 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) /* pixel space */ wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f); - if (!data->noback) + if (data->noback == false) ui_draw_search_back(NULL, NULL, &data->bbox); /* style not used yet */ /* draw text */ @@ -1136,10 +1136,10 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) /* special case, hardcoded feature, not draw backdrop when called from menus, * assume for design that popup already added it */ if (but->block->flag & UI_BLOCK_SEARCH_MENU) - data->noback = 1; + data->noback = true; if (but->a1 > 0 && but->a2 > 0) { - data->preview = 1; + data->preview = true; data->prv_rows = but->a1; data->prv_cols = but->a2; } diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index cb685b59b64..2ff52b51069 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1573,8 +1573,8 @@ static void draw_pose_dofs(Object *ob) for (i = 0; i < 3; i++) { /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ - amin[i] = (float)sin(pchan->limitmin[i] * 0.5f); - amax[i] = (float)sin(pchan->limitmax[i] * 0.5f); + amin[i] = sinf(pchan->limitmin[i] * 0.5f); + amax[i] = sinf(pchan->limitmax[i] * 0.5f); } glScalef(1.0f, -1.0f, 1.0f); @@ -1605,8 +1605,8 @@ static void draw_pose_dofs(Object *ob) phi = fac * (pchan->limitmax[2] - pchan->limitmin[2]); i = (a == -16) ? 0 : 1; - corner[i][0] = (float)sin(phi); - corner[i][1] = (float)cos(phi); + corner[i][0] = sinf(phi); + corner[i][1] = cosf(phi); corner[i][2] = 0.0f; glVertex3fv(corner[i]); } @@ -1629,8 +1629,8 @@ static void draw_pose_dofs(Object *ob) i = (a == -16) ? 2 : 3; corner[i][0] = 0.0f; - corner[i][1] = (float)sin(phi); - corner[i][2] = (float)cos(phi); + corner[i][1] = sinf(phi); + corner[i][2] = cosf(phi); glVertex3fv(corner[i]); } glEnd(); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 9dbdd8a9789..cbbc342bb6e 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -365,7 +365,8 @@ typedef struct ViewOpsData { float viewquat[4]; /* working copy of rv3d->viewquat */ float trackvec[3]; float mousevec[3]; /* dolly only */ - float reverse, dist0, camzoom0; + float reverse; + float dist_prev, camzoom_prev; float grid, far; bool axis_snap; /* view rotate only */ float zfac; @@ -425,8 +426,8 @@ static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *even * we may want to make this optional but for now its needed always */ ED_view3d_camera_lock_init(vod->v3d, vod->rv3d); - vod->dist0 = rv3d->dist; - vod->camzoom0 = rv3d->camzoom; + vod->dist_prev = rv3d->dist; + vod->camzoom_prev = rv3d->camzoom; copy_qt_qt(vod->viewquat, rv3d->viewquat); copy_qt_qt(vod->oldquat, rv3d->viewquat); vod->origx = vod->oldx = event->x; @@ -484,7 +485,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *even /* find a new ofs value that is along the view axis (rather than the mouse location) */ closest_to_line_v3(dvec, vod->dyn_ofs, my_pivot, my_origin); - vod->dist0 = rv3d->dist = len_v3v3(my_pivot, dvec); + vod->dist_prev = rv3d->dist = len_v3v3(my_pivot, dvec); negate_v3_v3(rv3d->ofs, dvec); } @@ -1711,7 +1712,7 @@ static void viewzoom_apply(ViewOpsData *vod, const int x, const int y, const sho if (use_cam_zoom) { float delta; delta = (x - vod->origx + y - vod->origy) / 10.0f; - vod->rv3d->camzoom = vod->camzoom0 + (zoom_invert ? -delta : delta); + vod->rv3d->camzoom = vod->camzoom_prev + (zoom_invert ? -delta : delta); CLAMP(vod->rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); } @@ -1746,7 +1747,7 @@ static void viewzoom_apply(ViewOpsData *vod, const int x, const int y, const sho len1 = (int)sqrt((ctr[0] - x) * (ctr[0] - x) + (ctr[1] - y) * (ctr[1] - y)) + 5; len2 = (int)sqrt((ctr[0] - vod->origx) * (ctr[0] - vod->origx) + (ctr[1] - vod->origy) * (ctr[1] - vod->origy)) + 5; - zfac = vod->dist0 * ((float)len2 / len1) / vod->rv3d->dist; + zfac = vod->dist_prev * ((float)len2 / len1) / vod->rv3d->dist; } else { /* USER_ZOOM_DOLLY */ float len1, len2; @@ -1766,11 +1767,11 @@ static void viewzoom_apply(ViewOpsData *vod, const int x, const int y, const sho if (use_cam_zoom) { /* zfac is ignored in this case, see below */ #if 0 - zfac = vod->camzoom0 * (2.0f * ((len1 / len2) - 1.0f) + 1.0f) / vod->rv3d->camzoom; + zfac = vod->camzoom_prev * (2.0f * ((len1 / len2) - 1.0f) + 1.0f) / vod->rv3d->camzoom; #endif } else { - zfac = vod->dist0 * (2.0f * ((len1 / len2) - 1.0f) + 1.0f) / vod->rv3d->dist; + zfac = vod->dist_prev * (2.0f * ((len1 / len2) - 1.0f) + 1.0f) / vod->rv3d->dist; } } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 64e49abd761..a6da770ed97 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2757,8 +2757,8 @@ int Warp(TransInfo *t, const int UNUSED(mval[2])) vec[1] = (vec[1] - cursor[1]); - co = (float)cos(phi0); - si = (float)sin(phi0); + co = cosf(phi0); + si = sinf(phi0); loc[0] = -si * vec[1] + cursor[0]; loc[1] = co * vec[1] + cursor[1]; loc[2] = vec[2]; diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 41a3418ada9..36a64303156 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -719,13 +719,13 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i side_delta = 2.0f * (float)M_PI / (float)nsides; theta = (float)M_PI + 0.5f * ring_delta; - cos_theta = (float)cos(theta); - sin_theta = (float)sin(theta); + cos_theta = cosf(theta); + sin_theta = sinf(theta); for (i = nrings - 1; i >= 0; i--) { theta1 = theta + ring_delta; - cos_theta1 = (float)cos(theta1); - sin_theta1 = (float)sin(theta1); + cos_theta1 = cosf(theta1); + sin_theta1 = sinf(theta1); if (do_caps && i == start) { // cap glBegin(GL_POLYGON); @@ -766,8 +766,8 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i float cos_phi, sin_phi, dist; phi -= side_delta; - cos_phi = (float)cos(phi); - sin_phi = (float)sin(phi); + cos_phi = cosf(phi); + sin_phi = sinf(phi); dist = radhole + radring * cos_phi; glVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi); @@ -1635,15 +1635,18 @@ void BIF_draw_manipulator(const bContext *C) switch (v3d->around) { case V3D_CENTER: case V3D_ACTIVE: - rv3d->twmat[3][0] = (scene->twmin[0] + scene->twmax[0]) / 2.0f; - rv3d->twmat[3][1] = (scene->twmin[1] + scene->twmax[1]) / 2.0f; - rv3d->twmat[3][2] = (scene->twmin[2] + scene->twmax[2]) / 2.0f; - if (v3d->around == V3D_ACTIVE && scene->obedit == NULL) { - Object *ob = OBACT; - if (ob && !(ob->mode & OB_MODE_POSE)) - copy_v3_v3(rv3d->twmat[3], ob->obmat[3]); + { + Object *ob; + if (((v3d->around == V3D_ACTIVE) && (scene->obedit == NULL)) && + ((ob = OBACT) && !(ob->mode & OB_MODE_POSE))) + { + copy_v3_v3(rv3d->twmat[3], ob->obmat[3]); + } + else { + mid_v3_v3v3(rv3d->twmat[3], scene->twmin, scene->twmax); } break; + } case V3D_LOCAL: case V3D_CENTROID: copy_v3_v3(rv3d->twmat[3], scene->twcent); -- cgit v1.2.3