Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make pipeline reports delta_time to imgui #187

Merged
merged 1 commit into from
May 22, 2024

Conversation

ruby3141
Copy link
Contributor

@ruby3141 ruby3141 commented May 16, 2024

According to imgui's custom backend implementation exhibit
and first-party backend implementations,
io.DeltaTime is "usually" meant to be updated by backend code.

(you can check platform backend impls of ocornut/imgui for example)

This PR solves issue #186.

According to imgui's custom backend implementation exhibit
and first-party backend implementations,
io.DeltaTime is "usually" meant to be updated by backend code.

(you can check platform backend impls of ocornut/imgui for example)
@veeenu veeenu linked an issue May 22, 2024 that may be closed by this pull request
Copy link
Owner

@veeenu veeenu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super sure what happens when the delta time ends up being Duration::ZERO, but it seems to be working. LGTM. Thank you for your contribution!

@veeenu veeenu merged commit 5655ce1 into veeenu:main May 22, 2024
1 check passed
@ruby3141
Copy link
Contributor Author

ruby3141 commented May 22, 2024

imgui prohibits IO.DeltaTime of 0 when it's not in its first frame,
but Duration::ZERO will be boundary checked by imgui::Io::update_delta_time() into f32::MIN_POSITIVE seconds.
https://github.com/ocornut/imgui/blob/a1566c5e1ba22755c359e3079f5f25ab53f1eafb/imgui.cpp#L9784
https://github.com/imgui-rs/imgui-rs/blob/cb8beeb74cceec787275ec3e121c0068ba08fbf7/imgui/src/io.rs#L435-L437

I've considered Duration::from_nanos(1) instead of Duration::ZERO, but turns out it was too large.

f32::MIN_POSITIVE seconds is small enough not to actually increment global timer(which is f64 btw) while being positive.
it is about 0.000000000000000000000000000000000000011754944 seconds, or 0.00000001 quectoseconds,
and when added into f64 global timer, which is usually larger than 1, it just rounded down into zero.
(It has about 30 zeros too many. In f64, the very next value after 1 is 1.0000000000000002.)

@ruby3141 ruby3141 deleted the dev/deltatime branch May 22, 2024 08:50
@veeenu
Copy link
Owner

veeenu commented May 22, 2024

That's great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hudhook pipeline doesn't report delta_time to imgui runtime
2 participants