ezEngine Release 26.3
Loading...
Searching...
No Matches
ezAnimPoseGenerator Class Referencefinal

#include <AnimPoseGenerator.h>

Public Member Functions

void Reset (const ezSkeletonResource *pSkeleton, ezGameObject *pTarget)
 
const ezSkeletonResourceGetSkeleton () const
 
const ezGameObjectGetTargetObject () const
 
ezAnimPoseGeneratorCommandSampleTrackAllocCommandSampleTrack (ezUInt32 uiDeterministicID)
 
ezAnimPoseGeneratorCommandRestPoseAllocCommandRestPose ()
 
ezAnimPoseGeneratorCommandCombinePosesAllocCommandCombinePoses ()
 
ezAnimPoseGeneratorCommandLocalToModelPoseAllocCommandLocalToModelPose ()
 
ezAnimPoseGeneratorCommandSampleEventTrackAllocCommandSampleEventTrack ()
 
ezAnimPoseGeneratorCommandAimIKAllocCommandAimIK ()
 
ezAnimPoseGeneratorCommandTwoBoneIKAllocCommandTwoBoneIK ()
 
const ezAnimPoseGeneratorCommandGetCommand (ezAnimPoseGeneratorCommandID id) const
 
ezAnimPoseGeneratorCommandGetCommand (ezAnimPoseGeneratorCommandID id)
 
void UpdatePose (bool bRequestExternalPoseGeneration)
 
ezArrayPtr< ezMat4GetCurrentPose () const
 
void SetFinalCommand (ezAnimPoseGeneratorCommandID cmdId)
 
ezAnimPoseGeneratorCommandID GetFinalCommand () const
 
bool ShouldSendPoseResultMsg () const
 

Detailed Description

Low-level infrastructure to generate animation poses using a command-based DAG (directed acyclic graph).

Architecture

The pose generator uses a command pattern to build a dependency graph for pose generation. Commands are allocated and connected to form a DAG where each command can have zero or more input commands. This architecture provides two key benefits:

  1. Efficient evaluation: Only commands reachable from the "final command" are executed
  2. Avoid redundant work: Each command executes exactly once, even if multiple commands depend on it

Command Types

These command types are currently available:

  • SampleTrack: Sample an animation clip at a specific time position
  • RestPose: Output the skeleton's rest/bind pose
  • CombinePoses: Blend multiple local-space poses with weights and optional per-bone masks
  • LocalToModelPose: Convert local-space transforms to model-space (concatenate hierarchy)
  • SampleEventTrack: Sample animation events without generating pose data
  • AimIK: Point a bone at a target position (inverse kinematics)
  • TwoBoneIK: Solve a two-bone chain to reach a target (arm/leg IK)

Data Flow

Commands operate on two types of pose data:

  • Local poses: Joint transforms relative to parent (ozz::math::SoaTransform format for SIMD efficiency)
  • Model poses: Joint transforms relative to skeleton root (ezMat4 format)

Typical flow:

  1. Sample/RestPose commands generate local poses
  2. CombinePoses blends local poses together
  3. LocalToModelPose converts to model space
  4. IK commands modify model-space transforms
  5. Final model pose is retrieved via GetCurrentPose()

Usage Pattern

The generator is reused across frames for efficiency (caches sampling contexts), but commands are recreated each frame to build a new pose.

Member Function Documentation

◆ GetFinalCommand()

ezAnimPoseGeneratorCommandID ezAnimPoseGenerator::GetFinalCommand ( ) const
inline

Returns the (currently) final command.

Can be used to inject further commands after it. Call SetFinalCommand() afterwards.

◆ SetFinalCommand()

void ezAnimPoseGenerator::SetFinalCommand ( ezAnimPoseGeneratorCommandID  cmdId)
inline

Sets the (currently) final command in the pose generation.

This will be used to determine which other commands are necessary to calculate.

◆ ShouldSendPoseResultMsg()

bool ezAnimPoseGenerator::ShouldSendPoseResultMsg ( ) const
inline

Whether the caller should send ezMsgAnimationPoseUpdated to its children.

Typically this should be done, to forward the calculated pose to the animated mesh components. However, when some other component takes over control (usually a ragdoll), the pose from this generator isn't the final result and thus should not be forwarded. The other component will take care of this already.

◆ UpdatePose()

void ezAnimPoseGenerator::UpdatePose ( bool  bRequestExternalPoseGeneration)

Calculates the pose, using the final command as reference where to start.

If bRequestExternalPoseGeneration is true, inverse-kinematics (IK) and powered ragdolls are also used.


The documentation for this class was generated from the following files: