Skip to content

Commit

Permalink
[Animation] Fix issue with tick processing
Browse files Browse the repository at this point in the history
Fixes an issue with realtime ticks not generating when
all animations are paused and then resumed.
  • Loading branch information
hyazinthh committed Feb 6, 2025
1 parent 6d781ec commit 7ebefa5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- Fixed multisampled raw download
- [Animation] Improved adaptive sampling scheme for splines to avoid infinite recursion when control points are coinciding
- [Animation] Fixed issue with ticks not being processed when all animations are paused

### 5.5.2
- updated Adaptify.Core to 1.3.0 (using local, new style adaptify)
Expand Down
5 changes: 1 addition & 4 deletions src/Aardvark.UI.Primitives/Animation/Animator/AnimatorApp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,4 @@ module Animator =
yield! time()
}

if model.Slots |> HashMap.exists (fun _ s -> s.Current.IsRunning) then
ThreadPool.add "animationTicks" (time()) ThreadPool.empty
else
ThreadPool.empty
ThreadPool.add "animationTicks" (time()) ThreadPool.empty
7 changes: 6 additions & 1 deletion src/Examples (dotnetcore)/26 - Animation/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ open Aardvark.UI
open Aardvark.UI.Primitives
open Aardvark.UI.Animation
open FSharp.Data.Adaptive
open Aardvark.Application

[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module Model =
Expand All @@ -32,6 +33,7 @@ module App =
style "width: 100%; height:100%"
onEvent "onRendered" [] (fun _ -> Animation AnimatorMessage.RealTimeTick)
onClick (fun _ -> GameMessage.Start |> Game)
onKeyDown OnKeyDown
attribute "showFPS" "true"
attribute "data-samples" "8"
]) RenderControlConfig.standard
Expand All @@ -44,7 +46,7 @@ module App =
ThreadPool.union camera animation


let update (model : Model) (msg : Message) =
let rec update (model : Model) (msg : Message) =
match msg with
| Game m ->
m |> Game.update model
Expand All @@ -55,6 +57,9 @@ module App =
| Animation msg ->
model |> Animator.update msg

| OnKeyDown Keys.Space ->
Game GameMessage.Pause |> update model

| _ ->
model

Expand Down
10 changes: 10 additions & 0 deletions src/Examples (dotnetcore)/26 - Animation/Game.fs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,16 @@ module Game =
| Start when model.state = Introduction ->
model |> Transitions.flyover

| Pause ->
match model.state with
| Paused original ->
{ model with state = original }
|> Animator.iterate (fun a -> a.Resume())

| _ ->
{ model with state = Paused model.state }
|> Animator.iterate (fun a -> a.Pause())

| _ when not <| GameState.isRunning model.state ->
model

Expand Down
4 changes: 4 additions & 0 deletions src/Examples (dotnetcore)/26 - Animation/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
open Aardvark.Base
open Aardvark.UI.Primitives
open Aardvark.UI.Animation
open Aardvark.Application
open FSharp.Data.Adaptive
open Adaptify

Expand Down Expand Up @@ -52,6 +53,7 @@ type GameState =
| Preparing
| Running of resolved: int
| Finished
| Paused of original: GameState

[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module GameState =
Expand All @@ -78,8 +80,10 @@ type GameMessage =
| Select of V2i
| Hover of V2i
| Unhover of V2i
| Pause

type Message =
| OnKeyDown of Keys
| Game of GameMessage
| Camera of OrbitMessage
| Animation of AnimatorMessage<Model>

0 comments on commit 7ebefa5

Please sign in to comment.