]> git.localhorst.tv Git - blank.git/commitdiff
apply pitch to head instead of body
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 19 Oct 2015 13:21:17 +0000 (15:21 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 19 Oct 2015 13:21:17 +0000 (15:21 +0200)
assets
src/model/Instance.hpp
src/model/Model.hpp
src/model/Part.hpp
src/model/model.cpp
src/ui/ui.cpp

diff --git a/assets b/assets
index ed7b81207b13b87a3a9097b9e25ebd06aa814d97..00b0cac2c26af161cc436d404d033e242a00c5a6 160000 (submodule)
--- a/assets
+++ b/assets
@@ -1 +1 @@
-Subproject commit ed7b81207b13b87a3a9097b9e25ebd06aa814d97
+Subproject commit 00b0cac2c26af161cc436d404d033e242a00c5a6
index 09ab78e368835998a09978d2be12c6620036a26c..0c828393675cb50f6e175510cfacfd6592a083be 100644 (file)
@@ -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 &);
 
index 55a9734381a7e68ad453f94f1e51ce489fdce748..ad8cb04a4ffbb1878150cedac1c2cbca493cb498 100644 (file)
@@ -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();
index 3e3b57080316942b8c60622614b4cda9f64e80e9..8c1db600244e4d4db37685c5abd3f0b1819c59e5 100644 (file)
@@ -41,6 +41,8 @@ public:
        std::uint16_t Enumerate(std::uint16_t) noexcept;
        void Index(std::vector<Part *> &) noexcept;
 
+       std::uint16_t ID() const noexcept { return id; }
+
        glm::mat4 LocalTransform(const Instance &) const noexcept;
        glm::mat4 GlobalTransform(const Instance &) const noexcept;
 
index 451433bc7e8296d38b37c551883598553ab13248..cad62ac2ec0cea30c99e39685adbef0729b6f3a8 100644 (file)
@@ -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);
 }
index 5b0eec8b1dac47bb7b1798e51dbfb4d814892893..43cdb53613ec2660603204128f9fffc91cf24839 100644 (file)
@@ -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();