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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-10-08 06:08:11 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-10-08 06:08:11 +0400
commitc6e2e7aa9374427ae114fcc532e7f2c8a8977874 (patch)
treee3fde055e7b1dcd9f955c37d8df013a8abe71a75 /source
parentafa1bf33fb48db48fb909e4853094f2d962f8327 (diff)
move tracking functions into math_rotation.c (no functional changes)
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/lattice.c65
-rw-r--r--source/blender/blenlib/BLI_math_rotation.h3
-rw-r--r--source/blender/blenlib/intern/math_rotation.c62
3 files changed, 75 insertions, 55 deletions
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 1390f0dbd56..71e5049f2cc 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -599,16 +599,6 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
}
#endif
-
- static float q_x90d[4] = {0.70710676908493, 0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180));
- static float q_y90d[4] = {0.70710676908493, 0.0, 0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180));
- static float q_z90d[4] = {0.70710676908493, 0.0, 0.0, 0.70710676908493}; // float rot_axis[3]= {0,0,2}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180));
-
- static float q_nx90d[4] = {0.70710676908493, -0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180));
- static float q_ny90d[4] = {0.70710676908493, 0.0, -0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180));
- static float q_nz90d[4] = {0.70710676908493, 0.0, 0.0, -0.70710676908493}; // float rot_axis[3]= {0,0,2}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180));
-
-
if(cd->no_rot_axis) { /* set by caller */
/* this is not exactly the same as 2.4x, since the axis is having rotation removed rather then
@@ -635,53 +625,18 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
* Notice X,Y,Z Up all have light colors and each ordered CCW.
*
* Now for Neg Up XYZ, the colors are all dark, and ordered clockwise - Campbell
+ *
+ * note: moved functions into quat_apply_track/vec_apply_track
* */
+ copy_qt_qt(quat, new_quat);
+ copy_v3_v3(cent, co);
+
+ /* zero the axis which is not used,
+ * the big block of text above now applies to these 3 lines */
+ quat_apply_track(quat, axis-1);
+ vec_apply_track(cent, axis-1);
+ cent[axis < 4 ? axis-1 : axis-4]= 0.0f;
- switch(axis) {
- case MOD_CURVE_POSX:
- mul_qt_qtqt(quat, new_quat, q_y90d);
-
- cent[0]= 0.0;
- cent[1]= co[2];
- cent[2]= co[1];
- break;
- case MOD_CURVE_NEGX:
- mul_qt_qtqt(quat, new_quat, q_ny90d);
-
- cent[0]= 0.0;
- cent[1]= -co[1];
- cent[2]= co[2];
-
- break;
- case MOD_CURVE_POSY:
- mul_qt_qtqt(quat, new_quat, q_x90d);
-
- cent[0]= co[2];
- cent[1]= 0.0;
- cent[2]= -co[0];
- break;
- case MOD_CURVE_NEGY:
- mul_qt_qtqt(quat, new_quat, q_nx90d);
-
- cent[0]= -co[0];
- cent[1]= 0.0;
- cent[2]= -co[2];
- break;
- case MOD_CURVE_POSZ:
- mul_qt_qtqt(quat, new_quat, q_z90d);
-
- cent[0]= co[1];
- cent[1]= -co[0];
- cent[2]= 0.0;
- break;
- case MOD_CURVE_NEGZ:
- mul_qt_qtqt(quat, new_quat, q_nz90d);
-
- cent[0]= co[0];
- cent[1]= -co[1];
- cent[2]= 0.0;
- break;
- }
/* scale if enabled */
if(cu->flag & CU_PATH_RADIUS)
diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h
index 1b3f4dced02..4b33efc5578 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -169,6 +169,9 @@ void mul_v3m3_dq(float r[3], float R[3][3], DualQuat *dq);
void mat4_to_dquat(DualQuat *r, float base[4][4], float M[4][4]);
void dquat_to_mat4(float R[4][4], DualQuat *dq);
+void quat_apply_track(float quat[4], short axis);
+void vec_apply_track(float vec[3], short axis);
+
float lens_to_angle(float lens);
float angle_to_lens(float angle);
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index b8cef511293..4e555b02c2b 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1530,6 +1530,68 @@ void copy_dq_dq(DualQuat *dq1, DualQuat *dq2)
memcpy(dq1, dq2, sizeof(DualQuat));
}
+/* axis matches eTrackToAxis_Modes */
+void quat_apply_track(float quat[4], short axis)
+{
+ /* axis calculated as follows */
+ /* float axis[3]= {1,0,0}; axis_angle_to_quat(q, axis, 90 * (M_PI / 180));
+ float axis[3]= {0,1,0}; axis_angle_to_quat(q, axis, 90 * (M_PI / 180));
+ float axis[3]= {0,0,2}; axis_angle_to_quat(q, axis, 90 * (M_PI / 180));
+ float axis[3]= {1,0,0}; axis_angle_to_quat(q, axis, -90 * (M_PI / 180));
+ float axis[3]= {0,1,0}; axis_angle_to_quat(q, axis, -90 * (M_PI / 180));
+ float axis[3]= {0,0,2}; axis_angle_to_quat(q, axis, -90 * (M_PI / 180)); */
+
+ /* notice x/y flipped intentionally */
+ const float quat_track[][4]= {{0.70710676908493, 0.0, 0.70710676908493, 0.0}, /* pos-y */
+ {0.70710676908493, 0.70710676908493, 0.0, 0.0}, /* pos-x */
+ {0.70710676908493, 0.0, 0.0, 0.70710676908493}, /* pos-z */
+ {0.70710676908493, 0.0, -0.70710676908493, 0.0}, /* neg-y */
+ {0.70710676908493, -0.70710676908493, 0.0, 0.0}, /* neg-x */
+ {0.70710676908493, 0.0, 0.0, -0.70710676908493}};/* neg-z */
+
+ mul_qt_qtqt(quat, quat, quat_track[axis]);
+}
+
+void vec_apply_track(float vec[3], short axis)
+{
+ float tvec[3];
+
+ copy_v3_v3(tvec, vec);
+
+ switch(axis) {
+ case 0: /* pos-x */
+ /* vec[0]= 0.0; */
+ vec[1]= tvec[2];
+ vec[2]= tvec[1];
+ break;
+ case 1: /* pos-y */
+ vec[0]= tvec[2];
+ /* vec[1]= 0.0; */
+ vec[2]= -tvec[0];
+ break;
+ case 2: /* pos-z */
+ vec[0]= tvec[1];
+ vec[1]= -tvec[0];
+ // vec[2]= 0.0; */
+ break;
+ case 3: /* neg-x */
+ /* vec[0]= 0.0; */
+ vec[1]= -tvec[1];
+ vec[2]= tvec[2];
+ break;
+ case 4: /* neg-y */
+ vec[0]= -tvec[0];
+ /* vec[1]= 0.0; */
+ vec[2]= -tvec[2];
+ break;
+ case 5: /* neg-z */
+ vec[0]= tvec[0];
+ vec[1]= -tvec[1];
+ /* vec[2]= 0.0; */
+ break;
+ }
+}
+
/* lense/angle conversion (radians) */
float lens_to_angle(float lens)
{