X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fui%2Fui.cpp;h=048aed1ac81559e21e2eee740d90a195bf5df22b;hb=f21a21b285c5b54e3abcc757c6715d22520dd190;hp=0f82139b2a7bd5350db9965e51d89ea1ea3c0843;hpb=54f3f1260b95a924fcb40d9d6de3fa2e2c382f6f;p=blank.git diff --git a/src/ui/ui.cpp b/src/ui/ui.cpp index 0f82139..048aed1 100644 --- a/src/ui/ui.cpp +++ b/src/ui/ui.cpp @@ -37,8 +37,6 @@ PlayerController::PlayerController(World &world, Player &player) : world(world) , player(player) , move_dir(0.0f) -, pitch(0.0f) -, yaw(0.0f) , dirty(true) , aim_world() , aim_entity() { @@ -55,19 +53,15 @@ void PlayerController::SetMovement(const glm::vec3 &m) noexcept { } void PlayerController::TurnHead(float dp, float dy) noexcept { - pitch += dp; - if (pitch > PI / 2) { - pitch = PI / 2; - } else if (pitch < -PI / 2) { - pitch = -PI / 2; - } - yaw += dy; - if (yaw > PI) { - yaw -= PI * 2; - } else if (yaw < -PI) { - yaw += PI * 2; - } - Invalidate(); + player.GetEntity().TurnHead(dp, dy); +} + +float PlayerController::GetPitch() const noexcept { + return player.GetEntity().Pitch(); +} + +float PlayerController::GetYaw() const noexcept { + return player.GetEntity().Yaw(); } void PlayerController::SelectInventory(int i) noexcept { @@ -85,9 +79,7 @@ void PlayerController::Invalidate() noexcept { void PlayerController::UpdatePlayer() noexcept { constexpr float max_vel = 5.0f; // in m/s if (dirty) { - player.GetEntity().Orientation(glm::quat(glm::vec3(0.0f, yaw, 0.0f))); - player.GetEntity().GetModel().EyesState().orientation = glm::quat(glm::vec3(pitch, 0.0f, 0.0f)); - player.GetEntity().TargetVelocity(glm::rotateY(move_dir * max_vel, yaw)); + player.GetEntity().TargetVelocity(glm::rotateY(move_dir * max_vel, player.GetEntity().Yaw())); Ray aim = player.Aim(); if (!world.Intersection(aim, glm::mat4(1.0f), player.GetEntity().ChunkCoords(), aim_world)) {