Skip to content

clamp time delta by max_delta even when relative speed is greater than 1#24237

Open
mockersf wants to merge 2 commits into
bevyengine:mainfrom
mockersf:clamp-with-max_delta
Open

clamp time delta by max_delta even when relative speed is greater than 1#24237
mockersf wants to merge 2 commits into
bevyengine:mainfrom
mockersf:clamp-with-max_delta

Conversation

@mockersf
Copy link
Copy Markdown
Member

Objective

Solution

  • Limit delta by max_delta even with a high relative_speed

Testing

  • Added / updated tests

@mockersf mockersf added the A-Time Involves time keeping and reporting label May 10, 2026
@mockersf mockersf marked this pull request as ready for review May 10, 2026 20:57
Comment thread crates/bevy_time/src/virt.rs Dismissed
Comment thread crates/bevy_time/src/virt.rs Outdated
@kfc35 kfc35 added D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 12, 2026
@@ -237,26 +237,26 @@ impl Time<Virtual> {
/// Updates the elapsed duration of `self` by `raw_delta`, up to the `max_delta`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Updates the elapsed duration of `self` by `raw_delta`, up to the `max_delta`.
/// Updates the elapsed duration of `self` by `raw_delta` * `relative_speed`, up to the `max_delta`.

} else {
scaled
};
self.context_mut().effective_speed = effective_speed;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the delta ended up being clamped, should the effective_speed in that case be updated to the value of max_delta / raw_delta? Since effective_speed is supposed to represent the multiplier that was applied to the raw_delta

@kfc35 kfc35 self-requested a review May 13, 2026 03:43
@kfc35
Copy link
Copy Markdown
Contributor

kfc35 commented May 13, 2026

Sorry I meant to just comment, not approve just yet 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Time Involves time keeping and reporting D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

high virtual time relative speed kills performances

4 participants