@@ -32,7 +32,6 @@ SOFTWARE.
3232#include < algorithm>
3333#include " twistSplineUtils.h"
3434
35-
3635/* *
3736 * A helper function for quickly finding a single index and segment percentage for an input tValue
3837 *
@@ -118,12 +117,6 @@ void multiLinearIndexes(const std::vector<Float> ¶ms, const std::vector<Floa
118117 }
119118}
120119
121-
122-
123-
124-
125-
126-
127120/* *
128121 * A Spline segment is a 4 vertex cubic bezier spline. Each segment is independent of the others, and
129122 * segment interdependency will be handled by a setup or rig.
@@ -581,19 +574,18 @@ class TwistSplineSegment {
581574 * linearly interpolating between startAngle and endAngle
582575 */
583576 void applyTwist (Float startAngle, Float endAngle){ // inRadians
584- startAngle *= -1 ;
585- endAngle *= -1 ;
577+ startAngle *= -1 ;
578+ endAngle *= -1 ;
586579
587580 resize (tnormals, size (rnormals));
588581 resize (tbinormals, size (rbinormals));
589582 twistVals.resize (size (rnormals));
590583
591-
592584 Float len = getLength ();
593585
594586 for (IndexType i=0 ; i <= lutSteps; ++i){
595587 Float perc = sampleLengths[i] / len; // parameterize by length
596- Float angle = ((endAngle - startAngle) * perc) + startAngle;
588+ Float angle = ((endAngle - startAngle) * perc) + startAngle;
597589 twistVals[i] = angle;
598590 const Vector &x = rnormals[i];
599591 const Vector &y = rbinormals[i];
@@ -612,17 +604,8 @@ class TwistSplineSegment {
612604 tbinormals[i] = cross (n, tnormals[i]);
613605 }
614606 }
615-
616607};
617608
618-
619-
620-
621-
622-
623-
624-
625-
626609// For later:
627610// I'll bet I can check the derivatives of the spline
628611// to find where it's even possible to be closer, and turn a closest
@@ -665,8 +648,6 @@ class TwistSpline {
665648 std::vector<Float> getRemap () const { return remap; }
666649 Float getTotalLength () const { return totalLength; }
667650
668-
669-
670651 // / Copy constructor
671652 TwistSpline (TwistSpline const &old){
672653 this ->verts = old.verts ;
@@ -884,7 +865,6 @@ class TwistSpline {
884865 solveTwist ();
885866 }
886867
887-
888868 /* *
889869 * Solve the locks of a parameter of the spline
890870 * Build a tridiagonal matrix that represents each vertex param as a relation to its neighbor params
@@ -973,7 +953,6 @@ class TwistSpline {
973953 solveTridiagonalMatrix (mat, res);
974954 }
975955
976-
977956 /* *
978957 * Solve a tridiagonal matrix in linear time
979958 * If you set up parameter values in a specific way, they can be thought of as a matrix
@@ -1062,6 +1041,26 @@ class TwistSpline {
10621041 std::vector<Float> oriMap;
10631042 solveTwistParamMatrix (orientVals, segLens, orientLocks, oriMap);
10641043
1044+ // Add an euler filter to the ori map.
1045+ Float tau = 6.283185307179586477 ;
1046+ Float pi = 3.141592653589793238 ;
1047+ for (size_t i = 1 ; i < oriMap.size (); ++i){
1048+ Float diff = oriMap[i] - oriMap[i - 1 ];
1049+ Float sign = 1.0 ;
1050+ if (diff < 0.0 ){
1051+ diff *= -1.0 ;
1052+ sign = -1.0 ;
1053+ }
1054+
1055+ int count = 0 ;
1056+ for (; count < 10 ; ++count){
1057+ if (diff < pi){
1058+ break ;
1059+ }
1060+ diff -= tau;
1061+ }
1062+ oriMap[i] -= count * sign * tau;
1063+ }
10651064 std::vector<Float> twistMap;
10661065 solveTwistParamMatrix (userTwists, segLens, twistLocks, twistMap);
10671066
0 commit comments