-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New node: 'Animation Delta Time' #4304
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,6 +33,8 @@ pub struct AnimationMessageHandler { | |||||||||||
| animation_state: AnimationState, | ||||||||||||
| fps: f64, | ||||||||||||
| animation_time_mode: AnimationTimeMode, | ||||||||||||
| /// Seconds of animation time elapsed between the previous frame and the current one. | ||||||||||||
| animation_delta_time: f64, | ||||||||||||
| } | ||||||||||||
| impl AnimationMessageHandler { | ||||||||||||
| pub(crate) fn timing_information(&self) -> TimingInformation { | ||||||||||||
|
|
@@ -41,7 +43,11 @@ impl AnimationMessageHandler { | |||||||||||
| AnimationTimeMode::TimeBased => Duration::from_millis(animation_time as u64), | ||||||||||||
| AnimationTimeMode::FrameBased => Duration::from_secs((self.frame_index / self.fps) as u64), | ||||||||||||
| }; | ||||||||||||
| TimingInformation { time: self.timestamp, animation_time } | ||||||||||||
| TimingInformation { | ||||||||||||
| time: self.timestamp, | ||||||||||||
| animation_time, | ||||||||||||
| animation_delta_time: self.animation_delta_time, | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| pub(crate) fn animation_start(&self) -> f64 { | ||||||||||||
|
|
@@ -89,7 +95,11 @@ impl MessageHandler<AnimationMessage, ()> for AnimationMessageHandler { | |||||||||||
| responses.add(PortfolioMessage::UpdateDocumentWidgets); | ||||||||||||
| } | ||||||||||||
| AnimationMessage::SetTime { time } => { | ||||||||||||
| // Elapsed animation time since the previous frame, in seconds (frozen while paused, so it reads 0 then) | ||||||||||||
| let previous_animation_time = self.timestamp - self.animation_start(); | ||||||||||||
| self.timestamp = time; | ||||||||||||
| let current_animation_time = self.timestamp - self.animation_start(); | ||||||||||||
| self.animation_delta_time = ((current_animation_time - previous_animation_time) / 1000.).max(0.); | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: In self.animation_delta_time = match self.animation_time_mode {
AnimationTimeMode::TimeBased => ((current_animation_time - previous_animation_time) / 1000.).clamp(0., 0.1),
AnimationTimeMode::FrameBased => if self.is_playing() { 1. / self.fps } else { 0. },
};Also note the lack of an upper clamp in Prompt for AI agentsAlso note the lack of an upper clamp in
Suggested change
|
||||||||||||
| responses.add(AnimationMessage::UpdateTime); | ||||||||||||
| } | ||||||||||||
|
Comment on lines
97
to
104
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In AnimationMessage::SetTime { time } => {
// Elapsed animation time since the previous frame, in seconds (frozen while paused, so it reads 0 then)
let previous_animation_time = self.timestamp - self.animation_start();
self.timestamp = time;
let current_animation_time = self.timestamp - self.animation_start();
self.animation_delta_time = match self.animation_time_mode {
AnimationTimeMode::TimeBased => ((current_animation_time - previous_animation_time) / 1000.).clamp(0., 0.1),
AnimationTimeMode::FrameBased => if self.is_playing() { 1. / self.fps } else { 0. },
};
responses.add(AnimationMessage::UpdateTime);
} |
||||||||||||
| AnimationMessage::IncrementFrameCounter => { | ||||||||||||
|
|
@@ -110,6 +120,7 @@ impl MessageHandler<AnimationMessage, ()> for AnimationMessageHandler { | |||||||||||
| } | ||||||||||||
| AnimationMessage::RestartAnimation => { | ||||||||||||
| self.frame_index = 0.; | ||||||||||||
| self.animation_delta_time = 0.; | ||||||||||||
| self.animation_state = match self.animation_state { | ||||||||||||
| AnimationState::Playing { .. } => AnimationState::Playing { start: self.timestamp }, | ||||||||||||
| _ => AnimationState::Stopped, | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -187,6 +187,7 @@ pub async fn export_gif( | |||||||||||||||||||||
| time: TimingInformation { | ||||||||||||||||||||||
| time: animation_time.as_secs_f64(), | ||||||||||||||||||||||
| animation_time, | ||||||||||||||||||||||
| animation_delta_time: 0., | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: In the GIF export loop, Prompt for AI agents
Suggested change
|
||||||||||||||||||||||
| }, | ||||||||||||||||||||||
|
Comment on lines
187
to
191
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In
Suggested change
|
||||||||||||||||||||||
| ..Default::default() | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The new
animation_delta_timefield is updated inSetTimeand reset inRestartAnimation, butSetFrameIndextriggers a graph render (SubmitActiveGraphRender) without resetting it. If the user scrubs to a specific frame while the animation is playing, the Animation Delta Time node will read a stale non-zero delta from the last playback frame instead of 0, since manual frame scrubbing involves no elapsed animation time.Prompt for AI agents