Skip to content

Commit

Permalink
lock fps counter updates to 5 at most
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Dec 8, 2020
1 parent a5329d4 commit 4dcee65
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/3d/qgs3dmapscene.cpp
Expand Up @@ -499,7 +499,19 @@ void Qgs3DMapScene::onFrameTriggered( float dt )
}

updateSceneState();
emit fpsCountChanged( 1.0f / dt );

// lock changing the FPS counter to 5 fps
static int frameCount = 0;
static float accumulatedTime = 0.0f;
frameCount++;
accumulatedTime += dt;
if ( accumulatedTime >= 0.2f )
{
float fps = ( float )frameCount / accumulatedTime;
frameCount = 0;
accumulatedTime = 0.0f;
emit fpsCountChanged( fps );
}
}

void Qgs3DMapScene::createTerrain()
Expand Down

0 comments on commit 4dcee65

Please sign in to comment.