diff options
author | x2048 <codeforsmile@gmail.com> | 2022-08-13 22:33:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-13 22:33:26 +0200 |
commit | d1cbb4bd8a3fea147032fde63fdc4f5298f20217 (patch) | |
tree | eab23e9a249b59fd742c8fd4bd313f7d14f0af43 /src/client/game.cpp | |
parent | 0e439b2fa3f0ba4f3352273519c32ebc9c3a680e (diff) | |
download | minetest-d1cbb4bd8a3fea147032fde63fdc4f5298f20217.tar.xz |
Reduce the use of porting::getTimeMs() when rendering frames (#12679)
* Avoid calling TimeTaker too frequently in renderMapXXX
* Calculate animation timer once per frame
* Remove code that breaks rendering frame at 2000ms
Co-authored-by: sfan5 <sfan5@live.de>
Co-authored-by: sfan5 <sfan5@live.de>
Diffstat (limited to 'src/client/game.cpp')
-rw-r--r-- | src/client/game.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp index c34e3a415..0e86de496 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -502,7 +502,7 @@ public: float clr[4] = {star_color.r, star_color.g, star_color.b, star_color.a}; m_star_color.set(clr, services); - u32 animation_timer = porting::getTimeMs() % 1000000; + u32 animation_timer = m_client->getEnv().getFrameTime() % 1000000; float animation_timer_f = (float)animation_timer / 100000.f; m_animation_timer_vertex.set(&animation_timer_f, services); m_animation_timer_pixel.set(&animation_timer_f, services); @@ -3275,7 +3275,7 @@ PointedThing Game::updatePointedThing( final_color_blend(&c, light_level, daynight_ratio); // Modify final color a bit with time - u32 timer = porting::getTimeMs() % 5000; + u32 timer = client->getEnv().getFrameTime() % 5000; float timerf = (float) (irr::core::PI * ((timer / 2500.0) - 0.5)); float sin_r = 0.08f * std::sin(timerf); float sin_g = 0.08f * std::sin(timerf + irr::core::PI * 0.5f); @@ -3748,6 +3748,12 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, LocalPlayer *player = client->getEnv().getLocalPlayer(); /* + Frame time + */ + + client->getEnv().updateFrameTime(); + + /* Fog range */ |