FAnimTrackCodec
- Module
- Animation
- Header
#include "Animation/AnimationCompression.h"- Namespace
Mowo
Properties
| Type | Name | Description |
|---|---|---|
static constexpr float | kUnitQuantStep | Half a quantization step, expressed as a fraction of the encoded range. Every error bound quoted on this codec is derived from it. Default 1.0f / 65535.0f. |
static constexpr uint8_t | kPackedFormatBase | Variable bit rate, per track (ACL's per-track bit rates): a quantized track that still meets its tolerance with fewer than 16 bits per component is bit-packed at the narrowest width that does. The width rides in the format byte, kPackedFormatBase + bits, so neither the .mmodel channel header nor a cooked descriptor grows a field. A packed vector key is a 16-bit time word plus three bits-wide axes; a packed rotation key is the time word, the 2-bit largest-component index and three bits-wide smallest-three components. Default 16. |
static constexpr uint32_t | kMinPackedBits | Default 3. |
static constexpr uint32_t | kMaxPackedBits | Default 15. |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | IsPacked | |
uint32_t | PackedBits | |
EAnimTrackFormat | PackedFormat | |
uint32_t | PackedVectorKeyBits | |
uint32_t | PackedRotationKeyBits | |
uint16_t | EncodeUnit | |
float | DecodeUnit | |
uint16_t | EncodeRanged | |
float | DecodeRanged | |
void | EncodeQuat | Smallest-three: a unit quaternion's largest component is recoverable from the other three, so we store 2 bits of index plus three 15-bit components over [-1/sqrt(2), +1/sqrt(2)] — 47 bits, written as 6 bytes. |
Quat | DecodeQuat | |
FCompressedAnimTrack | CompressVectorTrack | Encode one vector track into blob, returning its descriptor. |
FCompressedAnimTrack | CompressRotationTrack | |
FCompressedAnimTrack | CompressVectorTrackVbr | CompressVectorTrack, then the narrowest bit-packed width whose measured error still meets tolerance — taken only when it is smaller. |
FCompressedAnimTrack | CompressRotationTrackVbr | |
Vec3 | SampleVector | Sample straight out of the encoded bytes: binary search over the quantized time words, dequantize the two bracketing keys, lerp. |
Quat | SampleRotation | |
void | DecompressVectorTrack | Rebuild the lossless key list — used by tooling and by the .mmodel loader, which must keep handing every existing consumer raw keys. |
void | DecompressRotationTrack | |
uint64_t | VectorTrackBytes | |
uint64_t | RotationTrackBytes | |
uint32_t | VectorStride | |
uint32_t | RotationStride | |
float | MaxAxisDelta | |
float | MaxQuatDelta | Quaternion distance as the largest component difference after sign alignment: q and -q name one rotation, so comparing them raw would report a maximal error for an identical pose. |
Function details
IsPacked
static bool IsPacked(EAnimTrackFormat format)PackedBits
static uint32_t PackedBits(EAnimTrackFormat format)PackedFormat
static EAnimTrackFormat PackedFormat(uint32_t bits)PackedVectorKeyBits
static uint32_t PackedVectorKeyBits(uint32_t bits)PackedRotationKeyBits
static uint32_t PackedRotationKeyBits(uint32_t bits)EncodeUnit
static uint16_t EncodeUnit(float unit)DecodeUnit
static float DecodeUnit(uint16_t q)EncodeRanged
static uint16_t EncodeRanged(float value, float rangeMin, float rangeExtent)DecodeRanged
static float DecodeRanged(uint16_t q, float rangeMin, float rangeExtent)EncodeQuat
static void EncodeQuat(const Quat& in, uint8_t out[6])Smallest-three: a unit quaternion's largest component is recoverable from the other three, so we store 2 bits of index plus three 15-bit components over [-1/sqrt(2), +1/sqrt(2)] — 47 bits, written as 6 bytes. The sign is folded away by flipping q so the largest component is positive, which costs nothing (q and -q are the same rotation).
DecodeQuat
static Quat DecodeQuat(const uint8_t in[6])CompressVectorTrack
static FCompressedAnimTrack CompressVectorTrack(const std::vector<FAnimVectorKeyIn>& keys, float tolerance, bool collapseConstant, std::vector<uint8_t>& blob, float& outMaxError, bool& outCollapsed)Encode one vector track into blob, returning its descriptor. The returned format is Quantized only when the round trip measured against the original keys stays inside tolerance; otherwise the raw floats go in instead and the track is byte-exact.
CompressRotationTrack
static FCompressedAnimTrack CompressRotationTrack(const std::vector<FAnimRotationKeyIn>& keys, float tolerance, bool collapseConstant, std::vector<uint8_t>& blob, float& outMaxError, bool& outCollapsed)CompressVectorTrackVbr
static FCompressedAnimTrack CompressVectorTrackVbr(const std::vector<FAnimVectorKeyIn>& keys, float tolerance, bool collapseConstant, std::vector<uint8_t>& blob, float& outMaxError, bool& outCollapsed)CompressVectorTrack, then the narrowest bit-packed width whose measured error still meets tolerance — taken only when it is smaller. A track the fixed form stores raw, empty or collapsed to one key stays as it is.
CompressRotationTrackVbr
static FCompressedAnimTrack CompressRotationTrackVbr(const std::vector<FAnimRotationKeyIn>& keys, float tolerance, bool collapseConstant, std::vector<uint8_t>& blob, float& outMaxError, bool& outCollapsed)SampleVector
static Vec3 SampleVector(const FCompressedAnimTrack& track, const uint8_t* blobBase, float timeTicks, const Vec3& fallback)Sample straight out of the encoded bytes: binary search over the quantized time words, dequantize the two bracketing keys, lerp. No intermediate decompressed track is ever materialized — that whole-track decode is what makes most compressed-animation schemes unusable at runtime, and the reason this one is byte-addressable per key.
SampleRotation
static Quat SampleRotation(const FCompressedAnimTrack& track, const uint8_t* blobBase, float timeTicks, const Quat& fallback)DecompressVectorTrack
static void DecompressVectorTrack(const FCompressedAnimTrack& track, const uint8_t* blobBase, std::vector<FAnimVectorKeyIn>& out)Rebuild the lossless key list — used by tooling and by the .mmodel loader, which must keep handing every existing consumer raw keys.
DecompressRotationTrack
static void DecompressRotationTrack(const FCompressedAnimTrack& track, const uint8_t* blobBase, std::vector<FAnimRotationKeyIn>& out)VectorTrackBytes
static uint64_t VectorTrackBytes(const FCompressedAnimTrack& track)RotationTrackBytes
static uint64_t RotationTrackBytes(const FCompressedAnimTrack& track)VectorStride
static uint32_t VectorStride(EAnimTrackFormat format)RotationStride
static uint32_t RotationStride(EAnimTrackFormat format)MaxAxisDelta
static float MaxAxisDelta(const Vec3& a, const Vec3& b)MaxQuatDelta
static float MaxQuatDelta(const Quat& a, const Quat& in)Quaternion distance as the largest component difference after sign alignment: q and -q name one rotation, so comparing them raw would report a maximal error for an identical pose.