]> git.localhorst.tv Git - blank.git/commitdiff
restore orientation on player load
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 19 Oct 2015 15:21:02 +0000 (17:21 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 19 Oct 2015 15:21:02 +0000 (17:21 +0200)
only works for yaw, obviously

src/client/InteractiveState.hpp
src/client/client.cpp
src/standalone/MasterState.cpp

index b86258e9f2bb892bb06309f3e29a9c39ff717dc2..49c54745f8f88c57b94af1b52d6a7f72fb12fd68 100644 (file)
@@ -38,6 +38,7 @@ public:
 
        World &GetWorld() noexcept { return world; }
        Player &GetPlayer() noexcept { return player; }
+       PlayerController &GetPlayerController() noexcept { return input; }
        ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; }
 
        void OnEnter() override;
index 97292a957f86466a228dbd24f1c45e28a20aae85..fd4fbee8bad7c3b68362bb4950cebd2ecf2a3406 100644 (file)
@@ -380,6 +380,8 @@ void MasterState::On(const Packet::Join &pack) {
        state.reset(new InteractiveState(*this, player_id));
 
        pack.ReadPlayerState(state->GetPlayer().GetEntity().GetState());
+       glm::vec3 orient(glm::eulerAngles(state->GetPlayer().GetEntity().Orientation()));
+       state->GetPlayerController().TurnHead(orient.x, orient.y);
 
        env.state.PopAfter(this);
        env.state.Push(state.get());
index 1035bb23688da035893c3a10fdd8e687a9190b79..750e491141135ca52a14b534aab51ebbd4fdd46e 100644 (file)
@@ -51,6 +51,8 @@ MasterState::MasterState(
        chunk_renderer.FogDensity(wc.fog_density);
        if (save.Exists(player)) {
                save.Read(player);
+               glm::vec3 orient(glm::eulerAngles(player.GetEntity().Orientation()));
+               input.TurnHead(orient.x, orient.y);
        } else {
                spawn_player = true;
        }