diff options
| author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-06-23 00:10:26 +0700 |
|---|---|---|
| committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-06-23 00:10:26 +0700 |
| commit | 80ae4f1c42abfd1ddb576699f291f759250219c0 (patch) | |
| tree | ad5a171a60c9300e6fcc5d7f3fa2270a3446586c /src/Person.cpp | |
| parent | b8a48279dc67f5f44a9ccfb46e7c832ae3a5aff4 (diff) | |
| download | blackshades-80ae4f1c42abfd1ddb576699f291f759250219c0.tar.gz | |
Finish reformatting DrawSkeleton
Diffstat (limited to 'src/Person.cpp')
| -rw-r--r-- | src/Person.cpp | 153 |
1 files changed, 91 insertions, 62 deletions
diff --git a/src/Person.cpp b/src/Person.cpp index 1d47543..bce24f2 100644 --- a/src/Person.cpp +++ b/src/Person.cpp @@ -959,78 +959,107 @@ int Person::DrawSkeleton(int who) } //Find forward vectors - if(who==0||skeleton.free!=0||skeleton.offset!=0||whichgun!=nogun||currentanimation==lyinganim||((currentanimation==getupfrontanim||currentanimation==getupbackanim)&&targetanimation==idleanim)){ - if(!(skeleton.free==1&&longdead<=0)){ - if(skeleton.offset&&skeleton.free<1){ - XYZ normal; - skeleton.offset=0; - for(int i=0;i<skeleton.num_joints;i++){ - skeleton.joints[i].oldposition=skeleton.joints[i].position; - skeleton.joints[i].position+=skeleton.joints[i].offset; - if(findLengthfast(skeleton.joints[i].offset)<multiplier*multiplier*25)skeleton.joints[i].offset=0; - else{ - normal=skeleton.joints[i].offset; - Normalise(&normal); - skeleton.offset=1; - skeleton.joints[i].offset-=normal*multiplier*5; + if (!who || skeleton.free || skeleton.offset || whichgun != nogun + || currentanimation == lyinganim + || ((currentanimation == getupfrontanim + || currentanimation == getupbackanim) + && targetanimation == idleanim)) { + if (skeleton.free != 1 || longdead > 0) { + if (skeleton.offset && skeleton.free < 1) { + XYZ normal; + skeleton.offset = 0; + for (int i = 0; i < skeleton.num_joints; i++) { + auto joint = skeleton.joints[i]; + joint.oldposition = joint.position; + joint.position += joint.offset; + if (findLengthfast(joint.offset) >= multiplier * multiplier * 25) { + normal = joint.offset; + Normalise(&normal); + skeleton.offset = 1; + joint.offset -= normal * multiplier * 5; + } else { + joint.offset=0; + } + } + skeleton.DoConstraints(); } - } - skeleton.DoConstraints(); - } - CrossProduct(skeleton.joints[skeleton.forwardjoints[1]].position-skeleton.joints[skeleton.forwardjoints[0]].position,skeleton.joints[skeleton.forwardjoints[2]].position-skeleton.joints[skeleton.forwardjoints[0]].position,&skeleton.forward); - Normalise(&skeleton.forward); - CrossProduct(skeleton.joints[skeleton.lowforwardjoints[1]].position-skeleton.joints[skeleton.lowforwardjoints[0]].position,skeleton.joints[skeleton.lowforwardjoints[2]].position-skeleton.joints[skeleton.lowforwardjoints[0]].position,&skeleton.lowforward); - Normalise(&skeleton.lowforward); + auto fwdjoints = skeleton.forwardjoints; + 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); - //Special forwards - skeleton.specialforward[0]=skeleton.forward; + auto lowfwd = skeleton.lowforwardjoints; + 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.specialforward[1]=skeleton.joints[skeleton.jointlabels[rightshoulder]].position+skeleton.joints[skeleton.jointlabels[rightwrist]].position; - skeleton.specialforward[1]=skeleton.joints[skeleton.jointlabels[rightelbow]].position-skeleton.specialforward[1]/2; - skeleton.specialforward[1]+=skeleton.forward*.2; - Normalise(&skeleton.specialforward[1]); - skeleton.specialforward[2]=skeleton.joints[skeleton.jointlabels[leftshoulder]].position+skeleton.joints[skeleton.jointlabels[leftwrist]].position; - skeleton.specialforward[2]=skeleton.joints[skeleton.jointlabels[leftelbow]].position-skeleton.specialforward[2]/2; - skeleton.specialforward[2]+=skeleton.forward*.2; - Normalise(&skeleton.specialforward[2]); + //Special forwards + auto specialfwd = skeleton.specialforward; + *specialfwd++ = skeleton.forward; - if(who==0&&aimamount>0&&health==100&&whichgun!=nogun){ - //Facing - XYZ facing; - XYZ facingdown; - //Facing - facing=0; - facing.z=1; + auto right_shoulder = skeleton.jointlabels[rightshoulder]; + auto right_elbow = skeleton.jointlabels[rightelbow]; + *specialfwd = skeleton.joints[right_elbow].position + - skeleton.joints[right_shoulder].position / 2 + - right_wrist / 2 + skeleton.forward * 0.2; + Normalise(specialfwd++); - facing=DoRotation(facing,camera.rotation2,0,0); - facingdown=DoRotation(facing,90,0,0); - skeleton.specialforward[1]=skeleton.specialforward[1]*(1-aimamount)+facingdown*aimamount; - skeleton.specialforward[2]=skeleton.specialforward[2]*(1-aimamount)+facingdown*aimamount; - } + auto left_shoulder = skeleton.jointlabels[leftshoulder]; + auto left_elbow = skeleton.jointlabels[leftelbow]; + *specialfwd = skeleton.joints[left_elbow].position + - skeleton.joints[left_shoulder].position / 2 + - left_wrist / 2 + skeleton.forward * 0.2; + Normalise(specialfwd++); + + if(!who && aimamount > 0 + && health == 100 && whichgun != nogun) { + //Facing + XYZ facing {0}; + facing.z = 1; + facing = DoRotation(facing, camera.rotation2, 0, 0); + XYZ facingdown = DoRotation(facing, 90, 0, 0); + + skeleton.specialforward[1] *= 1 - aimamount; + skeleton.specialforward[1] += facingdown * aimamount; + skeleton.specialforward[2] *= 1 - aimamount; + skeleton.specialforward[2] += facingdown * aimamount; + } - skeleton.specialforward[3]=skeleton.joints[skeleton.jointlabels[righthip]].position+skeleton.joints[skeleton.jointlabels[rightankle]].position; - skeleton.specialforward[3]=skeleton.specialforward[3]/2-skeleton.joints[skeleton.jointlabels[rightknee]].position; - skeleton.specialforward[3]+=skeleton.lowforward*.2; - Normalise(&skeleton.specialforward[3]); - skeleton.specialforward[4]=skeleton.joints[skeleton.jointlabels[lefthip]].position+skeleton.joints[skeleton.jointlabels[leftankle]].position; - skeleton.specialforward[4]=skeleton.specialforward[4]/2-skeleton.joints[skeleton.jointlabels[leftknee]].position; - skeleton.specialforward[4]+=skeleton.lowforward*.2; - Normalise(&skeleton.specialforward[4]); + auto right_hip = skeleton.jointlabels[righthip]; + auto right_ankle = skeleton.jointlabels[rightankle]; + auto right_knee = skeleton.jointlabels[rightknee]; + *specialfwd = skeleton.joints[right_hip].position / 2 + + skeleton.joints[right_ankle].position / 2 + - skeleton.joints[right_knee].position + + skeleton.lowforward * 0.2; + Normalise(specialfwd++); - //Find joint rotations - for(int i=0;i<skeleton.num_joints;i++){ - if(skeleton.joints[i].hasparent&&skeleton.joints[i].visible) - { - skeleton.FindRotationJoint(i); + auto left_hip = skeleton.jointlabels[lefthip]; + auto left_ankle = skeleton.jointlabels[leftankle]; + auto left_knee = skeleton.jointlabels[leftknee]; + *specialfwd = skeleton.joints[left_hip].position / 2 + + skeleton.joints[left_ankle].position / 2 + - skeleton.joints[left_knee].position + + skeleton.lowforward * 0.2; + Normalise(specialfwd++); + + for(int i = 0; i < skeleton.num_joints; i++) + if (skeleton.joints[i].hasparent + && skeleton.joints[i].visible) + skeleton.FindRotationJoint(i); + + for(int i = 0; i < skeleton.num_muscles; i++) + if (skeleton.muscles[i].visible) + skeleton.FindRotationMuscle(i); } } - for(int i=0;i<skeleton.num_muscles;i++){ - if(skeleton.muscles[i].visible) - { - skeleton.FindRotationMuscle(i); - } - }}} for (int i = 0; i < skeleton.num_joints; i++) draw_joint(skeleton.joints[i], who, whichcostume); |
