Skip to main content

ssruntime/eval/
mod.rs

1//! The evaluation core — everything that turns `.ssab` data plus a time into drawable state.
2//!
3//! | Module | Responsibility |
4//! |---|---|
5//! | [`playback_controller`] | Transport, loop counting, ping-pong, seek, FPS and playback range. |
6//! | [`interpolation`] | Keyframe curve evaluation (delegates the maths to [`crate::interpolate`]). |
7//! | [`matrix`] / [`geometry`] | Transform composition and vertex/mesh geometry. |
8//! | [`framedata`] | Builds the per-frame FlatBuffer and the DrawBatch plan a Player consumes. |
9//! | [`override_layer`] | Per-part runtime overrides of color, cell and visibility. |
10//! | [`effect`] | Particle effect simulation. |
11//! | [`z_order`] | Draw-order resolution. |
12//! | [`ssab_lookup`] | Name/hash lookups into the loaded binary. |
13//!
14//! The enums defined here — [`SsCoordinateSystem`], [`SsOrigin`], [`SsUnit`] and
15//! [`RenderMode`] — are the knobs that adapt output to a host engine's conventions.
16//! Getting them right is usually the first thing a new Player has to do: a Y-down
17//! engine fed Y-up output renders upside down.
18
19pub mod effect;
20pub mod framedata;
21pub mod interpolation;
22pub mod keyframes;
23pub mod math;
24pub mod matrix;
25pub mod override_layer;
26pub mod playback_controller;
27pub mod ssab_lookup;
28pub mod z_order;
29
30/// The Y direction of what the runtime emits.
31#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
32pub enum SsCoordinateSystem {
33    /// Y grows upward, as SpriteStudio authors it. `0` in the C-API.
34    #[default]
35    YUp,
36    /// Y grows downward: Y coordinates and rotation are flipped. `1` in the C-API.
37    YDown,
38}
39
40/// Whether a part's Skew (shear) inherits down to its children.
41/// true == inherits down to children.
42/// false == does not inherit.
43pub const SKEW_PROPAGATES: bool = false;
44
45/// Where the positions the runtime emits are measured from.
46#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
47pub enum SsOrigin {
48    /// The canvas center. `0` in the C-API.
49    #[default]
50    Center,
51    /// The canvas's top-left corner: root parts are offset by half the canvas. `1`
52    /// in the C-API.
53    TopLeft,
54}
55
56/// The unit of the part positions the runtime emits.
57#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
58pub enum SsUnit {
59    /// Pixels. `0` in the C-API.
60    #[default]
61    Pixel,
62    /// Each part's position is divided by the canvas size. Sizes, local vertices and
63    /// UVs stay in pixels. `1` in the C-API.
64    Normalized,
65}
66
67/// What a frame computes, by how the Player draws it.
68#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
69pub enum RenderMode {
70    /// World matrices and mesh vertices are computed. `0` in the C-API.
71    #[default]
72    Direct,
73    /// World matrices are not computed, for a Player that composes parts in its own
74    /// scene graph. `1` in the C-API.
75    SceneGraph,
76}
77
78impl RenderMode {
79    pub fn from_u8(value: u8) -> Self {
80        match value {
81            1 => RenderMode::SceneGraph,
82            _ => RenderMode::Direct,
83        }
84    }
85}
86
87pub use matrix::{SsMatrix4x4, SsVector3};
88pub mod geometry;
89pub use geometry::*;