SimTimes returned by GameLoop and GameSystemManager are different (SiO2)

Hi

Depending on when we are calling this method on GameLoop for the first time

it will return a different time (always smaller) than SimTime returned by GameSystemManager.

It is because it will be taken as “baseTime” here.

So if the first call to it is 10 seconds after the system manager has started, the step time returned by GameLoop will be 10 seconds behind the one returned by GameSystemManager.

To prevent this I must call gameLoop.getStepTime().update(0);
before starting GameLoop to make sure “baseTime” will be set to 0.

There is something I still don’t understand because baseTime should never be 0. SimTime is supposed to be the “time since the first frame” ie: the simulation time.

If you force baseTime to 0 then the SimTime will be “random time since the CPU nano counter was reset”.

Even though your explanation is clear it’s still somehow not clicking to me what the problem is.

1 Like

There are two SimTime instances. One is maintained by GameSystemManager and one is maintained by GameLoop.

The one maintained by GameLoop claims to be thread safe and its value is get from GameSystemManager.getStepTime().getTime(). (i.e not the System.nanoTime())

I only force “baseTime” to 0 on the GameLoop step time, not the GameSystemManager step time.

Edit:

The time represented by these two methods is not the same. Their difference is arbitrary (could be 10s, 20m, 1h,…) depends on when we first call to GameLoop.getStepTime() after the game system manager is started.

Aren’t they supposed to represent the same time?

1 Like

I think so. I will need to dig deeper to see why I never hit this issue.

1 Like