an.stage.solve#
The solve compile pass: joints kept at every frame (ADR 0008 decision 6, an#512).
After every pass that moves a body (the actions, a genre’s poses and faces;
order 525, between face at 500 and camera_follow at 550), the
document so far is evaluated at every frame of the shot’s grid, the joints a
scene declares are solved under the authored motion by an.kinematics,
and one key per frame is emitted for every channel the solve moved. A scene
that declares no joint and no verb compiles byte for byte as before: the pass
returns before it reads anything.
Bodies are read from the built tree and the rigs (an.stage.rig.rig_structure()):
every part of an entity a declaration names is a body posed in stage space
(the root’s own coordinates: scene px from the stage centre), with the extent
of its drawing; its bones’ joints are hinges; a bone with no part is a named
point (paul/fore_r@hand_r). A node that is not a body (a face part) is a
point on the body it rides.
Drivers. What the author wrote is met exactly where the joints allow:
a rig’s ROOT parts (a torso, a prop’s body: nothing hangs them from a parent) stay where they are staged and animated, unless the entity says
overrides: {free: true}(or names the parts:free: [torso]), or apin/pullmoves them (a pinned cup goes to the hand);a part hung from a parent (an arm) is free, except in the channels authored on it; in
nesting: bonesan authored rotation is its joint held at that angle (a weld), since the angle is relative to a parent that may itself move;overrides: {fixed: true}holds every part of an entity where the author put it.
What it emits. One clip per entity, __solve__<entity>, placed last in
that entity’s track (later wins, so a solved channel replaces an authored one
on the same span: that is what a join means), with one quantised key per
frame on x, y and rotation of a part whose parent is not a body
(a root, a part of a flat rig) and rotation alone of a part nested in a
chain (its position follows from its parent’s). A channel the solve never
moves from what the document already shows is not emitted. Under step_hz
the solve runs on the shot’s step grid and the keys are stepped (its own
emission site, as the camera’s). meta.extensions.solve records the mode,
the solver version and effort, a digest of the solve’s inputs, the joints in
solver order, and what could not be held (the joints given up, the rejoins
that snapped, the authored spans the solve overrode): what an validate’s
joint checks read (an.verify.joints).
>>> from an.ir.schema import Shot
>>> declarations(Shot(id="s"), {}).empty
True
Module Attributes
after |
|
The name of the clip of each entity's solved channels ( |
|
The |
Functions
|
The solve's report recorded on a compiled document ( |
|
The joints |
|
The bodies and joints of |
|
A body reference as the point it names: a |
|
A contact's point in its part's own frame (an#519): |
|
The |
|
How far each joined joint of |
|
Whether |
|
The solve's render knobs for the shot-cache key: the solver's version, the shot's mode and effort as declared, and a digest of its declarations. |
|
|
|
The extent a node's body has: its drawing, or a |
|
|
Classes
|
Every joint and verb a shot declares, in solver order (structure first), and what it holds ( |
|
A shot's bodies (structure first) and joints, ready to solve. |
|
A body reference resolved on the compiled document ( |
|
What |
Exceptions
|
A declaration names a body, a point or a joint the shot does not have. |
- class an.stage.solve.Declarations(joints=list(), verbs=list(), problems=list(), holds=None, supports=list(), support_verbs=list())[source]#
Bases:
objectEvery joint and verb a shot declares, in solver order (structure first), and what it holds (
an.stage.hold.HoldDeclarations).A
supportjoint (an#519) is a lint’s declaration, never the solve’s: it goes tosupports, ajoin/unjoinof one tosupport_verbs, and neither makes the declarations non-empty, so a shot declaring only supports runs no solve and compiles as if it declared nothing.- holds: Any = None#
The hold verbs and
held_byoverrides (an.stage.hold), orNone.
- problems: list[tuple[str, str]]#
(where, message)for a declaration that does not read (a descriptor’s).
- supports: list[DeclaredJoint]#
The
supportjoints (an.stage.supportreads them; the solve does not).
- class an.stage.solve.NodePoint(entity, node, local=None, rest_world=None, end=False)[source]#
Bases:
objectA body reference resolved on the compiled document (
locate_point()): the node its point is on, and the point, in that node’s own frame (local), or, for a bone, at rest on the stage (rest_world: each caller maps it into its own frame).endmarks the drawn extent’s far end from the pivot (a hand), which the solve takes at the pivot of a node that only rides on a body.
- class an.stage.solve.PointScope(nodes, entities, rig, landmarks, contacts, rest)[source]#
Bases:
objectWhat
locate_point()resolves a reference against: the compiled document’s nodes by path, the shot’s entities by id, and per entity its rig (orNone), its landmarks and its contacts on a part ({name: (slot, (u, v) or None)}), andrest, a node’s rest stage transform.
- class an.stage.solve.Puppet(bodies, rows, held, events, rest, located=dict(), nodes=dict(), lean=dict())[source]#
Bases:
objectA shot’s bodies (structure first) and joints, ready to solve.
- lean: dict[str, list[float | None]]#
Per-frame rotation targets the hold layer gives bodies (a lean, and what rides on it):
body -> [rotation or None, per frame].
- an.stage.solve.SOLVE_CLIP_PREFIX: str = '__solve__'#
The name of the clip of each entity’s solved channels (
__solve__paul).
- an.stage.solve.SOLVE_ORDER: int = 525#
after
face(500), beforecamera_follow(550).- Type:
Where the pass runs
- exception an.stage.solve.UnknownBodyError(message, problems)[source]#
Bases:
CutoutCompileErrorA declaration names a body, a point or a joint the shot does not have.
problemslists each one as(where, message),whererelative to the shot (joints/0,actions/2): whatan validate’sunknown_bodycheck reports.
- an.stage.solve.build_puppet(doc, shot, mall, decl, *, vocab=None)[source]#
The bodies and joints of
shotas built indoc; raisesUnknownBodyErrornaming every reference it cannot resolve.- Return type:
- an.stage.solve.contact_point(node, point)[source]#
A contact’s point in its part’s own frame (an#519):
pointa fraction(u, v)of the part’s drawing, orNonefor the drawn extent’s far end from its pivot,CONTACT_INSETin. The one point the solve pins and thesupportcheck measures for that contact.>>> from an.stage.serialize import NodeJSON, VisualJSON >>> leg = NodeJSON(name="leg", visual=VisualJSON(width=16, height=100, anchor_y=0)) >>> contact_point(leg, None), contact_point(leg, (0.5, 0.5)) ((0.0, 100.0), (0.0, 50.0))
- an.stage.solve.declarations(shot, mall, *, verbs=True, play_extent=None)[source]#
The joints
shotdeclares (its entities’ descriptors’, its entities’, its own, in that order) and its verbs, flattened to shot time.- Return type:
- an.stage.solve.joint_residuals(doc, shot, mall, *, times=None)[source]#
How far each joined joint of
shotis from holding indoc, at every frame:(puppet, times, gaps[k][j], range_excess[k][j])(px; and radians past a hinge’s range, 0 inside it). An unjoined joint reads 0.
- an.stage.solve.local_box(node)[source]#
The extent a node’s body has: its drawing, or a
DFLT_BODY_EXTENTsquare about its pivot when it draws nothing, or a speck.A drawing under
SPECK_EXTENTon both sides (a one-pixel “empty” key of a swap set, the transparent-part workaround) is not an extent: as a body it would be a speck with its pivot many widths away, whose rotation the solver cannot hold, and the part would drift off its joint. A small drawing (a bead, a button) keeps its own box.>>> from an.stage.serialize import NodeJSON, VisualJSON >>> local_box(NodeJSON(name="speck", visual=VisualJSON(width=1, height=1, anchor_y=68))) (-5.0, -5.0, 10.0, 10.0)
- an.stage.solve.locate_point(ref, scope, *, side)[source]#
A body reference as the point it names: a
NodePoint, a worldPoint(world@x,yor[x, y]), or the message saying why it names none. The one resolver ofbody[@point](an#519): the solve’s (build_puppet(), which puts the node on its bodies) and thesupportcheck’s (an.stage.support).@pointis a fractionu,vof the node’s drawing, a bone of the rig, a landmark (an.genres.EntityKind.landmarks), else a contact (contact_point()).sidesays what no@means:"a"(and"socket") the node’s pivot,"b"the centre of its drawing,"hand"the far end of it from its pivot (its end effector).>>> from types import SimpleNamespace as NS >>> nothing = PointScope({}, {}, lambda e: None, lambda e: {}, lambda e: {}, None) >>> locate_point("world@3,4", nothing, side="a").u 3.0 >>> locate_point("ghost@hand", nothing, side="a") "'ghost@hand': 'ghost' is not an entity of this shot"
- Return type:
- an.stage.solve.node_index(doc)[source]#
{path: node}for every node of a compiled document’s scene tree.
- an.stage.solve.shot_declares_solve(shot, mall=None)[source]#
Whether
shotdeclares anything the solve acts on (the pass’s gate).>>> shot_declares_solve(Shot(id="s")) False
- Return type:
- an.stage.solve.solve_knobs(shot)[source]#
The solve’s render knobs for the shot-cache key: the solver’s version, the shot’s mode and effort as declared, and a digest of its declarations.
>>> sorted(solve_knobs(Shot(id="s"))) ['declared', 'hold_version', 'iterations', 'mode', 'solver_version', 'substeps']
- an.stage.solve.solve_pass(state)[source]#
The
solvecompile pass (orderSOLVE_ORDER). A no-op for a shot that declares no joint and no verb.- Return type:
- an.stage.solve.solve_report(doc)[source]#
The solve’s report recorded on a compiled document (
meta.extensions.solve),{}when the pass recorded nothing: whatan validate’s joint and hold checks read (theholdsentry is the hold layer’s).>>> from types import SimpleNamespace as NS >>> solve_report(NS(meta=NS(extensions={SOLVE_EXTENSION: {"mode": "solve"}}))) {'mode': 'solve'} >>> solve_report(NS(meta=NS(extensions=None))) {}