diff options
Diffstat (limited to 'src/Person.cpp')
-rw-r--r-- | src/Person.cpp | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/src/Person.cpp b/src/Person.cpp index 2007857..452a8bd 100644 --- a/src/Person.cpp +++ b/src/Person.cpp @@ -72,9 +72,7 @@ HitStruct Person::BulletCollideWithPlayer(int who, XYZ start, XYZ end){ } tempbulletloc[0]=start; tempbulletloc[1]=end; - if(sphere_line_intersection(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z, - tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z, - average.x, average.y, average.z, distancemax)){ + if (segmentIntersectsSphere(start, end, average, distancemax)) { for (auto& joint : skeleton.joints) { if (joint.hasparent && joint.visible) { tempbulletloc[0] = start; @@ -726,7 +724,7 @@ void Person::FindRotationGun(XYZ start, XYZ target) tempforward=DoRotation(tempforward,0,gunrotate1-90,0); tempforward=DoRotation(tempforward,0,0,gunrotate2-90); tempforward.y=0; - Normalise(&tempforward); + tempforward = normalize(tempforward); gunrotate3=acos(0-tempforward.z)*rad2deg; if(0>tempforward.x)gunrotate3=360-gunrotate3; } @@ -935,8 +933,7 @@ int Person::DrawSkeleton(int who) joint.oldposition = joint.position; joint.position += joint.offset; if (findLengthfast(joint.offset) >= multiplier * multiplier * 25) { - normal = joint.offset; - Normalise(&normal); + normal = normalize(joint.offset); skeleton.offset = 1; joint.offset -= normal * multiplier * 5; } else { @@ -947,34 +944,30 @@ int Person::DrawSkeleton(int who) } auto& fwdjoints = skeleton.forwardjoints; - CrossProduct(skeleton.joints[fwdjoints[1]].position + skeleton.forward = normalize(crossProduct(skeleton.joints[fwdjoints[1]].position - skeleton.joints[fwdjoints[0]].position, skeleton.joints[fwdjoints[2]].position - - skeleton.joints[fwdjoints[0]].position, - &skeleton.forward); - Normalise(&skeleton.forward); + - skeleton.joints[fwdjoints[0]].position)); auto& lowfwd = skeleton.lowforwardjoints; - CrossProduct(skeleton.joints[lowfwd[1]].position + skeleton.lowforward = normalize(crossProduct(skeleton.joints[lowfwd[1]].position - skeleton.joints[lowfwd[0]].position, skeleton.joints[lowfwd[2]].position - - skeleton.joints[lowfwd[0]].position, - &skeleton.lowforward); - Normalise(&skeleton.lowforward); + - skeleton.joints[lowfwd[0]].position)); // Special forwards auto specialfwd = skeleton.specialforward; *specialfwd++ = skeleton.forward; - *specialfwd = skeleton.joints[rightelbow].position + *specialfwd = normalize(skeleton.joints[rightelbow].position - skeleton.joints[rightshoulder].position / 2 - - right_wrist / 2 + skeleton.forward * 0.2; - Normalise(specialfwd++); + - right_wrist / 2 + skeleton.forward * 0.2); + specialfwd++; - *specialfwd = skeleton.joints[leftelbow].position + *specialfwd = normalize(skeleton.joints[leftelbow].position - skeleton.joints[leftshoulder].position / 2 - - left_wrist / 2 + skeleton.forward * 0.2; - Normalise(specialfwd++); + - left_wrist / 2 + skeleton.forward * 0.2); + specialfwd++; if(!who && aimamount > 0 && health == 100 && whichgun != nogun) { @@ -990,17 +983,17 @@ int Person::DrawSkeleton(int who) skeleton.specialforward[2] += facingdown * aimamount; } - *specialfwd = skeleton.joints[righthip].position / 2 + *specialfwd = normalize(skeleton.joints[righthip].position / 2 + skeleton.joints[rightankle].position / 2 - skeleton.joints[rightknee].position - + skeleton.lowforward * 0.2; - Normalise(specialfwd++); + + skeleton.lowforward * 0.2); + specialfwd++; - *specialfwd = skeleton.joints[lefthip].position / 2 + *specialfwd = normalize(skeleton.joints[lefthip].position / 2 + skeleton.joints[leftankle].position / 2 - skeleton.joints[leftknee].position - + skeleton.lowforward * 0.2; - Normalise(specialfwd++); + + skeleton.lowforward * 0.2); + specialfwd++; for (int i = 0; i < max_joints; i++) if (skeleton.joints[i].hasparent |