Skip to content

acl/compression/transform_adapters.h

#include "acl/compression/transform_adapters.h"

The interface of a transform adapter, and the built-in adapters of the runtime transform types.

transform_runtime_type_t

enum class transform_runtime_type_t : uint8_t
{
    custom = 0,
    vqf = 1,
    vqsf = 2,
    vqvf = 3,
    vqmf = 4,
    matrix3x4f = 5,
    automatic = 6,
};

The transform types that compression uses at runtime to compose transforms and to measure the error. The runtime type is not the type of the raw tracks: compression converts each rtm::vqvf source transform into the runtime type.

Value Description
custom A transform type that ACL does not know. ACL uses this transform type only through the functions of its transform adapter.
vqf A rotation and a translation, stored as rtm::vqvf. The scale is not used. The product of two VQ transforms is exact and associative.
vqsf A rotation, a translation, and a uniform scale, stored as rtm::vqsf. The product of two VQS transforms is exact and associative: a uniform scale creates no shear.
vqvf A rotation, a translation, and a 3D scale, stored as rtm::vqvf. The product of two VQV transforms discards the shear. Thus the product is not associative.
vqmf A rotation, a translation, and a 3x3 scale/shear matrix, stored as rtm::vqmf. The product of two VQM transforms keeps the shear. Thus the product is exact and associative.
matrix3x4f A 3x4 affine matrix, stored as rtm::matrix3x4f. The product of two matrices keeps the shear. Thus the product is exact and associative.
automatic For the compression settings only: compression selects the runtime transform type from the raw tracks. See compression_settings::transform_runtime_type. A transform adapter never returns this value.

itransform_adapter

class itransform_adapter

Interface for all transform adapters. A transform adapter gives the operations of a runtime transform type to compression. Compression uses them to put the transforms in object space and to measure the error:

  • converting from rtm::vqvf into the runtime transform type
  • the identity transform and the product of two transforms
  • taking local space transforms into object space
  • transforming points

The functions use the runtime transform type through void pointers. The runtime transform type must have an alignment of 16 bytes or less.

ACL calls these functions in the inner loops of compression. Thus most functions take a list of transforms, to keep the number of virtual function calls low.

itransform_adapter::get_name

virtual const char* get_name() const =0

Returns the unique name of the transform adapter.

itransform_adapter::get_hash

virtual uint32_t get_hash() const

Returns a unique hash to represent the transform adapter.

itransform_adapter::get_type

virtual transform_runtime_type_t get_type() const

Returns the runtime transform type of the adapter. A custom transform adapter returns custom.

itransform_adapter::get_transform_size

virtual size_t get_transform_size() const =0

Returns the size in bytes of the runtime transform type.

itransform_adapter::is_associative

virtual bool is_associative() const =0

Returns whether or not the product of two transforms is associative. When it is, compression can keep object space transforms and update only what changes. When it is not, compression must multiply the full chain of transforms from the root.

itransform_adapter::needs_conversion

virtual bool needs_conversion() const

Returns whether or not the runtime transform type is different from rtm::vqvf. When it is not, compression uses the rtm::vqvf transforms directly and does not call convert_transforms.

itransform_adapter::convert_transforms

virtual void convert_transforms(
    const convert_transforms_args& args,
    void* out_transforms) const

Converts from rtm::vqvf into the runtime transform type. Called when needs_conversion returns true.

itransform_adapter::identity

virtual void identity(void* out_transform) const =0

Writes the identity transform.

itransform_adapter::mul

virtual void mul(const void* lhs, const void* rhs, void* out_transform) const =0

Multiplies two transforms and writes the result. Multiplication order is as follow: local_to_world = mul(local_to_object, object_to_world) The output can be one of the inputs.

itransform_adapter::local_to_object_space

virtual void local_to_object_space(
    const local_to_object_space_args& args,
    void* out_object_transforms) const

Takes local space transforms into object space. The object space transform of a root is its local space transform. The default implementation uses mul. A transform adapter can replace it with a faster version.

itransform_adapter::mul_point3_x4

virtual void mul_point3_x4(
    rtm::vector4f point_xxxx,
    rtm::vector4f point_yyyy,
    rtm::vector4f point_zzzz,
    const void* transform,
    rtm::vector4f& out_result_xxxx,
    rtm::vector4f& out_result_yyyy,
    rtm::vector4f& out_result_zzzz) const =0

Multiplies a transform and four 3D points stored transposed. Multiplication order is as follow: world_position = mul_point3_x4(local_position, local_to_world)

itransform_adapter::convert_transforms_args

struct itransform_adapter::convert_transforms_args

Input arguments for the convert_transforms function.

itransform_adapter::convert_transforms_args::dirty_transform_indices

const uint32_t* dirty_transform_indices;

A list of transform indices that are dirty and need conversion.

itransform_adapter::convert_transforms_args::num_dirty_transforms

uint32_t num_dirty_transforms;

The number of dirty transforms that need conversion.

itransform_adapter::convert_transforms_args::transforms

const rtm::vqvf* transforms;

The input transforms in rtm::vqvf format to be converted.

itransform_adapter::convert_transforms_args::num_transforms

uint32_t num_transforms;

The number of transforms in the input and output buffers.

itransform_adapter::convert_transforms_args::sample_index

uint32_t sample_index;

The index in the clip of the sample these transforms come from. The sample time is 'sample_index / sample_rate', clamped to the clip duration.

itransform_adapter::convert_transforms_args::is_lossy

bool is_lossy;

True if these transforms come from the lossy data that compression tests. False if these transforms come from the raw data. A transform adapter can use it with data that compression does not see: for example, a value that you compress in another track and that you add to the lossy transforms only.

itransform_adapter::local_to_object_space_args

struct itransform_adapter::local_to_object_space_args

Input arguments for the local_to_object_space function.

itransform_adapter::local_to_object_space_args::dirty_transform_indices

const uint32_t* dirty_transform_indices;

A list of transform indices that are dirty and need transformation. A parent transform comes before its children in the list.

itransform_adapter::local_to_object_space_args::num_dirty_transforms

uint32_t num_dirty_transforms;

The number of dirty transforms that need transformation.

itransform_adapter::local_to_object_space_args::parent_transform_indices

const uint32_t* parent_transform_indices;

A list of parent transform indices for every transform. An index of k_invalid_track_index represents a root transform with no parent.

itransform_adapter::local_to_object_space_args::local_transforms

const void* local_transforms;

The input local space transforms in the runtime transform type.

itransform_adapter::local_to_object_space_args::num_transforms

uint32_t num_transforms;

The number of transforms in the input and output buffers.

vqf_transform_adapter

class vqf_transform_adapter final : public acl::acl_impl::builtin_transform_adapter<acl_impl::vq_transform_math>

The transform adapter for VQ transforms: a rotation and a translation. It uses rtm::vqvf and it does not use the scale. Compression uses it when a clip has no scale.

vqf_transform_adapter::get_name

virtual const char* get_name() const override

Returns the unique name of the transform adapter.

vqsf_transform_adapter

class vqsf_transform_adapter final : public acl::acl_impl::builtin_transform_adapter<acl_impl::vqs_transform_math>

The transform adapter for VQS transforms: a rotation, a translation, and a uniform scale. It uses rtm::vqsf. The source transforms must have a uniform scale.

vqsf_transform_adapter::get_name

virtual const char* get_name() const override

Returns the unique name of the transform adapter.

vqvf_transform_adapter

class vqvf_transform_adapter final : public acl::acl_impl::builtin_transform_adapter<acl_impl::vqv_transform_math>

The transform adapter for VQV transforms: a rotation, a translation, and a 3D scale. It uses rtm::vqvf. The product discards the shear, as in many game engines.

vqvf_transform_adapter::get_name

virtual const char* get_name() const override

Returns the unique name of the transform adapter.

vqmf_transform_adapter

class vqmf_transform_adapter final : public acl::acl_impl::builtin_transform_adapter<acl_impl::vqm_transform_math>

The transform adapter for VQM transforms: a rotation, a translation, and a 3x3 scale/shear matrix. It uses rtm::vqmf. The product keeps the shear and gives exact object space transforms.

vqmf_transform_adapter::get_name

virtual const char* get_name() const override

Returns the unique name of the transform adapter.

matrix3x4f_transform_adapter

class matrix3x4f_transform_adapter final : public acl::acl_impl::builtin_transform_adapter<acl_impl::matrix3x4_transform_math>

The transform adapter for 3x4 affine matrices. It uses rtm::matrix3x4f. The product keeps the shear and gives exact object space transforms.

matrix3x4f_transform_adapter::get_name

virtual const char* get_name() const override

Returns the unique name of the transform adapter.