FMotionMatchingDatabase
- Module
- Animation
- Header
#include "Animation/MotionMatching.h"- Namespace
Mowo
Properties
| Type | Name | Description |
|---|---|---|
static constexpr uint32_t | kSmallBlock | Default 16. |
static constexpr uint32_t | kLargeBlock | Default 64. |
Constructors
| Signature | Name | Description |
|---|---|---|
FMotionMatchingDatabase() = default | FMotionMatchingDatabase |
Public functions
| Returns | Name | Description |
|---|---|---|
void | StripRootTranslation | Drops a sampled pose's animated root DISPLACEMENT back to the skeleton's rest transform, keeping rotation and scale. |
void | SetMirrorTable | The table mirrored entries are reflected through. |
bool | HasMirror | |
const FMirrorResolved& | MirrorResolved | |
bool | Build | Clips must already be bound to the skeleton (AnimationClip::BindToSkeleton). |
bool | BuildCached | Build through the derived-data cache: the key is the clip/skeleton content hash + schema fingerprint + producer version, so a stale entry can never be returned. |
uint64_t | SourceHash | |
std::string | CacheKey | |
bool | Serialize | |
bool | Deserialize | |
const FMotionFeatureSchema& | Schema | |
uint32_t | FrameCount | |
uint32_t | Dimension | |
const std::vector<FMotionFrame>& | Frames | |
const std::vector<float>& | Features | |
const std::vector<float>& | Mean | |
const std::vector<float>& | StdDev | |
const std::vector<float>& | Weights | |
const float* | FrameFeatures | |
float | RawAt | |
void | Normalize | |
int32_t | FindFrame | Frame index playing at time in clip, or -1 when the clip is not in the database. |
bool | IsClipLooping | |
float | ClipDuration | |
uint64_t | TagMask | The mask of the named tags this database knows; unknown names add nothing (a required unknown tag would otherwise match no frame). |
const std::vector<std::string>& | TagNames | |
float | FrameCost | |
int32_t | Search | Weighted nearest neighbour, exact. |
int32_t | SearchBruteForce | The reference: every frame, no pruning. |
Function details
FMotionMatchingDatabase
FMotionMatchingDatabase() = defaultStripRootTranslation
static void StripRootTranslation(const Skeleton& skeleton, int32_t rootBone, std::vector<Mat4>& localTransforms)Drops a sampled pose's animated root DISPLACEMENT back to the skeleton's rest transform, keeping rotation and scale. Motion-matching clips carry root motion (that is where the trajectory features come from) while the character's position is owned by its movement component — so the pose must be consumed in character space, or a switch between clips whose roots have travelled different distances teleports the skeleton.
SetMirrorTable
void SetMirrorTable(const FMirrorTable& table)The table mirrored entries are reflected through. Set it before Build / BuildCached; it is part of the cache key.
HasMirror
bool HasMirror() constMirrorResolved
const FMirrorResolved& MirrorResolved() constBuild
bool Build(const FMotionFeatureSchema& schema, const Skeleton& skeleton, const std::vector<Ref<AnimationClip>>& clips, const std::vector<FMotionClipEntry>& entries)Clips must already be bound to the skeleton (AnimationClip::BindToSkeleton).
BuildCached
bool BuildCached(const FMotionFeatureSchema& schema, const Skeleton& skeleton, const std::vector<Ref<AnimationClip>>& clips, const std::vector<FMotionClipEntry>& entries, bool* outCacheHit = nullptr)Build through the derived-data cache: the key is the clip/skeleton content hash + schema fingerprint + producer version, so a stale entry can never be returned. Falls back to a plain Build when the DDC is not initialized.
SourceHash
static uint64_t SourceHash(const Skeleton& skeleton, const std::vector<Ref<AnimationClip>>& clips, const std::vector<FMotionClipEntry>& entries)CacheKey
static std::string CacheKey(const FMotionFeatureSchema& schema, const Skeleton& skeleton, const std::vector<Ref<AnimationClip>>& clips, const std::vector<FMotionClipEntry>& entries)Serialize
bool Serialize(std::vector<uint8_t>& out) constDeserialize
bool Deserialize(const std::vector<uint8_t>& data)Schema
const FMotionFeatureSchema& Schema() constFrameCount
uint32_t FrameCount() constDimension
uint32_t Dimension() constFrames
const std::vector<FMotionFrame>& Frames() constFeatures
const std::vector<float>& Features() constMean
const std::vector<float>& Mean() constStdDev
const std::vector<float>& StdDev() constWeights
const std::vector<float>& Weights() constFrameFeatures
const float* FrameFeatures(uint32_t frame) constRawAt
float RawAt(uint32_t frame, uint32_t dim) constNormalize
void Normalize(const float* raw, float* outNormalized) constFindFrame
int32_t FindFrame(int32_t clipIndex, float time, bool mirrored = false) constFrame index playing at time in clip, or -1 when the clip is not in the database. Wraps for looping clips, clamps otherwise.
IsClipLooping
bool IsClipLooping(int32_t clipIndex) constClipDuration
float ClipDuration(int32_t clipIndex) constTagMask
uint64_t TagMask(const std::vector<std::string>& tags) constThe mask of the named tags this database knows; unknown names add nothing (a required unknown tag would otherwise match no frame).
TagNames
const std::vector<std::string>& TagNames() constFrameCost
float FrameCost(uint32_t frame, const float* normalizedQuery) constSearch
int32_t Search(const float* normalizedQuery, float* outCost = nullptr, const FMotionSearchFilter* filter = nullptr) constWeighted nearest neighbour, exact. Frames are grouped in blocks of kSmallBlock inside blocks of kLargeBlock with the per-dimension bounds of each; a block whose weighted distance to the query's box already exceeds the best cost is skipped whole (Holden's AABB motion matching), so a full locomotion set searches a fraction of its frames.
SearchBruteForce
int32_t SearchBruteForce(const float* normalizedQuery, float* outCost = nullptr, const FMotionSearchFilter* filter = nullptr) constThe reference: every frame, no pruning. Same answer as Search.