Foundation
Loading...
Searching...
No Matches
Functions
Animation.cpp File Reference
#include "Animation.hpp"
#include <algorithm>

Functions

mat4 JointLocalMatrix (float3 const &t, quat const &r, float3 const &s)
 Composes a joint's local TRS into a matrix (T * R * S).
 
void ResetToRest (FSkeleton const &skel, FPose &pose)
 Seeds a pose's local TRS from the skeleton rest pose (call before SampleClip).
 
void SampleClip (FAnimationClip const &clip, float t, FPose &pose)
 Samples a clip at time t, overwriting the seeded local TRS for every channel's joint.
 
void ComputeGlobals (FSkeleton const &skel, FPose &pose)
 Walks the hierarchy, composing local TRS into world matrices in FPose::globals.
 
void SampleTrack (Span< const float > times, Span< const float > values, uint32_t comps, FAnimInterp interp, float t, Span< float > out)
 Samples a generic keyframed track of comps-wide values at time t into out.
 
void ComputeSkinningMatrices (FSkeleton const &skel, FPose const &pose, Span< mat4 > outPalette)
 Builds the skinning palette globals[j] * inverseBind[j] into outPalette.
 
void SkinVertices (Span< const FVertex > bind, Span< const FSkinBinding > binding, Span< const mat4 > palette, Span< FQVertex > out)
 Linear-blend skins bind-pose vertices by the palette, packing results for the dynamic ring.
 
void RecomputeNormals (Span< FVertex > verts, Span< const uint32_t > indices)
 Recomputes smooth per-vertex normals from positions over an indexed triangle list.
 

Function Documentation

◆ ComputeGlobals()

void ComputeGlobals ( FSkeleton const &  skel,
FPose pose 
)

Walks the hierarchy, composing local TRS into world matrices in FPose::globals.

◆ ComputeSkinningMatrices()

void ComputeSkinningMatrices ( FSkeleton const &  skel,
FPose const &  pose,
Span< mat4 >  outPalette 
)

Builds the skinning palette globals[j] * inverseBind[j] into outPalette.

Parameters
outPaletteMust hold FSkeleton::Count matrices.

◆ JointLocalMatrix()

mat4 JointLocalMatrix ( float3 const &  t,
quat const &  r,
float3 const &  s 
)

Composes a joint's local TRS into a matrix (T * R * S).

◆ RecomputeNormals()

void RecomputeNormals ( Span< FVertex verts,
Span< const uint32_t >  indices 
)

Recomputes smooth per-vertex normals from positions over an indexed triangle list.

Area-weighted face-normal accumulation, then normalize. Needed after POSITION-only morph deformation (which moves vertices without supplying normals); run it on the morphed vertices before packing/skinning so shading matches the deformed surface. Tangents are left as-is (re-projected onto the new normal frame by FQVertex::PackTBN).

◆ ResetToRest()

void ResetToRest ( FSkeleton const &  skel,
FPose pose 
)

Seeds a pose's local TRS from the skeleton rest pose (call before SampleClip).

◆ SampleClip()

void SampleClip ( FAnimationClip const &  clip,
float  t,
FPose pose 
)

Samples a clip at time t, overwriting the seeded local TRS for every channel's joint.

Note
Channels with no key for a component leave that component at its rest value, so call ResetToRest first. t is clamped per channel to its key range.

◆ SampleTrack()

void SampleTrack ( Span< const float >  times,
Span< const float >  values,
uint32_t  comps,
FAnimInterp  interp,
float  t,
Span< float >  out 
)

Samples a generic keyframed track of comps-wide values at time t into out.

Same time/value packing and interpolation rules as FAnimChannel (step/linear/cubic, clamped to the key range). Used for morph-target weight tracks (comps == target count).

Parameters
outMust be exactly comps wide.

◆ SkinVertices()

void SkinVertices ( Span< const FVertex bind,
Span< const FSkinBinding binding,
Span< const mat4 >  palette,
Span< FQVertex out 
)

Linear-blend skins bind-pose vertices by the palette, packing results for the dynamic ring.

Parameters
bindRest-pose, full-precision vertices (positions/normals/tangents in bind space).
bindingPer-vertex joint indices + weights (parallel to bind).
paletteSkinning matrices from ComputeSkinningMatrices.
outDestination quantized vertices (size == bind.size()); write straight into the span returned by GPUScene::UpdateDynamicGeometry.