Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-03-27 05:16:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-27 05:17:30 +0300
commit9ba948a4859da3308033fa6dc54f74433d7e6a21 (patch)
tree0bd6e95eb59d9af03aa32d925c68e1cbebecc246 /source/blender/blenlib/intern/math_rotation.c
parent337eb8c1de4c57c34520b467d79779153335eecb (diff)
Cleanup: style, use braces for blenlib
Diffstat (limited to 'source/blender/blenlib/intern/math_rotation.c')
-rw-r--r--source/blender/blenlib/intern/math_rotation.c86
1 files changed, 55 insertions, 31 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 5f6bbcce3b3..90eb76f19d9 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -137,8 +137,9 @@ void invert_qt(float q[4])
{
const float f = dot_qtqt(q, q);
- if (f == 0.0f)
+ if (f == 0.0f) {
return;
+ }
conjugate_qt(q);
mul_qt_fl(q, 1.0f / f);
@@ -671,8 +672,9 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
nor[1] = -tvec[2];
nor[2] = tvec[1];
- if (fabsf(tvec[1]) + fabsf(tvec[2]) < eps)
+ if (fabsf(tvec[1]) + fabsf(tvec[2]) < eps) {
nor[1] = 1.0f;
+ }
co = tvec[0];
}
@@ -681,8 +683,9 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
nor[1] = 0.0;
nor[2] = -tvec[0];
- if (fabsf(tvec[0]) + fabsf(tvec[2]) < eps)
+ if (fabsf(tvec[0]) + fabsf(tvec[2]) < eps) {
nor[2] = 1.0f;
+ }
co = tvec[1];
}
@@ -691,8 +694,9 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
nor[1] = tvec[0];
nor[2] = 0.0;
- if (fabsf(tvec[0]) + fabsf(tvec[1]) < eps)
+ if (fabsf(tvec[0]) + fabsf(tvec[1]) < eps) {
nor[0] = 1.0f;
+ }
co = tvec[2];
}
@@ -709,16 +713,16 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
quat_to_mat3(mat, q);
if (axis == 0) {
- if (upflag == 1) angle = 0.5f * atan2f(fp[2], fp[1]);
- else angle = -0.5f * atan2f(fp[1], fp[2]);
+ if (upflag == 1) { angle = 0.5f * atan2f(fp[2], fp[1]); }
+ else { angle = -0.5f * atan2f(fp[1], fp[2]); }
}
else if (axis == 1) {
- if (upflag == 0) angle = -0.5f * atan2f(fp[2], fp[0]);
- else angle = 0.5f * atan2f(fp[0], fp[2]);
+ if (upflag == 0) { angle = -0.5f * atan2f(fp[2], fp[0]); }
+ else { angle = 0.5f * atan2f(fp[0], fp[2]); }
}
else {
- if (upflag == 0) angle = 0.5f * atan2f(-fp[1], -fp[0]);
- else angle = -0.5f * atan2f(-fp[0], -fp[1]);
+ if (upflag == 0) { angle = 0.5f * atan2f(-fp[1], -fp[0]); }
+ else { angle = -0.5f * atan2f(-fp[0], -fp[1]); }
}
co = cosf(angle);
@@ -954,8 +958,9 @@ void quat_to_axis_angle(float axis[3], float *angle, const float q[4])
*angle = ha * 2;
/* prevent division by zero for axis conversion */
- if (fabsf(si) < 0.0005f)
+ if (fabsf(si) < 0.0005f) {
si = 1.0f;
+ }
axis[0] = q[1] / si;
axis[1] = q[2] / si;
@@ -1380,9 +1385,15 @@ void rotate_eul(float beul[3], const char axis, const float ang)
assert(axis >= 'X' && axis <= 'Z');
eul[0] = eul[1] = eul[2] = 0.0f;
- if (axis == 'X') eul[0] = ang;
- else if (axis == 'Y') eul[1] = ang;
- else eul[2] = ang;
+ if (axis == 'X') {
+ eul[0] = ang;
+ }
+ else if (axis == 'Y') {
+ eul[1] = ang;
+ }
+ else {
+ eul[2] = ang;
+ }
eul_to_mat3(mat1, eul);
eul_to_mat3(mat2, beul);
@@ -1418,16 +1429,16 @@ void compatible_eul(float eul[3], const float oldrot[3])
/* is 1 of the axis rotations larger than 180 degrees and the other small? NO ELSE IF!! */
if (fabsf(deul[0]) > 3.2f && fabsf(deul[1]) < 1.6f && fabsf(deul[2]) < 1.6f) {
- if (deul[0] > 0.0f) eul[0] -= pi_x2;
- else eul[0] += pi_x2;
+ if (deul[0] > 0.0f) { eul[0] -= pi_x2; }
+ else { eul[0] += pi_x2; }
}
if (fabsf(deul[1]) > 3.2f && fabsf(deul[2]) < 1.6f && fabsf(deul[0]) < 1.6f) {
- if (deul[1] > 0.0f) eul[1] -= pi_x2;
- else eul[1] += pi_x2;
+ if (deul[1] > 0.0f) { eul[1] -= pi_x2; }
+ else { eul[1] += pi_x2; }
}
if (fabsf(deul[2]) > 3.2f && fabsf(deul[0]) < 1.6f && fabsf(deul[1]) < 1.6f) {
- if (deul[2] > 0.0f) eul[2] -= pi_x2;
- else eul[2] += pi_x2;
+ if (deul[2] > 0.0f) { eul[2] -= pi_x2; }
+ else { eul[2] += pi_x2; }
}
}
@@ -1506,12 +1517,15 @@ static const RotOrderInfo rotOrders[] = {
static const RotOrderInfo *get_rotation_order_info(const short order)
{
assert(order >= 0 && order <= 6);
- if (order < 1)
+ if (order < 1) {
return &rotOrders[0];
- else if (order < 6)
+ }
+ else if (order < 6) {
return &rotOrders[order - 1];
- else
+ }
+ else {
return &rotOrders[5];
+ }
}
/* Construct quaternion from Euler angles (in radians). */
@@ -1547,7 +1561,9 @@ void eulO_to_quat(float q[4], const float e[3], const short order)
q[2] = (float)(a[1]);
q[3] = (float)(a[2]);
- if (R->parity) q[j + 1] = -q[j + 1];
+ if (R->parity) {
+ q[j + 1] = -q[j + 1];
+ }
}
/* Convert quaternion to Euler angles (in radians). */
@@ -1761,12 +1777,15 @@ void rotate_eulO(float beul[3], const short order, char axis, float ang)
zero_v3(eul);
- if (axis == 'X')
+ if (axis == 'X') {
eul[0] = ang;
- else if (axis == 'Y')
+ }
+ else if (axis == 'Y') {
eul[1] = ang;
- else
+ }
+ else {
eul[2] = ang;
+ }
eulO_to_mat3(mat1, eul, order);
eulO_to_mat3(mat2, beul, order);
@@ -1943,8 +1962,10 @@ void add_weighted_dq_dq(DualQuat *dqsum, const DualQuat *dq, float weight)
if (dq->scale_weight) {
float wmat[4][4];
- if (flipped) /* we don't want negative weights for scaling */
+ if (flipped) {
+ /* we don't want negative weights for scaling */
weight = -weight;
+ }
copy_m4_m4(wmat, (float(*)[4])dq->scale);
mul_m4_fl(wmat, weight);
@@ -1995,8 +2016,9 @@ void mul_v3m3_dq(float co[3], float mat[3][3], DualQuat *dq)
M[2][2] = w * w + z * z - x * x - y * y;
len2 = dot_qtqt(dq->quat, dq->quat);
- if (len2 > 0.0f)
+ if (len2 > 0.0f) {
len2 = 1.0f / len2;
+ }
/* translation */
t[0] = 2 * (-t0 * x + w * t1 - t2 * z + y * t3);
@@ -2004,8 +2026,9 @@ void mul_v3m3_dq(float co[3], float mat[3][3], DualQuat *dq)
t[2] = 2 * (-t0 * z + x * t2 + w * t3 - t1 * y);
/* apply scaling */
- if (dq->scale_weight)
+ if (dq->scale_weight) {
mul_m4_v3(dq->scale, co);
+ }
/* apply rotation and translation */
mul_m3_v3(M, co);
@@ -2019,8 +2042,9 @@ void mul_v3m3_dq(float co[3], float mat[3][3], DualQuat *dq)
copy_m3_m4(scalemat, dq->scale);
mul_m3_m3m3(mat, M, scalemat);
}
- else
+ else {
copy_m3_m3(mat, M);
+ }
mul_m3_fl(mat, len2);
}
}