diff options
-rw-r--r-- | src/GameTick.cpp | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/src/GameTick.cpp b/src/GameTick.cpp index 21d7858..b0615e0 100644 --- a/src/GameTick.cpp +++ b/src/GameTick.cpp @@ -329,19 +329,6 @@ void look(Game* game, double xpos, double ypos) camera.rotation2 = camera.rotation2 * 0.7 + camera.oldrotation2 * 0.3; camera.rotation2 = std::min(std::max(camera.rotation2, -89.0f), 89.0f); camera.oldrotation2 = camera.rotation2; - - if (game->zoom || visions || player.aimamount <= 0 - || player.whichgun == nogun - || player.whichgun == grenade - || player.whichgun == knife) { - camera.visrotation = camera.rotation; - camera.visrotation2 = camera.rotation2; - } else { - camera.visrotation = std::min(camera.rotation + 7, - std::max(camera.rotation - 7, camera.visrotation)); - camera.visrotation2 = std::min(camera.rotation2 + 15, - std::max(camera.rotation2 - 15, camera.visrotation2)); - } } void setListener(Game* game, XYZ facing) @@ -2356,25 +2343,31 @@ hit_terrain: camerashake-=multiplier; if(camerashake<0)camerashake=0; - // camera position - XYZ average; - if (this->zoom) - average = person[0].skeleton.joints[righthand].position; - else - average = person[0].skeleton.joints[head].position * (0.5f + person[0].aimamount * 0.5f) - + person[0].skeleton.joints[neck].position * (0.5f - person[0].aimamount * 0.5f); - - if(person[0].skeleton.free==0&&thirdperson!=2)camera.position=person[0].playercoords+rotate(average,0,person[0].playerrotation,0); - - if(person[0].skeleton.free==1&&thirdperson!=2)camera.position=average; - - //Restraints - - if(camera.position.y<.1)camera.position.y=.1; - - if(thirdperson!=2){ - oldrot=camera.visrotation; - oldrot2=camera.visrotation2; + // Camera position and angle + const auto& average = this->zoom + ? this->person[0].skeleton.joints[righthand].position + : (this->person[0].skeleton.joints[head].position + * (0.5f + this->person[0].aimamount * 0.5f)) + + (this->person[0].skeleton.joints[neck].position + * (0.5f - this->person[0].aimamount * 0.5f)); + if (thirdperson != 2) { + camera.position = person[0].skeleton.free ? average + : person[0].playercoords + + rotate(average, 0, person[0].playerrotation, 0); + } + if (camera.position.y < 0.1f) + camera.position.y = 0.1f; + if (this->zoom || visions || this->person[0].aimamount <= 0 + || this->person[0].whichgun == nogun + || this->person[0].whichgun == grenade + || this->person[0].whichgun == knife) { + camera.visrotation = camera.rotation; + camera.visrotation2 = camera.rotation2; + } else { + camera.visrotation = std::min(camera.rotation + 7, + std::max(camera.rotation - 7, camera.visrotation)); + camera.visrotation2 = std::min(camera.rotation2 + 15, + std::max(camera.rotation2 - 15, camera.visrotation2)); } //Kill count |