mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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>
This commit is contained in:
parent
0e439b2fa3
commit
d1cbb4bd8a
4 changed files with 19 additions and 16 deletions
|
@ -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);
|
||||
|
@ -3747,6 +3747,12 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
|
|||
TimeTaker tt_update("Game::updateFrame()");
|
||||
LocalPlayer *player = client->getEnv().getLocalPlayer();
|
||||
|
||||
/*
|
||||
Frame time
|
||||
*/
|
||||
|
||||
client->getEnv().updateFrameTime();
|
||||
|
||||
/*
|
||||
Fog range
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue