Jump to content

Timing things in Ultra


Go to solution Solved by Josh,

Recommended Posts

Posted

Is there a need for something like this in Ultra or is the game loop frequency manged by the engine as indicated by world::Update()'s frequency parameter?

uint64_t time_span = 1000;//ms
uint64_t time_interval = 100;//ms
uint64_t start_time = Millisecs();
float range = 90.0f;
float inc = range / (float)(time_span / time_interval);

//loop

auto result = 0.0f;
uint64_t current_time = Millisecs();
if (current_time >= start_time + time_interval) {
	start_time = current_time;

	result += inc;//Should be approx 90.0f after a second
}

 

  • Solution
Posted

You can, but since the update step is fixed, unlike Leadwerks, you can rely on each iteration occurring in intervals of 16.667 milliseconds.

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

I wonder if we could get the current update frequency of the world?  I could probably store a variable for this somewhere myself actually but just wondering.

float convertRPM(float rpm) {
	auto frequency = (world->update_frequency * 60.0f) / rpm;

	return 360.0f / frequency;
}

 

Posted

That is probably a good idea, especially for self-contained entity component code.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...