Skip to content

Phase 5 slice B — Animation blend preview + bake-to-clip #360

Description

@fernandotonon

Overview

Second slice of #260. Live blend two skeletal animations on the active entity with an adjustable weight, then bake the blended result into a new clip.

Slice A (#356) shipped speed scaling + per-entity loop region; this slice builds on that foundation.

Scope

  • New singleton AnimationBlender (or extension of AnimationControlController) that holds:
    • animA, animB — names of the two animations on the active entity
    • weight — 0..1
    • modemix (default), additive, override
    • live state controlled per-frame in MainWindow::frameRenderingQueued
  • Mix: stateA->setWeight(1 - w), stateB->setWeight(w), both enabled.
  • Additive: Skeleton::setBlendMode(ANIMBLEND_CUMULATIVE) on the active entity for the duration of the preview.
  • Override: simple A/B selection — only one state enabled, no blend curve (useful for quick swap previews).
  • Bake: sample the blended state at a fixed dt (default 30 fps), capture each bone's derived position/orientation/scale after _notifyDirty()+update(), write a new Animation track to the entity's skeleton named Blended_<animA>_<animB> (or user-supplied). Reuse AnimationMerger write helpers where possible.

QML

Inline in the Animations section of PropertiesPanel.qml (next to Play/Speed):

  • Two animation pickers (filtered to the active entity's clips)
  • Weight slider 0..1
  • Mode dropdown (Mix / Additive / Override)
  • "Bake to new clip" button + optional clip-name input

Tests

Pure-data fixture (no Ogre):

  • weight=0 ⇒ pure A
  • weight=1 ⇒ pure B
  • weight=0.5 ⇒ midpoint of a synthesized position track

Ogre fixture (Linux CI):

  • After bake, the new animation exists on the skeleton with the expected length and keyframe count
  • Sampling the new animation at midpoint matches the live blend output

Out of scope

  • Blend trees / state machines (multi-state graphs).
  • Cross-entity blending — restricted to the active entity's own skeleton.
  • More than two animations at once. (Plan defers N-way.)

Acceptance criteria

  • Pick two animations on a rigged entity → weight slider visibly mixes them in the viewport
  • Toggle Mode → Mix / Additive / Override behave as documented
  • Click Bake → new clip appears in the Animations list and plays back identically to the live preview at the same weight
  • Speed scaling (slice A) still works while blend preview is active
  • Loop region (slice A) still scopes to the selected animation, not the blended pair

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions