Skip to content

feat: (#3854) add UnifiedAnimationParentComponent , add UnifiedAnimationChildComponent#3855

Closed
s1r1m1r1 wants to merge 7 commits intoflame-engine:mainfrom
s1r1m1r1:feature/ssa-sprite-optimization
Closed

feat: (#3854) add UnifiedAnimationParentComponent , add UnifiedAnimationChildComponent#3855
s1r1m1r1 wants to merge 7 commits intoflame-engine:mainfrom
s1r1m1r1:feature/ssa-sprite-optimization

Conversation

@s1r1m1r1
Copy link
Contributor

@s1r1m1r1 s1r1m1r1 commented Mar 8, 2026

SSA

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Copy link
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

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

This PR is lacking a description.
Also, we're aiming to not use abbreviations anywhere.

/// A version of [SpriteAnimationComponent] that uses an external [animationTicker].
/// This allows multiple components to share the same ticker, synchronizing
/// their animations and reducing the number of [update] calls.
class SynchronizedSpriteAnimationComponent extends SpriteAnimationComponent {
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain what the point of this component is? You can already pass in a ticker to the original component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ticker is injected through the constructor. Instead of the component creating its own animation, it is passed a SpriteAnimationTicker that is managed by a parent controller or a global system.

SpriteAnimationTicker that is managed by a parent controller or a global system

Shared State: When render(Canvas canvas) is called, the component asks its _animationTicker for the current sprite to draw. Since the ticker is shared, _animationTicker.getSprite() returns the exact same frame for every component in that frame.

Zero Per-Component Logic: Because playing is false, the expensive update(dt) loop (which calculates time elapsed and frame indexes) is skipped for all 3000 components. Only the single shared ticker is updated once per frame in the parent.

GPU Performance: Because every component is drawing the same region of the same image, the GPU can process these commands much faster (often using a single SpriteBatch call), leading to the jump from ~30 FPS to hundreds or thousands.

@s1r1m1r1 s1r1m1r1 force-pushed the feature/ssa-sprite-optimization branch 3 times, most recently from afcfbb5 to 37b6907 Compare March 8, 2026 22:39
@s1r1m1r1 s1r1m1r1 changed the title feat: (#3854) add ssa_sprite_animation_component , add ssa_sprite_batch_component feat: (#3854) add UnifiedAnimationParentComponent , add UnifiedAnimationChildComponent Mar 8, 2026
@s1r1m1r1 s1r1m1r1 force-pushed the feature/ssa-sprite-optimization branch 3 times, most recently from 20d667e to 545f68d Compare March 8, 2026 23:09
@s1r1m1r1 s1r1m1r1 force-pushed the feature/ssa-sprite-optimization branch from 545f68d to 9749376 Compare March 9, 2026 01:10
@s1r1m1r1
Copy link
Contributor Author

s1r1m1r1 commented Mar 9, 2026

I decided to do some further research.

@s1r1m1r1 s1r1m1r1 closed this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants