Skip to content

acl/compression/track_array.h

#include "acl/compression/track_array.h"

The raw track list types: an array of tracks with the same type.

track_array

class track_array

An array of tracks. Although each track contained within is untyped, each track must have the same type. They must all have the same sample rate and the same number of samples.

Construction

track_array::track_array
track_array() noexcept

Constructs an empty track array.

track_array(iallocator& allocator, uint32_t num_tracks)

Constructs an array with the specified number of tracks. Tracks will be empty and untyped by default.

track_array(track_array&& other) noexcept

Move constructor for a track array.

track_array::~track_array
~track_array()

Destroys a track array.

track_array::operator=
track_array& operator=(track_array&& other) noexcept

Move assignment for a track array.

Properties

track_array::get_allocator
iallocator* get_allocator() const

Returns a pointer to the allocator instance or nullptr if there is none present.

track_array::get_num_tracks
uint32_t get_num_tracks() const

Returns the number of tracks contained in this array.

track_array::get_num_samples_per_track
uint32_t get_num_samples_per_track() const

Returns the number of samples per track in this array. This does not account for the repeating first sample when the wrap looping policy is used. See sample_looping_policy for details.

track_array::get_track_interpolator
track_interpolator_t get_track_interpolator() const

Returns the track interpolator type for tracks in this array.

track_array::get_track_type
track_type8 get_track_type() const

Returns the track type for tracks in this array.

track_array::get_track_category
track_category8 get_track_category() const

Returns the track category for tracks in this array.

track_array::get_sample_rate
float get_sample_rate() const

Returns the sample rate for tracks in this array.

track_array::get_duration
float get_duration() const

Returns the duration for tracks in this array. Note that the duration depends on the looping policy. See sample_looping_policy for details.

track_array::get_finite_duration
float get_finite_duration() const

Returns the finite duration for tracks in this array. Note that the duration depends on the looping policy. See sample_looping_policy for details.

track_array::get_name
const string& get_name() const

Returns the track name.

track_array::set_name
void set_name(const string& name)

Sets the track name.

track_array::get_transform_space
transform_space_t get_transform_space() const

Returns the space of the transform tracks, see transform_space_t. Compression uses it to measure the error in object space. Scalar tracks do not use it.

Defaults to local.

track_array::set_transform_space
void set_transform_space(transform_space_t space)

Sets the space of the transform tracks, see transform_space_t. Scalar tracks do not use it.

track_array::get_playback_scale
float get_playback_scale() const

Returns the uniform scale that the runtime applies to the whole clip at playback. For example, a designer scales a character, or the game spawns it with a random scale. The error that the runtime shows is the object space error multiplied by this scale. Thus compression divides the precision of each transform track by this scale, and the error functions multiply the error of the transform tracks by this scale. The precision, the error, and the keyframe stripping threshold are in playback units. The shell distance stays in the units of the clip. Scalar tracks do not use it.

Defaults to 1.0.

track_array::set_playback_scale
void set_playback_scale(float scale)

Sets the uniform scale that the runtime applies to the whole clip at playback. It must be positive and finite. See get_playback_scale. Scalar tracks do not use it.

track_array::set_looping_policy
void set_looping_policy(sample_looping_policy policy)

Sets the looping policy. Note that when wrap policy is used, an extra repeating first sample is artificially inserted at the end of the clip. This artificial sample maps to the first sample, it only lives once in memory. This allows us to interpolate from the last sample back to the first sample when looping and wrapping during playback. See sample_looping_policy for details. The sample_looping_policy::as_compressed value isn't allowed here.

track_array::get_looping_policy
sample_looping_policy get_looping_policy() const

Returns the looping policy.

Tracks

track_array::operator[]
track& operator[](uint32_t index)
const track& operator[](uint32_t index) const

Returns the track at the specified index.

track_array::begin
track* begin()
const track* begin() const

Returns a pointer to the first track.

track_array::end
track* end()
const track* end() const

Returns a pointer past the last track.

track_array::is_empty
bool is_empty() const

Returns true if the track array doesn't contain any data, false otherwise.

Validation and sampling

track_array::is_valid
error_result is_valid() const

Returns whether a track array is valid or not. An array is valid if:

  • It is empty
  • All tracks have the same type
  • All tracks have the same number of samples
  • All tracks have the same sample rate
  • All tracks are valid
  • The transform space is a valid value
track_array::sample_tracks
template<class track_writer_type>
void sample_tracks(
    float sample_time,
    sample_rounding_policy rounding_policy,
    track_writer_type& writer) const

