Grid Point Animation #124

Open
opened 2025-07-12 19:11:49 +00:00 by john · 1 comment
Owner

Enable animating individual grid tiles (color, tilesprite animations).
Definition of Done:

  • Can animate tile colors independently
  • Sprite index animation for effects
  • Efficient batch animation support
  • Matrix-style demo effects possible
Enable animating individual grid tiles (color, tilesprite animations). Definition of Done: - Can animate tile colors independently - Sprite index animation for effects - Efficient batch animation support - Matrix-style demo effects possible
Author
Owner

Current Architecture

Animation System:

  • Targets either UIDrawable (Frame, Caption, Sprite, Grid) or UIEntity
  • Uses std::weak_ptr for RAII-safe target tracking
  • Properties applied via target->setProperty(name, value)

Grid Cells:

  • Grid points are raw storage: std::vector<UIGridPoint>
  • Layer data is raw arrays: std::vector<sf::Color> or std::vector<int>
  • Layers themselves ARE shared_ptr wrapped
  • markDirty(x, y) mechanism already exists for efficient per-cell updates

The Core Challenge

The animation system fundamentally requires shared_ptr targets for:

  1. RAII safety (detecting destroyed targets via weak_ptr::expired())
  2. Property locking (#120 - conflict detection)
Approach Description
A: Cell Reference Wrapper New GridCellRef class wrapping (layer, x, y) with getProperty/setProperty
B: startCell() Method Add anim.startCell(layer, x, y) to Animation class
C: Batch Animation New GridAnimation class for multi-cell animations
D: Layer Methods Add layer.animate_cell(x, y, value, duration)

Recommended Approach: B + C Hybrid

  1. Primary: Add startCell(layer, x, y) to Animation class (4-5 hours)
  • New target tracking: weak_ptr or weak_ptr
  • New applyValue() overloads for layer cells
  • Property locking uses key: (layer_ptr, "cell[x,y].property")
  1. Optional Enhancement: Batch helper for Matrix effects (3-4 hours)
  • Simple Python helper function, not new C++ class
  • Creates multiple animations efficiently

We won't be implementing for 1.0, this is getting deferred for a while

## Current Architecture Animation System: - Targets either `UIDrawable` (`Frame`, `Caption`, `Sprite`, `Grid`) or `UIEntity` - Uses `std::weak_ptr` for RAII-safe target tracking - Properties applied via `target->setProperty(name, value)` Grid Cells: - Grid points are raw storage: `std::vector<UIGridPoint>` - Layer data is raw arrays: `std::vector<sf::Color>` or `std::vector<int>` - Layers themselves ARE `shared_ptr` wrapped - `markDirty(x, y)` mechanism already exists for efficient per-cell updates ## The Core Challenge The animation system fundamentally requires `shared_ptr` targets for: 1. RAII safety (detecting destroyed targets via `weak_ptr::expired()`) 2. Property locking (#120 - conflict detection) | Approach | Description | |---------------------------|---------------------------------------------------------------------------| | A: Cell Reference Wrapper | New GridCellRef class wrapping (layer, x, y) with getProperty/setProperty | | B: startCell() Method | Add anim.startCell(layer, x, y) to Animation class | | C: Batch Animation | New GridAnimation class for multi-cell animations | | D: Layer Methods | Add layer.animate_cell(x, y, value, duration) | Recommended Approach: B + C Hybrid 1. Primary: Add startCell(layer, x, y) to Animation class (4-5 hours) - New target tracking: weak_ptr<ColorLayer> or weak_ptr<TileLayer> - New applyValue() overloads for layer cells - Property locking uses key: (layer_ptr, "cell[x,y].property") 2. Optional Enhancement: Batch helper for Matrix effects (3-4 hours) - Simple Python helper function, not new C++ class - Creates multiple animations efficiently We won't be implementing for 1.0, this is getting deferred for a while
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
john/McRogueFace#124
No description provided.