# animation_state_machine.h ## Overview
Implements an Animation State Machine. The Animation State Machine is responsible for handling transitions between separate "animation states" and blending together animations for a character.
## Index
Truth objects
`enum tm_asm_state_interface_properties`
`TM_TT_ASPECT__ASM_STATE_INTERFACE`
`TM_TT_TYPE__ASM_REGULAR_STATE`
`enum TM_TT_PROP__ASM_REGULAR_STATE`
`TM_TT_TYPE__ASM_RANDOM_STATE`
`enum TM_TT_VALUE__ASM_RANDOM_STATE__STRATEGY`
`enum TM_TT_PROP__ASM_RANDOM_STATE`
`TM_TT_TYPE__ASM_RANDOM_STATE_ANIMATION`
`enum TM_TT_PROP__ASM_RANDOM_STATE_ANIMATION`
`TM_TT_TYPE__ASM_BLEND_STATE`
`enum tm_tt_value__asm_blend_state__dimensions`
`enum TM_TT_PROP__ASM_BLEND_STATE`
`TM_TT_TYPE__ASM_BLEND_STATE_ANIMATION`
`enum TM_TT_PROP__ASM_BLEND_STATE_ANIMATION`
`TM_TT_TYPE__ASM_EMPTY_STATE`
`enum tm_asm_transition_interface_properties`
`TM_TT_ASPECT__ASM_TRANSITION_INTERFACE`
`TM_TT_TYPE__ASM_REGULAR_TRANSITION`
`enum tm_tt_value__asm_regular_transition__on`
`enum TM_TT_PROP__ASM_REGULAR_TRANSITION`
`TM_TT_TYPE__ASM_LAYER`
`enum TM_TT_PROP__ASM_LAYER`
`TM_TT_TYPE__ASM_EVENT`
`enum TM_TT_PROP__ASM_EVENT`
`TM_TT_TYPE__ASM_VARIABLE`
`enum TM_TT_PROP__ASM_VARIABLE`
`TM_TT_TYPE__ASM_BLEND_SET_WEIGHT`
`enum TM_TT_PROP__ASM_BLEND_SET_WEIGHT`
`TM_TT_TYPE__ASM_BLEND_SET`
`enum TM_TT_PROP__ASM_BLEND_SET`
`TM_TT_TYPE__ASM_CONSTRAINT`
`enum TM_TT_PROP__ASM_CONSTRAINT`
`TM_TT_TYPE__ASM_MOTION_MIXER`
`enum TM_TT_PROP__ASM_MOTION_MIXER`
`TM_TT_TYPE__ASM_MOTION_MIXER_SLIDER`
`enum TM_TT_PROP__ASM_MOTION_MIXER_SLIDER`
`TM_TT_TYPE__ASM_MOTION_MIXER_BUTTON`
`enum TM_TT_PROP__ASM_MOTION_MIXER_BUTTON`
`TM_TT_TYPE__ASM_MOTION_MIXER_VARIABLE_KEY`
`enum TM_TT_PROP__ASM_MOTION_MIXER_VARIABLE_KEY`
`TM_TT_TYPE__ASM_MOTION_MIXER_EVENT_KEY`
`enum TM_TT_PROP__ASM_MOTION_MIXER_EVENT_KEY`
`TM_TT_TYPE__ANIMATION_STATE_MACHINE`
`enum TM_TT_PROP__ANIMATION_STATE_MACHINE`

API
`tm_animation_state_machine_manager_o`
`tm_animation_state_machine_o`
`TM_STATE_MACHINE__MAX_LAYERS`
`TM_STATE_MACHINE__MAX_VARIABLES`
`struct tm_animation_state_machine_state_t`
`struct tm_animation_state_machine_trigger_t`
`struct tm_animation_state_machine_constraint_t`

`struct tm_animation_state_machine_api`
`compile()`
`create_manager()`
`destroy_manager()`
`create_state_machine()`
`destroy_state_machine()`
`state()`
`set_state()`
`event()`
`tick_state_machine()`
`tick()`
`pose()`
`locomotion_delta()`
`get_variable()`
`set_variable()`
`is_state_playing()`
`triggers()`
`constraints()`

`tm_animation_state_machine_api_version`
## API

Truth objects

