diff options
Diffstat (limited to 'src/Skeleton.cpp')
-rw-r--r-- | src/Skeleton.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/Skeleton.cpp b/src/Skeleton.cpp index dc5cdf8..6925fb6 100644 --- a/src/Skeleton.cpp +++ b/src/Skeleton.cpp @@ -34,10 +34,8 @@ void Joint::DoConstraint() if(hasparent){ //Find midpoint midp=(position+parent->position)/2; - //Find vector from midpoint to second vector - vel=parent->position-midp; - //Change to unit vector - Normalise(&vel); + // Find vector from midpoint to second vector + vel = normalize(parent->position - midp); //Apply velocity change velocity+=((midp-vel*length/2)-position); parent->velocity+=((midp+vel*length/2)-parent->position); @@ -69,10 +67,8 @@ void Muscle::DoConstraint(int broken) //Find midpoint midp=(parent1->position+parent2->position)/2; - //Find vector from midpoint to second vector - vel=parent2->position-midp; - //Change to unit vector - Normalise(&vel); + // Find vector from midpoint to second vector + vel = normalize(parent2->position - midp); //Apply velocity change newpoint1=midp-vel*length/2; newpoint2=midp+vel*length/2; @@ -137,7 +133,7 @@ void Skeleton::DoConstraints(Model *collide, XYZ *move, float rotation) && collide->normals[whichtri].y <= 0.8) { normalrotated = DoRotation(collide->normals[whichtri], 0, rotation, 0); pos = impact + normalrotated * offset; - ReflectVector(&joints[i].velocity, &normalrotated); + reflect(&joints[i].velocity, normalrotated); joints[i].velocity *= 0.3; } @@ -284,7 +280,7 @@ void Skeleton::FindRotationJoint(int which) tempforward=DoRotation(tempforward,0,joints[which].rotate1-90,0); tempforward=DoRotation(tempforward,0,0,joints[which].rotate2-90); tempforward.y=0; - Normalise(&tempforward); + tempforward = normalize(tempforward); joints[which].rotate3=acos(0-tempforward.z)*rad2deg; if(0>tempforward.x)joints[which].rotate3=360-joints[which].rotate3; } @@ -313,7 +309,7 @@ void Skeleton::FindRotationMuscle(int which) tempforward=DoRotation(tempforward,0,muscles[which].rotate1-90,0); tempforward=DoRotation(tempforward,0,0,muscles[which].rotate2-90); tempforward.y=0; - Normalise(&tempforward); + tempforward = normalize(tempforward); muscles[which].rotate3=acos(0-tempforward.z)*rad2deg; for (auto& joint : joints) if (&joint == muscles[which].parent1) { @@ -344,11 +340,15 @@ void Animation::load(const char* name) for (int i = 0; i < max_joints; ++i) testskeleton.joints[i].position = position[i][j]; //Find forward vectors - CrossProduct(testskeleton.joints[testskeleton.forwardjoints[1]].position-testskeleton.joints[testskeleton.forwardjoints[0]].position,testskeleton.joints[testskeleton.forwardjoints[2]].position-testskeleton.joints[testskeleton.forwardjoints[0]].position,&testskeleton.forward); - Normalise(&testskeleton.forward); + testskeleton.forward = normalize(crossProduct(testskeleton.joints[testskeleton.forwardjoints[1]].position + - testskeleton.joints[testskeleton.forwardjoints[0]].position, + testskeleton.joints[testskeleton.forwardjoints[2]].position + - testskeleton.joints[testskeleton.forwardjoints[0]].position)); - CrossProduct(testskeleton.joints[testskeleton.lowforwardjoints[1]].position-testskeleton.joints[testskeleton.lowforwardjoints[0]].position,testskeleton.joints[testskeleton.lowforwardjoints[2]].position-testskeleton.joints[testskeleton.lowforwardjoints[0]].position,&testskeleton.lowforward); - Normalise(&testskeleton.lowforward); + testskeleton.lowforward = normalize(crossProduct(testskeleton.joints[testskeleton.lowforwardjoints[1]].position + - testskeleton.joints[testskeleton.lowforwardjoints[0]].position, + testskeleton.joints[testskeleton.lowforwardjoints[2]].position + - testskeleton.joints[testskeleton.lowforwardjoints[0]].position)); //Special forwards testskeleton.specialforward[0]=testskeleton.forward; @@ -356,20 +356,20 @@ void Animation::load(const char* name) testskeleton.specialforward[1]=testskeleton.joints[rightshoulder].position+testskeleton.joints[rightwrist].position; testskeleton.specialforward[1]=testskeleton.joints[rightelbow].position-testskeleton.specialforward[1]/2; testskeleton.specialforward[1]+=testskeleton.forward*.2; - Normalise(&testskeleton.specialforward[1]); + testskeleton.specialforward[1] = normalize(testskeleton.specialforward[1]); testskeleton.specialforward[2]=testskeleton.joints[leftshoulder].position+testskeleton.joints[leftwrist].position; testskeleton.specialforward[2]=testskeleton.joints[leftelbow].position-testskeleton.specialforward[2]/2; testskeleton.specialforward[2]+=testskeleton.forward*.2; - Normalise(&testskeleton.specialforward[2]); + testskeleton.specialforward[2] = normalize(testskeleton.specialforward[2]); testskeleton.specialforward[3]=testskeleton.joints[righthip].position+testskeleton.joints[rightankle].position; testskeleton.specialforward[3]=testskeleton.specialforward[3]/2-testskeleton.joints[rightknee].position; testskeleton.specialforward[3]+=testskeleton.lowforward*.2; - Normalise(&testskeleton.specialforward[3]); + testskeleton.specialforward[3] = normalize(testskeleton.specialforward[3]); testskeleton.specialforward[4]=testskeleton.joints[lefthip].position+testskeleton.joints[leftankle].position; testskeleton.specialforward[4]=testskeleton.specialforward[4]/2-testskeleton.joints[leftknee].position; testskeleton.specialforward[4]+=testskeleton.lowforward*.2; - Normalise(&testskeleton.specialforward[4]); + testskeleton.specialforward[4] = normalize(testskeleton.specialforward[4]); //Find joint rotations for (int i = 0; i < max_joints; ++i) |