From: Daniel Karbach Date: Mon, 19 Oct 2015 13:21:17 +0000 (+0200) Subject: apply pitch to head instead of body X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=b9a63fedbc65e8659c43f7fa381017c0c70a48da;p=blank.git apply pitch to head instead of body --- diff --git a/assets b/assets index ed7b812..00b0cac 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit ed7b81207b13b87a3a9097b9e25ebd06aa814d97 +Subproject commit 00b0cac2c26af161cc436d404d033e242a00c5a6 diff --git a/src/model/Instance.hpp b/src/model/Instance.hpp index 09ab78e..0c82839 100644 --- a/src/model/Instance.hpp +++ b/src/model/Instance.hpp @@ -27,6 +27,7 @@ public: const Model &GetModel() const noexcept { return *model; } glm::mat4 EyesTransform() const noexcept; + Part::State &EyesState() noexcept; void Render(const glm::mat4 &, DirectionalLighting &); diff --git a/src/model/Model.hpp b/src/model/Model.hpp index 55a9734..ad8cb04 100644 --- a/src/model/Model.hpp +++ b/src/model/Model.hpp @@ -32,7 +32,6 @@ public: const Part &GetPart(std::size_t i) const noexcept { return *part[i]; } void SetEyes(std::uint16_t id) { eyes_id = id; } - const Part &GetEyesPart() const noexcept { return GetPart(eyes_id); } void Enumerate(); diff --git a/src/model/Part.hpp b/src/model/Part.hpp index 3e3b570..8c1db60 100644 --- a/src/model/Part.hpp +++ b/src/model/Part.hpp @@ -41,6 +41,8 @@ public: std::uint16_t Enumerate(std::uint16_t) noexcept; void Index(std::vector &) noexcept; + std::uint16_t ID() const noexcept { return id; } + glm::mat4 LocalTransform(const Instance &) const noexcept; glm::mat4 GlobalTransform(const Instance &) const noexcept; diff --git a/src/model/model.cpp b/src/model/model.cpp index 451433b..cad62ac 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -27,6 +27,10 @@ Instance::~Instance() { } +Part::State &Instance::EyesState() noexcept { + return state[model->GetEyesPart().ID()]; +} + glm::mat4 Instance::EyesTransform() const noexcept { return model->GetEyesPart().GlobalTransform(*this); } diff --git a/src/ui/ui.cpp b/src/ui/ui.cpp index 5b0eec8..43cdb53 100644 --- a/src/ui/ui.cpp +++ b/src/ui/ui.cpp @@ -85,7 +85,8 @@ 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(pitch, yaw, 0.0f))); + 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)); Ray aim = player.Aim();