### `enum tm_asm_state_interface_properties`
Properties shared by all Truth types that represent states in the Animation State Machine. This defines a common interface (or if you so want, an abstract base class) for all animation states. !!! TODO: TODO * ??? Emit end event * ??? Muted layers ~~~c enum tm_asm_state_interface_properties { // Name of the state. TM_TT_PROP__ASM_STATE__NAME, // string // Sort order in the list of states. TM_TT_PROP__ASM_STATE__SORT_ORDER, // double // Position of the the node representing the state. TM_TT_PROP__ASM_STATE__POSITION_X, // float TM_TT_PROP__ASM_STATE__POSITION_Y, // float // [[TM_TT_TYPE__ASM_BLEND_SET]] to use for the state. TM_TT_PROP__ASM_STATE__BLEND_SET, // reference [[TM_TT_TYPE__ASM_BLEND_SET]] // [[expression_language.h]] expression for computing the speed at which the state should be // played. TM_TT_PROP__ASM_STATE__SPEED, // string // [[TM_TT_TYPE__ASM_CONSTRAINT]] enabled in this state. TM_TT_PROP__ASM_STATE__CONSTRAINTS, // subobject_set [[TM_TT_TYPE__ASM_CONSTRAINT]] // Index of first custom state property for Truth types implementing this interface. TM_TT_PROP__ASM_STATE__FIRST_CUSTOM, }; ~~~
### `TM_TT_ASPECT__ASM_STATE_INTERFACE`
~~~c #define TM_TT_ASPECT__ASM_STATE_INTERFACE ~~~ Aspect that indicates that a Truth Type implements the `enum tm_asm_state_interface_properties` interface.
### `TM_TT_TYPE__ASM_REGULAR_STATE`
~~~c #define TM_TT_TYPE__ASM_REGULAR_STATE "tm_asm_regular_state" #define TM_TT_TYPE_HASH__ASM_REGULAR_STATE TM_STATIC_HASH("tm_asm_regular_state", 0x59fee4d09be9ff70ULL) ~~~ State for Regular animations.
### `enum TM_TT_PROP__ASM_REGULAR_STATE`
Properties for the Regular state. ~~~c enum { // Animation that should be played in this state. TM_TT_PROP__ASM_REGULAR_STATE__ANIMATION = TM_TT_PROP__ASM_STATE__FIRST_CUSTOM, // reference [[TM_TT_TYPE__ANIMATION_CLIP]] }; ~~~
### `TM_TT_TYPE__ASM_RANDOM_STATE`
~~~c #define TM_TT_TYPE__ASM_RANDOM_STATE "tm_asm_random_state" #define TM_TT_TYPE_HASH__ASM_RANDOM_STATE TM_STATIC_HASH("tm_asm_random_state", 0x3449e1af19be66fcULL) ~~~ State that plays a random animation clip out of a weighted selection. Each time the animation loops a new random clip is picked.
### `enum TM_TT_VALUE__ASM_RANDOM_STATE__STRATEGY`
Strategy used by `TM_TT_TYPE__ASM_RANDOM_STATE` to pick the next random animation. ~~~c enum { // The state will never play the same clip twice in a row, other than that, the pick is // random. TM_TT_VALUE__ASM_RANDOM_STATE__STRATEGY__DONT_REPEAT, // The animation for each loop will be picked independent of any previous picks. This may result // in the same animation repeating itself multiple times. TM_TT_VALUE__ASM_RANDOM_STATE__STRATEGY__INDEPENDENT_PICK, // The state will shuffle all the clips (like a deck of cards) and play them in the // randomized order. When all animations have been played a new shuffle is made and the // animations are played again. The randomizer also make sure that in the transition from // one shuffle to the next, animations are not repeated. TM_TT_VALUE__ASM_RANDOM_STATE__STRATEGY__SHUFFLE, }; ~~~
### `enum TM_TT_PROP__ASM_RANDOM_STATE`
Properties for the Random state. ~~~c enum { // Strategy to use for randomizing animations. // uint32_t(enum TM_TT_VALUE__ASM_RANDOM_STATE__STRATEGY__*) TM_TT_PROP__ASM_RANDOM_STATE__STRATEGY = TM_TT_PROP__ASM_STATE__FIRST_CUSTOM, // When animation loops, crossfade it with itself over this amount of time. Default is zero // which means no crossfade -- the animation will hard transition to the next random clip. This // only works if the start and end states of the animation are identical. TM_TT_PROP__ASM_RANDOM_STATE__LOOP_CROSSFADE_TIME, // float // Animation that should be played in this state. TM_TT_PROP__ASM_RANDOM_STATE__ANIMATIONS, // subobject [[TM_TT_TYPE__ASM_RANDOM_STATE_ANIMATION]] }; ~~~
### `TM_TT_TYPE__ASM_RANDOM_STATE_ANIMATION`
~~~c #define TM_TT_TYPE__ASM_RANDOM_STATE_ANIMATION "tm_asm_random_state_animation" #define TM_TT_TYPE_HASH__ASM_RANDOM_STATE_ANIMATION TM_STATIC_HASH("tm_asm_random_state_animation", 0x305e388654972dcaULL) ~~~ Type for an individual animation in a Random state.
### `enum TM_TT_PROP__ASM_RANDOM_STATE_ANIMATION`
Properties for an invididual animation in a Random state. ~~~c enum { // Animation to play. TM_TT_PROP__ASM_RANDOM_STATE_ANIMATION__ANIMATION, // reference [[TM_TT_TYPE__ANIMATION_CLIP]] // Weight for the random pick. When we make a random pick, each animation will be picked with // likelihood corresponding to its weight value. TM_TT_PROP__ASM_RANDOM_STATE_ANIMATION__WEIGHT, // float }; ~~~
### `TM_TT_TYPE__ASM_BLEND_STATE`
~~~c #define TM_TT_TYPE__ASM_BLEND_STATE "tm_asm_blend_state" #define TM_TT_TYPE_HASH__ASM_BLEND_STATE TM_STATIC_HASH("tm_asm_blend_state", 0x92fcc955018db6e3ULL) ~~~ State that blends together a number of animations based on a 1D or 2D blend map.
### `enum tm_tt_value__asm_blend_state__dimensions`
Specifies whether blending happens in 1D or 2D. ~~~c enum tm_tt_value__asm_blend_state__dimensions { TM_TT_VALUE__ASM_BLEND_STATE__DIMENSIONS__1D, TM_TT_VALUE__ASM_BLEND_STATE__DIMENSIONS__2D, }; ~~~
### `enum TM_TT_PROP__ASM_BLEND_STATE`
Properties for the Blend state. ~~~c enum { // Specifies one- or two-dimensional blend. TM_TT_PROP__ASM_BLEND_STATE__DIMENSIONS = TM_TT_PROP__ASM_STATE__FIRST_CUSTOM, // uint32_t(enum tm_tt_value__asm_blend_state__dimensions) // Variables that control the blend. [[TM_TT_PROP__ASM_BLEND_STATE__VARIABLE_Y]] is only used // if the blend is a 2D blend. TM_TT_PROP__ASM_BLEND_STATE__VARIABLE_X, // reference [[TM_TT_TYPE__ASM_VARIABLE]] TM_TT_PROP__ASM_BLEND_STATE__VARIABLE_Y, // reference [[TM_TT_TYPE__ASM_VARIABLE]] // Animations to blend between. TM_TT_PROP__ASM_BLEND_STATE__ANIMATIONS, // subobject [[TM_TT_TYPE__ASM_BLEND_STATE_ANIMATION]] }; ~~~
### `TM_TT_TYPE__ASM_BLEND_STATE_ANIMATION`
~~~c #define TM_TT_TYPE__ASM_BLEND_STATE_ANIMATION "tm_asm_blend_state_animation" #define TM_TT_TYPE_HASH__ASM_BLEND_STATE_ANIMATION TM_STATIC_HASH("tm_asm_blend_state_animation", 0x2f252b77cdb79071ULL) ~~~ Represents an animation in a Blend State.
### `enum TM_TT_PROP__ASM_BLEND_STATE_ANIMATION`
Properties for an animation in a Blend state. ~~~c enum { // Animation to play. TM_TT_PROP__ASM_BLEND_STATE_ANIMATION__ANIMATION, // reference [[TM_TT_TYPE__ANIMATION_CLIP]] // Position of the animation in the blend map. [[TM_TT_PROP__ASM_BLEND_STATE_ANIMATION__Y]] is // only used by 2D blends. TM_TT_PROP__ASM_BLEND_STATE_ANIMATION__X, // float TM_TT_PROP__ASM_BLEND_STATE_ANIMATION__Y, // float }; ~~~
### `TM_TT_TYPE__ASM_EMPTY_STATE`
~~~c #define TM_TT_TYPE__ASM_EMPTY_STATE "tm_asm_empty_state" #define TM_TT_TYPE_HASH__ASM_EMPTY_STATE TM_STATIC_HASH("tm_asm_empty_state", 0x7f41f0f438535b36ULL) ~~~ A state that plays no animations.
### `enum tm_asm_transition_interface_properties`
Properties shared by all transition Truth types. Defines an interface / abstract base class for transitions in the Animation State Machine. ~~~c enum tm_asm_transition_interface_properties { // Name of the transition. TM_TT_PROP__ASM_TRANSITION__NAME, // string // Sort order in the list of transitions. TM_TT_PROP__ASM_TRANSITION__SORT_ORDER, // double // Reference to the source state of the transition. TM_TT_PROP__ASM_TRANSITION__FROM_STATE, // reference (any type with [[TM_TT_ASPECT__ASM_STATE_INTERFACE]]) // Reference to the destination state of the transition. TM_TT_PROP__ASM_TRANSITION__TO_STATE, // reference(any type with [TM_TT_ASPECT__ASM_STATE_INTERFACE]]) // Index of the first custom property, in Truth types implementing this interface. TM_TT_PROP__ASM_TRANSITION__FIRST_CUSTOM, // Index of first custom transition property }; ~~~
### `TM_TT_ASPECT__ASM_TRANSITION_INTERFACE`
~~~c #define TM_TT_ASPECT__ASM_TRANSITION_INTERFACE ~~~ Aspect that indicates that a Truth Type implements the `enum tm_asm_transition_interface_properties` interface.
### `TM_TT_TYPE__ASM_REGULAR_TRANSITION`
~~~c #define TM_TT_TYPE__ASM_REGULAR_TRANSITION "tm_asm_regular_transition" #define TM_TT_TYPE_HASH__ASM_REGULAR_TRANSITION TM_STATIC_HASH("tm_asm_regular_transition", 0xc09e9acbcae250b4ULL) ~~~ Type for Regular transitions.
### `enum tm_tt_value__asm_regular_transition__on`
Specifies when a Regular transition happens. ~~~c enum tm_tt_value__asm_regular_transition__on { // The transition happens when a particular Event occurs. TM_TT_VALUE__ASM_REGULAR_TRANSITION__ON__EVENT, // The transition happens when the animation has finished playing. TM_TT_VALUE__ASM_REGULAR_TRANSITION__ON__ANIMATION_FINISHED, // The transition happens when a certain condition is fulfilled. The condition is tested for // every frame. TM_TT_VALUE__ASM_REGULAR_TRANSITION__ON__CONDITION, }; ~~~
### `enum TM_TT_PROP__ASM_REGULAR_TRANSITION`
Properties for Regular transitions. ~~~c enum { // Indicates when the transition happens. TM_TT_PROP__ASM_REGULAR_TRANSITION__ON = TM_TT_PROP__ASM_TRANSITION__FIRST_CUSTOM, // uint32_t(tm_tt_value__asm_regular_transition__on) // For [[TM_TT_VALUE__ASM_REGULAR_TRANSITION__ON__EVENT]], the event that triggers the // transition. TM_TT_PROP__ASM_REGULAR_TRANSITION__EVENT, // reference [[TM_TT_TYPE__ASM_EVENT]] // For [[TM_TT_VALUE__ASM_REGULAR_TRANSITION__ON__CONDITION]], an [[expression_language.h]] // expression that is evaluated to determine if the transition should trigger or not. TM_TT_PROP__ASM_REGULAR_TRANSITION__CONDITION, // string // Time to crossfade to the destination state if the transition is taken. Note that logically, // the transition happens immediately, the crossfade only applies to the animation visuals. TM_TT_PROP__ASM_REGULAR_TRANSITION__CROSSFADE_TIME, // float }; ~~~
### `TM_TT_TYPE__ASM_LAYER`
~~~c #define TM_TT_TYPE__ASM_LAYER "tm_asm_layer " #define TM_TT_TYPE_HASH__ASM_LAYER TM_STATIC_HASH("tm_asm_layer ", 0x5d696c56f7fa796dULL) ~~~ Type for a Layer in the Animation State Machine. The ASM can have multiple layers with higher layers overriding lower layers based on bone opacity. Each layer has its own state transition graph. !!! NOTE: API-REVIEW There is a superfluous space in the type name of this and the other types below. We should consider fixing it. Note that fixing it requires migrating Truth data, since the type name is used in serialization.
### `enum TM_TT_PROP__ASM_LAYER`
Properties for Layers. ~~~c enum { // Name of the layer. TM_TT_PROP__ASM_LAYER__NAME, // string // Sort order in the list of layers. TM_TT_PROP__ASM_LAYER__SORT_ORDER, // double // Default state. When a State Machine is first created, the layer will be in this state. TM_TT_PROP__ASM_LAYER__DEFAULT_STATE, // reference(ASM_*_STATE) // List of states for this layer. TM_TT_PROP__ASM_LAYER__STATES, // subobject_set(ASM_*_STATE) // List of transitions for this layer. TM_TT_PROP__ASM_LAYER__TRANSITIONS, // subobject_set(ASM_*_TRANSITION) }; ~~~
### `TM_TT_TYPE__ASM_EVENT`
~~~c #define TM_TT_TYPE__ASM_EVENT "tm_asm_event " #define TM_TT_TYPE_HASH__ASM_EVENT TM_STATIC_HASH("tm_asm_event ", 0x52847af34d7153f0ULL) ~~~ Type for an Event in the Animation State Machine. Events are objects that can be externally triggered to cause transitions in the state machine.
### `enum TM_TT_PROP__ASM_EVENT`
Properties for Events. ~~~c enum { // Name of the event. TM_TT_PROP__ASM_EVENT__NAME, // string // Sort order in the list of events. TM_TT_PROP__ASM_EVENT__SORT_ORDER, // double }; ~~~
### `TM_TT_TYPE__ASM_VARIABLE`
~~~c #define TM_TT_TYPE__ASM_VARIABLE "tm_asm_variable " #define TM_TT_TYPE_HASH__ASM_VARIABLE TM_STATIC_HASH("tm_asm_variable ", 0xda1955a46ea322beULL) ~~~ Type for a Variable in the Animation State Machine. Variables can be assigned values externally and these values control how the state machine behaves.
### `enum TM_TT_PROP__ASM_VARIABLE`
Properties for Variables. ~~~c enum { // Name of the variable. TM_TT_PROP__ASM_VARIABLE__NAME, // string // Sort order in the list of variables. TM_TT_PROP__ASM_VARIABLE__SORT_ORDER, // double // Default value of the variable when the state machine is first created. TM_TT_PROP__ASM_VARIABLE__DEFAULT, // float // Minimum allowed value for the variable. TM_TT_PROP__ASM_VARIABLE__MIN, // float // Maximum allowed value for the variable. TM_TT_PROP__ASM_VARIABLE__MAX, // float // If `true`, this variable's value is computed from [[TM_TT_PROP__ASM_VARIABLE__EXPRESSION]]. TM_TT_PROP__ASM_VARIABLE__COMPUTED, // bool // [[expression_language.h]] expression for dynamically computing the variable's value if // [[TM_TT_PROP__ASM_VARIABLE__COMPUTED]] is set. TM_TT_PROP__ASM_VARIABLE__EXPRESSION, // string }; ~~~
### `TM_TT_TYPE__ASM_BLEND_SET_WEIGHT`
~~~c #define TM_TT_TYPE__ASM_BLEND_SET_WEIGHT "tm_asm_blend_set_weight" #define TM_TT_TYPE_HASH__ASM_BLEND_SET_WEIGHT TM_STATIC_HASH("tm_asm_blend_set_weight", 0x64ca3695fbbbc1f7ULL) ~~~ Type that holds the weight of a bone in a `TM_TT_TYPE__ASM_BLEND_SET`.
### `enum TM_TT_PROP__ASM_BLEND_SET_WEIGHT`
Properties for bone weights. ~~~c enum { // Name of the bone that we control the weight of. TM_TT_PROP__ASM_BLEND_SET_WEIGHT__NAME, // string // Weight of the bone. TM_TT_PROP__ASM_BLEND_SET_WEIGHT__WEIGHT, // float }; ~~~
### `TM_TT_TYPE__ASM_BLEND_SET`
~~~c #define TM_TT_TYPE__ASM_BLEND_SET "tm_asm_blend_set" #define TM_TT_TYPE_HASH__ASM_BLEND_SET TM_STATIC_HASH("tm_asm_blend_set", 0x92f9e2914f038512ULL) ~~~ Type for Blend Sets. A blend set controls weight (or opacity) for a number of bones in the character. Blend Sets can be assigned to animations to have them play on only a subset of the character's bones (for example, only the upper body).
### `enum TM_TT_PROP__ASM_BLEND_SET`
Properties for Blend Sets. ~~~c enum { // Name of the set. TM_TT_PROP__ASM_BLEND_SET__NAME, // string // Sort order in the list of sets. TM_TT_PROP__ASM_BLEND_SET__SORT_ORDER, // double // Default weight for any bone not mentioned in [[TM_TT_PROP__ASM_BLEND_SET__WEIGHTS]]. // Typically either 1 or 0. TM_TT_PROP__ASM_BLEND_SET__DEFAULT_WEIGHT, // float // List of bones that have weights explicitly set in the Blend Set. TM_TT_PROP__ASM_BLEND_SET__WEIGHTS, // subobject_set [[TM_TT_TYPE__ASM_BLEND_SET_WEIGHT]] }; ~~~
### `TM_TT_TYPE__ASM_CONSTRAINT`
~~~c #define TM_TT_TYPE__ASM_CONSTRAINT "tm_asm_constraint" #define TM_TT_TYPE_HASH__ASM_CONSTRAINT TM_STATIC_HASH("tm_asm_constraint", 0x5c6e920aba6c0255ULL) ~~~ Type for Constraints. A Constraints is associated with an entity with a Constraint Component.
### `enum TM_TT_PROP__ASM_CONSTRAINT`
Properties for `TM_TT_TYPE__ASM_CONSTRAINT`. ~~~c enum { // Constraint that this item refers to. TM_TT_PROP__ASM_CONSTRAINT__CONSTRAINT, // reference [[TM_TT_TYPE__ENTITY]] // Sort order in the list of constraints. TM_TT_PROP__ASM_CONSTRAINT__SORT_ORDER, // double }; ~~~
### `TM_TT_TYPE__ASM_MOTION_MIXER`
~~~c #define TM_TT_TYPE__ASM_MOTION_MIXER "tm_asm_motion_mixer" #define TM_TT_TYPE_HASH__ASM_MOTION_MIXER TM_STATIC_HASH("tm_asm_motion_mixer", 0x2d1bc22a3c7cfcebULL) ~~~ Type for the Motion Mixer. The Motion Mixer is a UI object that lets you preview an Animation State Machine by triggering events, changing variables, etc.
### `enum TM_TT_PROP__ASM_MOTION_MIXER`
~~~c enum { // Sliders in the Motion Mixer UI. TM_TT_PROP__ASM_MOTION_MIXER__SLIDERS, // subobject_set [[TM_TT_TYPE__ASM_MOTION_MIXER_SLIDER]] // Buttons in the Motion Mixer UI. TM_TT_PROP__ASM_MOTION_MIXER__BUTTONS, // subobject_set [[TM_TT_TYPE__ASM_MOTION_MIXER_BUTTON]] // Keys to set Variables in the Motion Mixer UI. TM_TT_PROP__ASM_MOTION_MIXER__VARIABLE_KEYS, // subobject_set [[TM_TT_TYPE__ASM_MOTION_MIXER_VARIABLE_KEY]] // Keys to trigger Events in the Motion Mixer UI. TM_TT_PROP__ASM_MOTION_MIXER__EVENT_KEYS, // subobject_set [[TM_TT_TYPE__ASM_MOTION_MIXER_EVENT_KEY]], }; ~~~
### `TM_TT_TYPE__ASM_MOTION_MIXER_SLIDER`
~~~c #define TM_TT_TYPE__ASM_MOTION_MIXER_SLIDER "tm_asm_motion_mixer_slider" #define TM_TT_TYPE_HASH__ASM_MOTION_MIXER_SLIDER TM_STATIC_HASH("tm_asm_motion_mixer_slider", 0xc8158058953e8257ULL) ~~~ Type for Motion Mixer sliders.
### `enum TM_TT_PROP__ASM_MOTION_MIXER_SLIDER`
Properties for Motion Mixer sliders. ~~~c enum { // Variable controlled by this slider. TM_TT_PROP__ASM_MOTION_MIXER_SLIDER__VARIABLE, // reference [[TM_TT_TYPE__ASM_VARIABLE]] // Sort order in the list of sliders. TM_TT_PROP__ASM_MOTION_MIXER_SLIDER__SORT_ORDER, // double }; ~~~
### `TM_TT_TYPE__ASM_MOTION_MIXER_BUTTON`
~~~c #define TM_TT_TYPE__ASM_MOTION_MIXER_BUTTON "tm_asm_motion_mixer_button" #define TM_TT_TYPE_HASH__ASM_MOTION_MIXER_BUTTON TM_STATIC_HASH("tm_asm_motion_mixer_button", 0x1d174065e7d0db8aULL) ~~~ Type for Motion Mixer buttons.
### `enum TM_TT_PROP__ASM_MOTION_MIXER_BUTTON`
Properties for Motion Mixer buttons. ~~~c enum { // Event triggered by this button. TM_TT_PROP__ASM_MOTION_MIXER_BUTTON__EVENT, // reference [[TM_TT_TYPE__ASM_EVENT]] // Sort order in the list of buttons. TM_TT_PROP__ASM_MOTION_MIXER_BUTTON__SORT_ORDER, // double }; ~~~
### `TM_TT_TYPE__ASM_MOTION_MIXER_VARIABLE_KEY`
~~~c #define TM_TT_TYPE__ASM_MOTION_MIXER_VARIABLE_KEY "tm_asm_motion_mixer_variable_key" #define TM_TT_TYPE_HASH__ASM_MOTION_MIXER_VARIABLE_KEY TM_STATIC_HASH("tm_asm_motion_mixer_variable_key", 0x88c1e2333ac733c3ULL) ~~~ Type for Motion Mixer variable keys.
### `enum TM_TT_PROP__ASM_MOTION_MIXER_VARIABLE_KEY`
Properties for Motion Mixer variable keys. ~~~c enum { // Sort order in the list of variable keys. TM_TT_PROP__ASM_MOTION_MIXER_VARIABLE_KEY__SORT_ORDER, // double // Input key that will affect this variable of type [[enum tm_input_keyboard_item]]. TM_TT_PROP__ASM_MOTION_MIXER_VARIABLE_KEY__KEY, // uint32_t // Variable that is effected by the key. TM_TT_PROP__ASM_MOTION_MIXER_VARIABLE_KEY__VARIABLE, // reference [[TM_TT_TYPE__ASM_VARIABLE]] // Time over which the variable value will lerp towards the key value (1 for pressed, 0 for // lifted). TM_TT_PROP__ASM_MOTION_MIXER_VARIABLE_KEY__LERP_TIME, // float }; ~~~
### `TM_TT_TYPE__ASM_MOTION_MIXER_EVENT_KEY`
~~~c #define TM_TT_TYPE__ASM_MOTION_MIXER_EVENT_KEY "tm_asm_motion_mixer_event_key" #define TM_TT_TYPE_HASH__ASM_MOTION_MIXER_EVENT_KEY TM_STATIC_HASH("tm_asm_motion_mixer_event_key", 0x8d34c9aa682dbc87ULL) ~~~ Type for motion mixer event keys.
### `enum TM_TT_PROP__ASM_MOTION_MIXER_EVENT_KEY`
Properties for motion mixer event keys. ~~~c enum { // Sort order in the list of event keys. TM_TT_PROP__ASM_MOTION_MIXER_EVENT_KEY__SORT_ORDER, // double // Input key that will trigger the event of type [[enum tm_input_keyboard_item]]. TM_TT_PROP__ASM_MOTION_MIXER_EVENT_KEY__KEY, // uint32_t // Event to trigger when the key is pressed. TM_TT_PROP__ASM_MOTION_MIXER_EVENT_KEY__EVENT, // reference [[TM_TT_TYPE__ASM_EVENT]] }; ~~~
### `TM_TT_TYPE__ANIMATION_STATE_MACHINE`
~~~c #define TM_TT_TYPE__ANIMATION_STATE_MACHINE "tm_animation_state_machine" #define TM_TT_TYPE_HASH__ANIMATION_STATE_MACHINE TM_STATIC_HASH("tm_animation_state_machine", 0x49e17e57f4e4ea47ULL) ~~~ Type for the Animation State Machine.
### `enum TM_TT_PROP__ANIMATION_STATE_MACHINE`
Properties of the Animation State Machine. ~~~c enum { // Name. TM_TT_PROP__ANIMATION_STATE_MACHINE__NAME, // string // Entity that will be used to preview the ASM. TM_TT_PROP__ANIMATION_STATE_MACHINE__PREVIEW_ENTITY, // reference [[TM_TT_TYPE__ENTITY]] // Layers. TM_TT_PROP__ANIMATION_STATE_MACHINE__LAYERS, // subobject_set [[TM_TT_TYPE__ASM_LAYER]] // Events. TM_TT_PROP__ANIMATION_STATE_MACHINE__EVENTS, // subobject_set [[TM_TT_TYPE__ASM_EVENT]] // Variables. TM_TT_PROP__ANIMATION_STATE_MACHINE__VARIABLES, // subobject_set [[TM_TT_TYPE__ASM_VARIABLE]] // Blend sets. TM_TT_PROP__ANIMATION_STATE_MACHINE__BLEND_SETS, // subobject_set [[TM_TT_TYPE__ASM_BLEND_SET]] // Motion Mixer. TM_TT_PROP__ANIMATION_STATE_MACHINE__MOTION_MIXER, // subobject [[TM_TT_TYPE__ASM_MOTION_MIXER]] }; ~~~

API

### `tm_animation_state_machine_manager_o`
~~~c typedef struct tm_animation_state_machine_manager_o tm_animation_state_machine_manager_o; ~~~ Opaque object representing an Animation State Machine Manager. The manager manages a number of `tm_animation_state_machine_o` state machines.
### `tm_animation_state_machine_o`
~~~c typedef struct tm_animation_state_machine_o tm_animation_state_machine_o; ~~~ Opaque object representing an Animation State Machine.
### `TM_STATE_MACHINE__MAX_LAYERS`
Maximum number of Layers allowed in a State Machine. ~~~c enum { TM_STATE_MACHINE__MAX_LAYERS = 16 }; ~~~
### `TM_STATE_MACHINE__MAX_VARIABLES`
Maximum number of variables allowed in a State Machine. ~~~c enum { TM_STATE_MACHINE__MAX_VARIABLES = 64 }; ~~~
### `struct tm_animation_state_machine_state_t`
Represents the current state of an Animation State Machine. ~~~c typedef struct tm_animation_state_machine_state_t { // Number of layers in the state machine. uint32_t num_layers; TM_PAD(4); // Truth [[tm_uuid_t]] for each Layer. tm_uuid_t layer_uuid[TM_STATE_MACHINE__MAX_LAYERS]; // [[tm_uuid_t]], name and type of the current active state in each Layer. tm_uuid_t state_uuid[TM_STATE_MACHINE__MAX_LAYERS]; tm_strhash_t state_type_hash[TM_STATE_MACHINE__MAX_LAYERS]; tm_strhash_t state_name_hash[TM_STATE_MACHINE__MAX_LAYERS]; // Current time of the animation in each layer. double state_animation_time[TM_STATE_MACHINE__MAX_LAYERS]; // Number of variables. uint32_t num_variables; TM_PAD(4); // Hashed names and values of each varaible in the state machine. tm_strhash_t variable_names[TM_STATE_MACHINE__MAX_VARIABLES]; float variable_values[TM_STATE_MACHINE__MAX_VARIABLES]; } tm_animation_state_machine_state_t; ~~~
### `struct tm_animation_state_machine_trigger_t`
Trigger recorded by the animation state machine. ~~~c typedef struct tm_animation_state_machine_trigger_t { // Hashed name of the trigger. tm_strhash_t hash; // Full name of the trigger. const char *name; // Value of the trigger. float value; // Layer that the trigger was triggered in. uint32_t layer; } tm_animation_state_machine_trigger_t; ~~~
### `struct tm_animation_state_machine_constraint_t`
Constraint recorded by the animation state machine. ~~~c typedef struct tm_animation_state_machine_constraint_t { // UUID of constraint entity. tm_uuid_t entity; // True if the constraint was enabled, false otherwise. bool enabled; TM_PAD(7); } tm_animation_state_machine_constraint_t; ~~~
### `struct tm_animation_state_machine_api`
API for manipulating Animation State Machines. #### `compile()` ~~~c void (*compile)(const struct tm_the_truth_o *tt, tm_tt_id_t sm_id, char *vm, struct tm_allocator_i *allocator); ~~~ Compiles a `TM_TT_TYPE__ANIMATION_STATE_MACHINE` in The Truth to an efficient binary representation. The binary representation is written to the carray `vm`, using the allocator `allocator`, which should be a fixed VM allocator. Note that `vm` must be non-NULL. You can ensure this by setting the capacity of `vm` to 1 to force memory allocation before calling `compile()`. #### `create_manager()` ~~~c tm_animation_state_machine_manager_o *(*create_manager)(struct tm_allocator_i *allocator); ~~~ Creates an Animation State Machine Manager. #### `destroy_manager()` ~~~c void (*destroy_manager)(tm_animation_state_machine_manager_o *manager); ~~~ Destroys a manager created by `create_manager()`. #### `create_state_machine()` ~~~c tm_animation_state_machine_o *(*create_state_machine)( tm_animation_state_machine_manager_o *manager, struct tm_the_truth_o *tt, void *data); ~~~ Creates a state machine. `data` should be the compiled state machine data returned by `compile()`. #### `destroy_state_machine()` ~~~c void (*destroy_state_machine)(tm_animation_state_machine_o *sm); ~~~ Destroys a state machine created by `create_state_machine()`. #### `state()` ~~~c tm_animation_state_machine_state_t (*state)(const tm_animation_state_machine_o *sm); ~~~ Returns the current state of the state machine. #### `set_state()` ~~~c void (*set_state)(tm_animation_state_machine_o *sm, const tm_animation_state_machine_state_t *state); ~~~ Sets the state of the animation state machine. #### `event()` ~~~c void (*event)(tm_animation_state_machine_o *sm, tm_strhash_t name_hash); ~~~ Triggers the event with the specified `name_hash`. #### `tick_state_machine()` ~~~c void (*tick_state_machine)(tm_animation_state_machine_o *sm, float dt); ~~~ Advances the clock in the specified state machine `sm` by `dt`. #### `tick()` ~~~c void (*tick)(tm_animation_state_machine_manager_o *manager, float dt); ~~~ Advances the clock in all state machines managed by `manager` by `dt`. #### `pose()` ~~~c struct tm_animation_pose_t *(*pose)(tm_animation_state_machine_o *sm); ~~~ Returns the current animation pose for the state machine `sm`. #### `locomotion_delta()` ~~~c tm_transform_t (*locomotion_delta)(tm_animation_state_machine_o *sm); ~~~ Returns the locomotion delta from the state machine `sm`. #### `get_variable()` ~~~c float (*get_variable)(const tm_animation_state_machine_o *sm, tm_strhash_t name_hash); ~~~ Gets the value of the state machine variable `name_hash`. #### `set_variable()` ~~~c void (*set_variable)(tm_animation_state_machine_o *sm, tm_strhash_t name_hash, float value); ~~~ Sets the value of the state machine variable `name_hash` to `value`. #### `is_state_playing()` ~~~c bool (*is_state_playing)(const tm_animation_state_machine_o *sm, tm_strhash_t name_hash); ~~~ Returns *true* if a state with the name `name_hash` is currently playing in any of the state machine layers. #### `triggers()` ~~~c tm_animation_state_machine_trigger_t *(*triggers)(const tm_animation_state_machine_o *sm); ~~~ Returns a `carray.inl` of the triggers that were triggered for this ASM during the last `tick()` operation. #### `constraints()` ~~~c tm_animation_state_machine_constraint_t *(*constraints)(const tm_animation_state_machine_o *sm); ~~~ Returns a `carray.inl` of the constraints that were enabled/disabled for this ASM during the last `tick()` operation.
### `tm_animation_state_machine_api_version`
~~~c #define tm_animation_state_machine_api_version ~~~