Skip to content

Commit

Permalink
State Machines and Animations will call advanceAndApply() instead of …
Browse files Browse the repository at this point in the history
…advance() and apply() separately
  • Loading branch information
duncandoit committed Jun 8, 2022
1 parent 658a76c commit 6d33cb6
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 11 deletions.
4 changes: 0 additions & 4 deletions Source/Components/RiveView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down
6 changes: 1 addition & 5 deletions Source/Renderer/RiveLinearAnimationInstance.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Source/Renderer/RiveStateMachineInstance.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion Source/Renderer/include/RiveLinearAnimationInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6d33cb6

Please sign in to comment.