Sample all tracks within this array at the specified sample time and desired rounding policy. Track samples are written out using the track_writer provided. The sample_time value must be within [0, clip duration] inclusive otherwise it will be clamped.

track_array::sample_track
template<class track_writer_type>
void sample_track(
    uint32_t track_index,
    float sample_time,
    sample_rounding_policy rounding_policy,
    track_writer_type& writer) const

Sample a single track within this array at the specified sample time and desired rounding policy. The track sample is written out using the track_writer provided. The sample_time value must be within [0, clip duration] inclusive otherwise it will be clamped.

track_array::get_raw_size
uint32_t get_raw_size() const

Returns the raw size for this track array. Note that this differs from the actual memory used by an instance of this class. It is meant for comparison against the compressed size.

track_array_typed

template<track_type8 track_type_, track_interpolator_t track_interpolator_ = track_interpolator_t::linear>
class track_array_typed : public acl::track_array

A typed track array. See track_array for details.

Types and constants

track_array_typed::type
track_type8 type = track_type_;

The track type.

track_array_typed::interpolator
track_interpolator_t interpolator = track_interpolator_;

The interpolation type.

track_array_typed::category
track_category8 category = track_traits<track_type_>::category;

The track category.

track_array_typed::track_member_type
using track_member_type = track_typed<track_type_, track_interpolator_>;

The track member type.

Construction

track_array_typed::track_array_typed
track_array_typed() noexcept

Constructs an empty track array.

track_array_typed(iallocator& allocator, uint32_t num_tracks)

Constructs an array with the specified number of tracks. Tracks will be empty and untyped by default.

track_array_typed(const track_array_typed&) = delete

Cannot copy.

track_array_typed(track_array_typed&& other) noexcept

Move constructor for a track array.

track_array_typed::~track_array_typed
~track_array_typed() = default

Destroys a track array.

track_array_typed::operator=
track_array_typed& operator=(const track_array_typed&) = delete

Cannot copy.

track_array_typed& operator=(track_array_typed&& other) noexcept

Move assignment for a track array.

Properties

track_array_typed::get_track_type
track_type8 get_track_type() const

Returns the track type for tracks in this array.

track_array_typed::get_track_category
track_category8 get_track_category() const

Returns the track category for tracks in this array.

Tracks

track_array_typed::operator[]
track_member_type& operator[](uint32_t index)
const track_member_type& operator[](uint32_t index) const

Returns the track at the specified index.

track_array_typed::begin
track_member_type* begin()
const track_member_type* begin() const

Returns a pointer to the first track.

track_array_typed::end
track_member_type* end()
const track_member_type* end() const

Returns a pointer past the last track.

track_array_cast

template<typename track_array_type>
track_array_type& track_array_cast(track_array& track_array_)

template<typename track_array_type>
const track_array_type& track_array_cast(const track_array& track_array_)

Casts an untyped track array into the desired track array type while asserting for safety.

template<typename track_array_type>
track_array_type* track_array_cast(track_array* track_array_)

template<typename track_array_type>
const track_array_type* track_array_cast(const track_array* track_array_)

Casts an untyped track array into the desired track array type. Returns nullptr if the types are not compatible or if the input is nullptr.

track_array_float1f_ex

using track_array_float1f_ex = track_array_typed<track_type8::float1f, track_interpolator_t::extended>;

A track array of float1f scalar samples, with the extended interpolator: each sample has its own interpolator.

track_array_float2f_ex

using track_array_float2f_ex = track_array_typed<track_type8::float2f, track_interpolator_t::extended>;

A track array of float2f scalar samples, with the extended interpolator: each sample has its own interpolator.

track_array_float3f_ex

using track_array_float3f_ex = track_array_typed<track_type8::float3f, track_interpolator_t::extended>;

A track array of float3f scalar samples, with the extended interpolator: each sample has its own interpolator.

track_array_float4f_ex

using track_array_float4f_ex = track_array_typed<track_type8::float4f, track_interpolator_t::extended>;

A track array of float4f scalar samples, with the extended interpolator: each sample has its own interpolator.

track_array_vector4f_ex

using track_array_vector4f_ex = track_array_typed<track_type8::vector4f, track_interpolator_t::extended>;

A track array of vector4f scalar samples, with the extended interpolator: each sample has its own interpolator.

track_array_vqvf_ex

using track_array_vqvf_ex = track_array_typed<track_type8::vqvf, track_interpolator_t::extended>;

A track array of vqvf transform samples, with the extended interpolator: each sample has its own interpolator.