code cleanup: use bools, (float)sin/(float)cos -> sinf/cosf, more meaningful var names.
This commit is contained in:
@@ -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];
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user