From 6d33cb6e14dd06e8e1c8a47439fbf801aee5064b Mon Sep 17 00:00:00 2001 From: Zachary Duncan Date: Wed, 8 Jun 2022 00:38:18 -0400 Subject: [PATCH] State Machines and Animations will call advanceAndApply() instead of advance() and apply() separately --- Source/Components/RiveView.swift | 4 ---- Source/Renderer/RiveLinearAnimationInstance.mm | 6 +----- Source/Renderer/RiveStateMachineInstance.mm | 2 +- Source/Renderer/include/RiveLinearAnimationInstance.h | 1 - 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Source/Components/RiveView.swift b/Source/Components/RiveView.swift index cb002385..9344f21f 100644 --- a/Source/Components/RiveView.swift +++ b/Source/Components/RiveView.swift @@ -169,12 +169,10 @@ open class RiveView: RiveRendererView { if let stateMachine = riveModel.stateMachine { isPlaying = stateMachine.advance(by: delta) && wasPlaying - stateMachine.stateChanges().forEach { stateMachineDelegate?.stateMachine?(stateMachine, didChangeState: $0) } } else if let animation = riveModel.animation { isPlaying = animation.advance(by: delta) && wasPlaying - animation.apply() if isPlaying { if animation.didLoop() { @@ -192,8 +190,6 @@ open class RiveView: RiveRendererView { } } - // advance the artboard - riveModel.artboard.advance(by: delta) playerDelegate?.player(didAdvanceby: delta, riveModel: riveModel) // Trigger a redraw diff --git a/Source/Renderer/RiveLinearAnimationInstance.mm b/Source/Renderer/RiveLinearAnimationInstance.mm index 68fdd3dc..be1a8f10 100644 --- a/Source/Renderer/RiveLinearAnimationInstance.mm +++ b/Source/Renderer/RiveLinearAnimationInstance.mm @@ -33,12 +33,8 @@ - (void)setTime:(float) time { instance->time(time); } -- (void)apply { - instance->apply(); -} - - (bool)advanceBy:(double)elapsedSeconds { - return instance->advance(elapsedSeconds); + return instance->advanceAndApply(elapsedSeconds); } - (void)direction:(int)direction { diff --git a/Source/Renderer/RiveStateMachineInstance.mm b/Source/Renderer/RiveStateMachineInstance.mm index 5bc426fe..53182eee 100644 --- a/Source/Renderer/RiveStateMachineInstance.mm +++ b/Source/Renderer/RiveStateMachineInstance.mm @@ -36,7 +36,7 @@ - (instancetype)initWithStateMachine:(rive::StateMachineInstance *)stateMachine - (bool) advanceBy:(double)elapsedSeconds { - return instance->advance(elapsedSeconds); + return instance->advanceAndApply(elapsedSeconds); } - (RiveSMIBool *)getBool:(NSString *)name { diff --git a/Source/Renderer/include/RiveLinearAnimationInstance.h b/Source/Renderer/include/RiveLinearAnimationInstance.h index d142a92f..c662d728 100644 --- a/Source/Renderer/include/RiveLinearAnimationInstance.h +++ b/Source/Renderer/include/RiveLinearAnimationInstance.h @@ -22,7 +22,6 @@ NS_ASSUME_NONNULL_BEGIN - (float)time; - (void)setTime:(float) time; - (float)endTime; -- (void)apply; - (bool)advanceBy:(double)elapsedSeconds; - (int)direction; - (void)direction:(int)direction;