Animation Property Locking #120

Closed
opened 2025-07-12 19:06:28 +00:00 by john · 1 comment
Owner

Prevent multiple animations from conflicting on the same property.
Definition of Done:

  • Only one animation per property at a time
  • Later animations either queue or override (configurable)
  • No visual glitches from conflicting animations
  • Clear error messages for conflicts
Prevent multiple animations from conflicting on the same property. Definition of Done: - Only one animation per property at a time - Later animations either queue or override (configurable) - No visual glitches from conflicting animations - Clear error messages for conflicts
Author
Owner

Implementation Complete (commit 58efffd)

Animation property locking is now implemented with three conflict modes:

API

anim = mcrfpy.Animation("x", 500.0, 2.0, "linear")

# Default behavior - replace existing animation
anim.start(frame)

# Explicitly specify conflict mode
anim.start(frame, conflict_mode="replace")  # Complete old, start new
anim.start(frame, conflict_mode="queue")    # Wait for existing to complete
anim.start(frame, conflict_mode="error")    # Raise RuntimeError if busy

Behavior

Mode When Property Busy Effect
replace Old animation jumps to final value New animation starts immediately
queue New animation is queued Starts automatically when property freed
error RuntimeError raised No change to existing animation

Technical Details

  • Property locks tracked per (target_ptr, property_name) pair
  • Locks automatically cleaned up when animations complete or targets destroyed
  • Queue processed after each animation manager update
  • Different properties on same target can animate simultaneously
  • Same property on different targets can animate simultaneously

Test Coverage

Added tests/unit/test_animation_property_locking.py with 8 tests covering:

  • Replace mode (default and explicit)
  • Queue mode
  • Error mode with proper exception
  • Invalid conflict_mode validation
  • Different properties (no conflict)
  • Different targets (no conflict)
  • Replace mode completing old animation value
## Implementation Complete (commit 58efffd) Animation property locking is now implemented with three conflict modes: ### API ```python anim = mcrfpy.Animation("x", 500.0, 2.0, "linear") # Default behavior - replace existing animation anim.start(frame) # Explicitly specify conflict mode anim.start(frame, conflict_mode="replace") # Complete old, start new anim.start(frame, conflict_mode="queue") # Wait for existing to complete anim.start(frame, conflict_mode="error") # Raise RuntimeError if busy ``` ### Behavior | Mode | When Property Busy | Effect | |------|-------------------|--------| | `replace` | Old animation jumps to final value | New animation starts immediately | | `queue` | New animation is queued | Starts automatically when property freed | | `error` | RuntimeError raised | No change to existing animation | ### Technical Details - Property locks tracked per `(target_ptr, property_name)` pair - Locks automatically cleaned up when animations complete or targets destroyed - Queue processed after each animation manager update - Different properties on same target can animate simultaneously - Same property on different targets can animate simultaneously ### Test Coverage Added `tests/unit/test_animation_property_locking.py` with 8 tests covering: - Replace mode (default and explicit) - Queue mode - Error mode with proper exception - Invalid conflict_mode validation - Different properties (no conflict) - Different targets (no conflict) - Replace mode completing old animation value
john closed this issue 2025-12-28 18:23:44 +00:00
Sign in to join this conversation.
No milestone
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#120
No description provided.