docs: ADR 0084, the bones guide, roadmap and changelog for springs and joint translation (M7)

This commit is contained in:
Tanish Manku committed 2026-11-13 00:54:34 -07:00
1 parent ef3406b80d
commit 1a6f46364d
7 files changed
+166 -9

No files matched your search

+1
View File
@@ -125,6 +125,7 @@ OR Apache-2.0) is noted in the table.
| WebAssembly plug-in host (module validation, limits, fuel, resumable host calls) | `crates/plugins` | W3C WebAssembly Core Specification 1.0 / 2.0 (W3C Royalty-Free Patent Policy); the `wasmi` interpreter (MIT OR Apache-2.0) | Host model ported from PhotoCraft's filter plug-ins (same project family and licence) and extended with the AniCraft request ABI (ADR 0017). |
| Selection tool on raw shapes: bending an edge (least-squares control-point move), following a bent edge in every shape that shares it, snapping, a marquee that cuts | `crates/geom/src/raw.rs`, `crates/geom/src/planar.rs`, `crates/engine/src/cmds_raw.rs` | Bernstein polynomials and least squares (public mathematical results); behaviour of Animate's Selection tool learned from issue #42, Adobe's public help and observation | Own implementation (ADR 0041); no Adobe code. |
| Inverse kinematics by cyclic coordinate descent (bone drags, `bone.solve`), with joint limits as a clamp per step | `crates/doc/src/armature.rs` | L.-C. T. Wang and C. C. Chen, *A combined optimization method for solving the inverse kinematics problem of mechanical manipulators*, IEEE Trans. Robotics and Automation 7(4), 1991; C. Welman, *Inverse Kinematics and Geometric Constraints for Articulated Figure Manipulation*, MSc thesis, Simon Fraser University, 1993 | Published algorithm; own implementation (ADR 0043). |
| Bone springs: a damped oscillator on each joint driven by the inertia of a pendulum on an accelerating pivot, integrated by backward (implicit) Euler | `crates/doc/src/spring.rs` | L. D. Landau and E. M. Lifshitz, *Mechanics*, §5 and §25 (pendulum with a moving point of support; damped oscillations); E. Hairer and G. Wanner, *Solving Ordinary Differential Equations II: Stiff and Differential-Algebraic Problems*, Springer, 1996 (the implicit Euler method) | Textbook mathematics; own implementation (ADR 0084). |
| Asset Warp: rigid moving-least-squares deformation of a warp mesh's vertices by pins (weights `1 / d²`, the best rotation from the weighted dot and cross of the centred pins), piecewise affine between them | `crates/doc/src/warp.rs`, `crates/render/src/warp.rs` | S. Schaefer, T. McPhail and J. Warren, *Image deformation using moving least squares*, SIGGRAPH 2006, §2.3 | Published method; own implementation (ADR 0079). |
| Linear blend skinning of a shape's outline by its bones (shape armatures: anchors blended by bone weights, handles with their anchors), with weights from the inverse fourth power of the distance to each bone | `crates/doc/src/skin.rs` | N. Magnenat-Thalmann, R. Laperrière and D. Thalmann, *Joint-dependent local deformations for hand animation and object grasping*, Graphics Interface 1988; J. P. Lewis, M. Cordner and N. Fong, *Pose space deformation*, SIGGRAPH 2000, §2 | Published method; own implementation (ADR 0071). |
| Envelope: bicubic Bézier patch warp, inner points from a bicubic Coons patch (ADR 0080) | `crates/geom/src/envelope.rs` | S. A. Coons, *Surfaces for Computer-Aided Design of Space Forms*, MIT Project MAC TR-41, 1967; G. Farin, *Curves and Surfaces for CAGD*, 5th ed., Morgan Kaufmann, 2002 (tensor-product Bézier patches) | Published mathematics; own implementation. |
+15
View File
@@ -2,6 +2,21 @@
## Unreleased
* **Bones, second slice: springs, joint translation and editing members** (ADR 0084, M7).
* **Joint translation**: Properties › Bone › X/Y translation lets a joint slide along the
axes of what the bone starts on, freely or within limits (pixels). Slides are part of each
pose and tween with it; the Selection tool's IK turns joints first and slides them only to
reach where turning can't.
* **Springs**: per-bone Spring (strength) and Damping, 0 to 100. A sprung bone lags behind
and swings past its pose as the bones it hangs from move, then settles, chaining down a
tail. Evaluated as a pure function of the motion up to the frame (no stored state, bounded
replay of at most six seconds), so seeking equals playing bit for bit, and the stage, Test
Movie and every export show it. Springs: Enable turns an armature's springs off for posing.
* **Members edited in place**: picking a bone selects the instance it moves; its colour
effect, blending and filters change on every pose, one undo step, the armature intact.
* Headless: `bone.set_translation`, `bone.set_spring`, `bone.enable_springs`, `slide_x` /
`slide_y` on `bone.pose`; `bone.info` reports slides, springs and each bone's swing.
* **Camera, second slice: layer depth, attaching layers and colour** (ADR 0082, M7).
* **Layer depth in perspective**: through the camera, a pinhole with a fixed focal length
(1,000 px), a deeper layer moves less when the camera pans and grows less when it zooms;
@@ -100,7 +100,8 @@ list, and every edit is a command.
* ~~Shape armatures (bones inside a shape, with binding of its points) and the Bind tool~~:
ADR 0071. Their bones join joint nodes inside the shape and reuse this ADR's poses, forward
kinematics and CCD solver unchanged.
* Spring and damping, joint translation (Animate's X/Y joint constraints), Animate's runtime
armatures (poses that ActionScript drives), and XFL import of armature layers.
* Editing instance properties of armature members in place; armature layers under masks and
motion guides; an IK drag that keeps pinned bones *below* the dragged one in place.
* ~~Spring and damping, joint translation (Animate's X/Y joint constraints)~~: ADR 0084.
Animate's runtime armatures (poses that ActionScript drives), and XFL import of armature
layers.
* ~~Editing instance properties of armature members in place~~ (colour effect, blending,
filters: ADR 0084); armature layers under masks and motion guides; an IK drag that keeps pinned bones *below* the dragged one in place.
@@ -0,0 +1,112 @@
# ADR 0084: Bone springs, joint translation and editing armature members in place
* Status: accepted (2026-11-13)
* Relates to: roadmap M7 (Bone/IK tool), ADR 0043 (armatures), ADR 0071 (shape armatures),
ADR 0003 (file format), ADR 0004 (destructive actions), ADR 0056 (colour effects)
## Context
ADR 0043 and ADR 0071 left three things Animate artists reach for when rigging: **joint
translation** (a joint that slides along X and/or Y within limits, like a piston or a neck that
extends), **springs** (per-bone strength and damping: a tail that lags behind and swings after
the body moves), and **editing a member's look** (colour effect, filters, blending) on the
armature layer, which ADR 0043 refused with every other artwork edit. Behaviour was learned from
Adobe's public help pages and from watching the program; nothing was copied. The hard
constraint is ADR 0001's: time is a function. A spring is a simulation, and simulations carry
state from frame to frame; `evaluate` must not.
## Decision
1. **Joint translation is part of the pose.** `Bone.slide_x` / `slide_y: Option<Limits>` (in
pixels, at most ±10,000; `None`: the joint doesn't slide that way; ±10,000 is "enabled,
unconstrained"). `JointAngle` gains `x`, `y`, the slide at that pose, written only when not
0 (`#[serde(default, skip_serializing_if)]`), so poses without slides read and write exactly
as before. The slide is along the **x and y axes of what the bone starts on** (the parent
instance, or the parent joint node of a shape armature), normalised to unit length so the
limits are pixels whatever the parent's scale, and turning with the parent so a piston keeps
its line as the arm holding it swings. Forward kinematics becomes
`W_child = R_joint'(a) · T(d) · W_parent · rest`, with `d` the slide in layer space and
`joint'` the joint moved by `d`. With no slide it is ADR 0043's formula, computed the same
way, so existing armatures place bit for bit. Slides tween linearly with the angles and are
clamped to the limits on evaluation, as angles are.
2. **IK slides only where turning can't reach.** `armature::solve` runs ADR 0043's CCD on the
angles alone first; only when that leaves the effector farther than the tolerance and a
movable bone slides does a second round of sweeps also slide each joint, after turning it,
by the projection of the remaining error on its enabled axes (the exact 2×2 solve when both
are on), clamped. A target the joints reach by turning is solved exactly as before, which
keeps posing predictable: a bone that may slide still bends first and stretches only when
pulled beyond its reach, and a joint that may not turn (limits 0…0) but slides is a piston.
3. **A spring is evaluated, never stored.** `Bone.spring: Option<Spring { strength, damping }>`
(each 0…1, shown 0–100). Each sprung bone carries an angle `φ` off its keyed angle, driven
by the keyed motion's accelerations (the joint's linear acceleration across the bone and the
keyed direction's angular acceleration: the inertia of a pendulum on a moving pivot) and
pulled back by a damped spring: `φ'' = −θ_key'' − (a_joint · n)/L − ω²φ − 2ζωφ'`. Strength
maps to the natural frequency (0.5 Hz to 10 Hz, even in pitch); damping `d` to the ratio
`ζ = ½·d/(1−d)` (0 swings on, ⅔ is critical, 1 is infinite: the swing never starts). Springs
chain: a bone's keyed direction is taken from its parent *as swung*, so a tail whips.
`spring::sprung_pose(layer, frame, fps)` replays the motion from a fixed start for every
frame it is asked about: at most six seconds back (720 frames at most), never before the run
of keyframes the frame is on, two frames before that only to know the motion's speed. Every
step is a fixed function of the frames before it, so **seeking to a frame gives exactly the
bits playing to it does**, and the stage, the player, Test Movie and every export agree with
no cache. Motion in the older half of the window counts less and less (a smoothstep taper of
the drive), so a swing fades out smoothly instead of jumping when its cause leaves the
window; this bounds a damping-0 spring's ring to six seconds, the price of statelessness.
The integrator is backward Euler with four steps per frame, stable for any strength, damping
and frame rate; the swing is clamped to half a turn and stopped by the joint's limits. Time
is in seconds (the stage's frame rate), so a spring looks alike at 24 and 48 fps.
Measured (release, this machine): 16 sprung bones, 24 fps, 144 frames replayed: 0.33 ms per
evaluated frame.
4. **Where springs apply.** `evaluate_shown(layer, frame, guide, fps)` is `evaluate_guided`
with the sprung pose; `eval_timeline` (so `evaluate`, every raster and vector export, onion
skins, the GPU stage), the player and the HTML canvas exporter (which bakes every frame) use
it, so every export sees the swing with no change of its own. Commands keep editing the
**keyed** pose through `evaluate_guided`: springs never write to the file, and the solver
works on what is keyed. The stage draws the bones swung, as the artwork shows. `Armature.
springs_off` (Properties › Bone › Springs: Enable, `bone.enable_springs`) plays the keyed
poses exactly, as Animate's per-armature spring switch does, for posing without the swing.
Damping 100, strength 0 or springs off give the keyed pose bit for bit (tested).
5. **Members are edited in place on every pose.** `element.set_color_effect`, `set_alpha`,
`set_blend` and `set_filters` work on armature members through
`Session::selected_props_mut`: on an armature layer the selected members change on every
keyframe of the layer, in one undo step, with no frame keyed, the bones and poses untouched.
The look is a property of the member, not of a pose, which is what an artist tinting a limb
expects, and it leaves nothing for a pose tween to blend. Every other artwork edit is still
refused there (ADR 0043). Picking a bone selects the instance it moves, and Properties shows
only the member's Colour effect, Blending and Filters, with a line saying its bone places it.
6. **Commands** (in the `bone.*` namespace plug-ins may already call): `bone.set_translation
{bone, axis, enabled?, constrain?, min?, max?}`, `bone.set_spring {bone, strength?,
damping?}`, `bone.enable_springs {enabled, layer? | bone?}`, `slide_x` / `slide_y` on
`bone.pose`, and `bone.info` reports slides, translation limits, springs, each bone's swing
at the frame and whether springs are on. Each is one undo step; none destroys anything, so
none asks (ADR 0004).
## Instances and shapes in one armature: proposed, not built
It doesn't fit cleanly in this slice. ADR 0071's skin is the armature's *one* shape, its joint
nodes are no elements, and `place`, `roots`, `sanitize`, `bone.remove` and the Bind tool all
branch on "skinned or not". Mixing them needs nodes that may be either an instance or a joint
node inside a shape, more than one skin per armature, and rules for what removing a bone frees.
The proposal: `Armature.skins: Vec<Skin>` keyed by shape, a bone's `parent`/`child` naming an
instance, a shape, or a node of one, `place` unchanged (it already places both), and the Bone
tool allowed to drag from a shape's bone end onto an instance. It is its own ADR and PR.
## Consequences
* Files without slides or springs are written exactly as before; an older AniCraft ignores the
new fields and plays the keyed poses without slides or springs (the file holds the keyed
poses, and each keyframe's elements as posed).
* Evaluating a sprung armature costs a replay of up to six seconds of its motion per frame;
armatures without live springs cost nothing extra.
* Hostile files are repaired on load: non-finite limits and springs go, limits are clamped to
±10,000 px, slides in poses to the same, strengths and damping to 0…1.
## Not yet
* Instances and shapes in one armature (above); gravity, wind and per-armature spring presets;
springs on the root's own motion of a shape armature's outline points (only bones swing).
* An IK drag that slides joints by preference rather than only to reach; translation limits
drawn on the stage.
* Runtime armatures driven by scripts, XFL import of armatures (with their springs and
translation), and baking the swing into keyframes (Convert to Keyframes) for formats that
can't evaluate it; every export today evaluates through `evaluate`, so none needs it yet.
-1
View File
@@ -23,4 +23,3 @@ has to renumber because another PR merged first.
| Number | Pull request | Topic |
|---|---|---|
| 0037 | #38 (outside contribution) | Interface languages |
| 0084 | m7/bones-spring | Bones: spring, joint translation, editing members |
+25 -2
View File
@@ -213,10 +213,32 @@ Select a bone to see **Properties › Bone**:
pose.
* **Pin**: the bone, and the bones it hangs from, stay put while you drag the bones below it.
Handy for keeping a shoulder in place while you pose a hand.
* **X translation** and **Y translation**: **Enable** lets the joint slide along the x or y axis
of what the bone starts on (as that part is turned), so the bone can stretch away from it,
like a piston or a neck that extends. **Constrain** limits how far, with **Limits** (min and
max, in pixels). **Slide** sets how far the joint has slid at the playhead, and keys the pose.
When you drag with the **Selection** tool, joints turn first and slide only to reach where
turning can't.
* **Spring** and **Damping** (0 to 100): secondary motion. A bone with a spring lags behind
when the bones it hangs from move, swings past its pose and settles back, like a tail, an
antenna or a ponytail. A higher **Spring** is stiffer: it swings faster and lags less; 0 is
no spring. **Damping** sets how quickly the swing dies down: 0 swings on for a while, 100
absorbs it all.
* **Springs: Enable** turns every spring of the armature on or off. Turn them off while you
pose, to see exactly the poses you key; Test Movie and every export play them while they
are on.
* **Remove Bone** (or **Delete**): removes the bone and those below it. Their instances stay
where they are, on a layer of their own. If the armature has more than one pose, AniCraft asks
first.
Selecting a bone also selects the instance it moves. Properties then shows that instance's
**Colour effect**, and for movie clips and buttons its **Blending** and **Filters**. Change
them there, and the instance keeps the look in every pose, while its bone still places it.
Springs never change your poses: AniCraft works out the swing from how the armature moves up
to each frame, so jumping to a frame shows exactly what playing to it shows. Each swing fades
out within six seconds of the motion that caused it.
### Bones inside a shape
A shape can have bones of its own, so the shape itself bends, like a tail, a tentacle or a
@@ -247,9 +269,10 @@ to pick it, and the points it moves fill in. Then:
back to the automatic binding. Adding or removing bones rebinds the points you haven't bound
by hand.
Bones inside a shape take joint translation and springs too.
Not there yet: symbols and shapes in one armature, reshaping a shape after it has bones,
springs, joints that slide, armatures that scripts pose while the movie plays, and armatures
from Animate files.
armatures that scripts pose while the movie plays, and armatures from Animate files.
## Asset Warp
+8 -2
View File
@@ -351,14 +351,20 @@ These commands have no menu item: the panels, the stage and the timeline use the
Parameters: `{bone} removes it and the bones below it; the instances they moved go to a layer of their own as they look at the playhead (with the last bone, the whole armature does); asks first when the armature has more than one pose`
- **Joint Limits** `bone.set_limits` · changes the document
Parameters: `{bone, constrain?: bool (false: turns freely), min?, max? (°, −360…360, from where it was drawn)} limits how far the joint turns, in every pose`
- **Joint Translation** `bone.set_translation` · changes the document
Parameters: `{bone, axis: "x" | "y" (along the axes of what the bone starts on, as it is turned), enabled?: bool (false: the joint doesn't slide that way), constrain?: bool (false: slides freely), min?, max? (px, ±10,000, from where it was drawn)} lets the joint slide, in every pose; posing (bone.solve, the Selection tool) slides it only where turning can't reach`
- **Bone Spring** `bone.set_spring` · changes the document
Parameters: `{bone, strength? (0–100: 0 is no spring; stiffer swings faster and lags less), damping? (0–100: how quickly the swing dies down; 100 absorbs it all)} secondary motion: the bone lags behind and swings past its pose as the bones it hangs from move, then settles. Evaluated, never stored: the keyed poses don't change`
- **Enable Springs** `bone.enable_springs` · changes the document
Parameters: `{enabled: bool, layer? (the armature layer) | bone?} turns the armature's springs on or off (off: it plays its keyed poses exactly, as while posing)`
- **Pin Bone** `bone.pin` · changes the document
Parameters: `{bone, pinned: bool} a pinned bone (and the bones it hangs from) stays put while dragging bones below it`
- **Pose Bone** `bone.pose` · changes the document
Parameters: `{bone?, angle? (°, the joint angle: 0 as drawn), rotate_by? (°), dx?, dy? (moves the whole armature), layer? (the armature layer, when no bone is given), frame?} keys the pose at the frame`
Parameters: `{bone?, angle? (°, the joint angle: 0 as drawn), rotate_by? (°), slide_x?, slide_y? (px: how far the joint slides, within its translation limits), dx?, dy? (moves the whole armature), layer? (the armature layer, when no bone is given), frame?} keys the pose at the frame`
- **Drag Bone** `bone.solve` · changes the document
Parameters: `{bone, x, y (stage px: where the bone's end goes), local?: [x, y] (the point dragged, in the bone's instance's space; default its end), frame?} → {reached, error (px), chain}; inverse kinematics turns the bone and the bones above it (limits respected, pinned bones kept)`
- **Armatures** `bone.info`
Parameters: `{frame?, layer?, points?: bool} → every armature on the scene at the frame: its bones with joint and end (stage px), joint angle and limits (°), pinned; a shape armature's shape, how many points each bone moves, and with points the shape's points (stage px) and the bones each follows`
Parameters: `{frame?, layer?, points?: bool} → every armature on the scene at the frame: its bones with joint and end (stage px, as keyed), joint angle and limits (°), slide and translation limits (px), spring (0–100) and its swing at the frame (°, what the spring adds to the angle), pinned; whether springs are on; a shape armature's shape, how many points each bone moves, and with points the shape's points (stage px) and the bones each follows`
- **Add Warp Pin** `warp.pin_add` · changes the document
Parameters: `{element?, x, y (stage px, on the artwork)} → {element, pin, created}. Pins the artwork there (adding the mesh first if it has none), on every keyframe that bends the same mesh; nothing moves`
- **Move Warp Pin** `warp.pin_move` · changes the document