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>2010-10-08 11:29:08 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-10-08 11:29:08 +0400
commit65b0893df0c82b04701f5f39c725df983c19f0c7 (patch)
tree7efc4126e852ead95ce7e3e5164b9dd6e14a567e /source/blender/blenlib/intern/math_rotation.c
parent5e232548d3d3362ba5f2af7807237bc7d6b672d6 (diff)
bugfix [#21483] Twisting when Dupliframing a Surface Circle (Nurbs) along a Curve.
use the curve's twist for follow path constraint and parent-path.
Diffstat (limited to 'source/blender/blenlib/intern/math_rotation.c')
-rw-r--r--source/blender/blenlib/intern/math_rotation.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index be383fdc73c..c4f12a5efc1 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1531,25 +1531,27 @@ void copy_dq_dq(DualQuat *dq1, DualQuat *dq2)
}
/* 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 */
-
+void quat_apply_track(float quat[4], short axis, short upflag)
+{
+ /* rotations are hard coded to match vec_to_quat */
+ const float quat_track[][4]= {{0.70710676908493, 0.0, -0.70710676908493, 0.0}, /* pos-y90 */
+ {0.5, 0.5, 0.5, 0.5}, /* Quaternion((1,0,0), radians(90)) * Quaternion((0,1,0), radians(90)) */
+ {0.70710676908493, 0.0, 0.0, 0.70710676908493}, /* pos-z90 */
+ {0.70710676908493, 0.0, 0.70710676908493, 0.0}, /* neg-y90 */
+ {0.5, -0.5, -0.5, 0.5}, /* Quaternion((1,0,0), radians(-90)) * Quaternion((0,1,0), radians(-90)) */
+ {1, 0, 0, 0}};/* no rotation */
+
mul_qt_qtqt(quat, quat, quat_track[axis]);
+
+ if(axis>2)
+ axis= axis-3;
+
+ /* 90d rotation when the second */
+ if(upflag != (2-axis)>>1) { // [0->1, 1->0, 2->0]
+ float q[4]= {0.70710676908493, 0, 0, 0};
+ q[axis+1] = ((axis==1)) ? 0.70710676908493 : -0.70710676908493; /* flip non Y axis */
+ mul_qt_qtqt(quat, quat, q);
+ }
}
void vec_apply_track(float vec[3], short axis)
@@ -1565,9 +1567,9 @@ void vec_apply_track(float vec[3], short axis)
vec[2]= -tvec[1];
break;
case 1: /* pos-y */
- vec[0]= tvec[2];
+ /* vec[0]= tvec[0]; */
/* vec[1]= 0.0; */
- vec[2]= -tvec[0];
+ /* vec[2]= tvec[2]; */
break;
case 2: /* pos-z */
vec[0]= tvec[1];
@@ -1580,12 +1582,12 @@ void vec_apply_track(float vec[3], short axis)
vec[2]= -tvec[2];
break;
case 4: /* neg-y */
- vec[0]= -tvec[0];
+ vec[0]= -tvec[2];
/* vec[1]= 0.0; */
- vec[2]= -tvec[2];
+ vec[2]= tvec[0];
break;
case 5: /* neg-z */
- vec[0]= tvec[0];
+ vec[0]= -tvec[0];
vec[1]= -tvec[1];
/* vec[2]= 0.0; */
break;