]> git.localhorst.tv Git - blank.git/blobdiff - src/client/client.cpp
more transform caching
[blank.git] / src / client / client.cpp
index 3c30a62495127a52ace02decb18233c845e463f5..8bd0ae3db1a6c76d7546cd568d823e2ef616f709 100644 (file)
@@ -62,7 +62,9 @@ InteractiveState::InteractiveState(MasterState &master, uint32_t player_id)
 , stat_timer(1000)
 , sky(master.GetEnv().loader.LoadCubeMap("skybox"))
 , update_status()
-, chat(master.GetEnv(), *this, *this) {
+, chat(master.GetEnv(), *this, *this)
+, time_skipped(0)
+, packets_skipped(0) {
        if (!save.Exists()) {
                save.Write(master.GetWorldConf());
        }
@@ -163,11 +165,18 @@ void InteractiveState::Update(int dt) {
                hud.FocusNone();
        }
        if (world_dt > 0) {
-               input.PushPlayerUpdate(world_dt);
+               if (input.UpdateImportant() || packets_skipped >= master.NetStat().SuggestedPacketSkip()) {
+                       input.PushPlayerUpdate(time_skipped + world_dt);
+                       time_skipped = 0;
+                       packets_skipped = 0;
+               } else {
+                       time_skipped += world_dt;
+                       ++packets_skipped;
+               }
        }
        hud.Display(res.block_types[player.GetInventorySlot() + 1]);
        if (stat_timer.Hit()) {
-               hud.UpdateNetStats(master);
+               hud.UpdateNetStats(master.NetStat());
        }
        hud.Update(dt);
 
@@ -180,9 +189,7 @@ void InteractiveState::Update(int dt) {
 }
 
 void InteractiveState::Render(Viewport &viewport) {
-       viewport.WorldPosition(
-               player.GetEntity().Transform(player.GetEntity().ChunkCoords())
-               * player.GetEntity().GetModel().EyesTransform());
+       viewport.WorldPosition(player.GetEntity().ViewTransform(player.GetEntity().ChunkCoords()));
        if (master.GetConfig().video.world) {
                chunk_renderer.Render(viewport);
                world.Render(viewport);