UBlendSpace

Allows multiple animations to be blended between based on input parameters

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Animation/BlendSpace.h

Include

#include "Animation/BlendSpace.h"

Syntax

class UBlendSpace :
    public UAnimationAsset,
    public IInterpolationIndexProvider

Remarks

Allows multiple animations to be blended between based on input parameters

Variables

Name Description

Public variable

TObjectPtr< UAn...

 

AnalysisProperties

Analysis properties for each axis.

Public variable

float

 

AnimLength

This is the maximum length of any sample in the blendspace.

Protected variable

TEnumAsByte< EB...

 

AxisToScaleAnimation

If you have input smoothing, this specifies the axis on which to scale the animation playback speed.

Public variable

bool

 

bAllowMeshSpaceBlending

If set then blending is performed in mesh space if there are per-bone sample smoothing overrides.

Public variable

bool

 

bContainsRotationOffsetMeshSpaceSamples

Indicates whether any samples have the flag to apply rotation offsets in mesh space

Public variable

bool

 

bInterpolateUsingGrid

If true then interpolation is done via a grid at runtime.

Protected variable

FBlendParameter...

 

BlendParameters

Blend Parameters for each axis.

Protected variable

FBlendSpaceData

 

BlendSpaceData

Container for the runtime data, which could be line segments, triangulation or tetrahedrons

Public variable

bool

 

bLoop

The default looping behavior of this blend space. Asset players can override this

Public variable

bool

 

bTargetWeightInterpolationEaseInOut

If set then this eases in/out the sample weight adjustments, using the speed to determine how much smoothing to apply.

Public variable

TObjectPtr< UCa...

 

CachedAnalysisProperties

Cached properties used to initialize properties when newly created.

Protected variable

TArray< int32 >

 

DimensionIndices

The order in which to use the dimensions in the data - e.g. [1, 2] means a 2D blend using Y and Z

Protected variable

TArray< struct ...

 

GridSamples

Grid samples, indexing scheme imposed by subclass

Public variable

FInterpolationP...

 

InterpolationParam

Input Smoothing parameters for each input axis

Protected variable

TArray< FPerBon...

 

ManualPerBoneOverrides

Per bone sample smoothing settings, which affect the specified bone and all its descendants in the skeleton.

Public variable

TEnumAsByte< EN...

 

NotifyTriggerMode

The current mode used by the BlendSpace to decide which animation notifies to fire.

Protected variable

EBlendSpacePerB...

 

PerBoneBlendMode

There are two ways to use per pone sample smoothing: Blend profiles and manually maintaining the per bone overrides.

Protected variable

FBlendSpaceBlen...

 

PerBoneBlendProfile

Reference to a blend profile of the corresponding skeleton to be used for per bone smoothing in case the per bone blend mode is set to use a blend profile.

Protected variable

TArray< FPerBon...

 

PerBoneBlendValues

Stores the actual bone references and their smoothing interpolation speeds used by the blend space.

Public variable

EPreferredTrian...

 

PreferredTriangulationDirection

Preferred edge direction when the triangulation has to make an arbitrary choice

Public variable

TObjectPtr< UAn...

 

PreviewBasePose

Preview Base pose for additive BlendSpace

Protected variable

FVector[3]

 

PreviousAxisMinMaxValues

Protected variable

float[3]

 

PreviousGridSpacings

Protected variable

TArray< struct ...

 

SampleData

Sample animation data

Protected variable

int32

 

SampleIndexWithMarkers

Track index to get marker data from.

Public variable

float

 

TargetWeightInterpolationSpeedPerSec

If greater than zero, this is the speed at which the sample weights are allowed to change.

Constructors

Name Description

Public function

UBlendSpace

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function

int32

 

AddSample

(
    const FVector& SampleValue
)

Add samples

Public function

int32

 

AddSample

(
    UAnimSequence* AnimationSequen...,
    const FVector& SampleValue
)

Add samples

Protected function Const

bool

 

ContainsMatchingSamples

(
    EAdditiveAnimationType AdditiveType
)

Returns whether or not all animation set on the blend space samples match the given additive type

Protected function Const

bool

 

ContainsNonAdditiveSamples()

Protected function Const

FVector

 

ConvertBlendInputToGridSpace

(
    const FVector& BlendInput
)

Translates BlendInput to grid space

Public function

bool

 

DeleteSample

(
    const int32 BlendSampleIndex
)

Delete samples

Public function Const

bool

 

DoesAnimationMatchExistingSamples

(
    const UAnimSequence* Animation...
)

Check if the blend spaces contains samples whos additive type match that of the animation sequence

Public function

bool

 

EditSampleValue

(
    const int32 BlendSampleIndex,
    const FVector& NewValue
)

Edit samples

Public function

void

 

ExpandRangeForSample

(
    const FVector& SampleValue
)

Public function Const

FVector

 

FilterInput

(
    FBlendFilter* Filter,
    const FVector& BlendInput,
    float DeltaTime
)

Interpolate BlendInput based on Filter data

Public function Const

void

 

ForEachImmutableSample

(
    const TFunctionRef< void(const FBle...
)

Allows the user to iterate through all the data samples available in the blend space.

Public function Const

float

 

GetAnimationLengthFromSampleData

(
    const TArray< FBlendSampleData >& ...
)

Utility function to calculate animation length from sample data list

Public function Const

void

 

GetAnimationPose

(
    TArray< FBlendSampleData >& BlendS...,
    const FAnimExtractContext& Extract...,
    FAnimationPoseData& OutAnimationPo...
)

Public function Const

void

 

GetAnimationPose

(
    TArray< FBlendSampleData >& BlendS...,
    TArrayView< FPoseLink > InPoseLinks,
    const FAnimExtractContext& Extract...,
    FPoseContext& Output
)

Protected function Virtual Const

EBlendSpaceA...

 

GetAxisToScale()

Returns the axis which can be used to scale animation speed.

Public function Const

const FBlend...

 

GetBlendParameter

(
    const int32 Index
)

Accessor for blend parameter

Public function Const

const FBlend...

 

GetBlendSample

(
    const int32 SampleIndex
)

Returns the Blend Sample at the given index, will assert on invalid indices

Public function Const

const TArray...

 

GetBlendSamples()

Get this blend spaces sample data

Public function Const

const FBlend...

 

GetBlendSpaceData()

Returns the runtime triangulation etc data

Public function Const

FVector

 

GetClampedAndWrappedBlendInput

(
    const FVector& BlendInput
)

Returns the blend input after clamping and/or wrapping

Protected function Const

FVector

 

GetClampedBlendInput

(
    const FVector& BlendInput
)

Returns the blend input clamped to the valid range, unless that axis has been set to wrap in which case no clamping is done

Public function Const

FVector

 

GetGridPosition

(
    int32 GridIndex
)

Returns the sample position associated with the elements returned by GetGridSamples

Public function Const

FVector

 

GetGridPosition

(
    int32 GridX,
    int32 GridY
)

Returns the sample position associated with the coordinates

Protected function Const

const FEdito...

 

GetGridSampleInternal

(
    int32 Index
)

Returns the grid element at Index or NULL if Index is not valid

Public function Const

const TArray...

 

GetGridSamples()

Return GridSamples from this BlendSpace

Protected function Const

FVector

 

GetNormalizedBlendInput

(
    const FVector& BlendInput
)

Translates BlendInput to grid space

Public function Const

int32

 

GetNumberOfBlendSamples()

Get the number of sample points for this blend space

Protected function Const

void

 

GetRawSamplesFromBlendInput

(
    const FVector& BlendInput,
    TArray< FGridBlendSample, TInlineAl...
)

Get Grid Samples from BlendInput, From Input, it will populate OutGridSamples with the closest grid points.

Public function Const

bool

 

GetSamplesFromBlendInput

(
    const FVector& BlendInput,
    TArray< FBlendSampleData >& OutSam...,
    int32& InOutCachedTriangulationInd...,
    bool bCombineAnimations
)

Get Grid Samples from BlendInput It will return all samples that has weight > KINDA_SMALL_NUMBER

Public function Const

void

 

InitializeFilter

(
    FBlendFilter* Filter,
    int NumDimensions
)

Initialize BlendSpace filtering for runtime.

Protected function

void

 

InitializePerBoneBlend()

Initialize Per Bone Blend

Protected function Const

bool

 

InterpolateWeightOfSampleData

(
    float DeltaTime,
    const TArray< FBlendSampleData >& ...,
    const TArray< FBlendSampleData >& ...,
    TArray< FBlendSampleData >& FinalS...
)

Utility function to interpolate weight of samples from OldSampleDataList to NewSampleDataList and copy back the interpolated result to FinalSampleDataList

Public function Const

bool

 

IsAnimationCompatible

(
    const UAnimSequence* Animation...
)

Check if the animation sequence additive type is compatible with this blend space

Public function Const

bool

 

IsAnimationCompatibleWithSkeleton

(
    const UAnimSequence* Animation...
)

Check if the animation sequence's skeleton is compatible with this blendspace

Protected function Const

bool

 

IsSameSamplePoint

(
    const FVector& SamplePointA,
    const FVector& SamplePointB
)

Checks if the given samples points overlap

Public function Const

bool

 

IsSampleWithinBounds

(
    const FVector& SampleValue
)

Public function Const

bool

 

IsTooCloseToExistingSamplePoint

(
    const FVector& SampleValue,
    int32 OriginalIndex
)

Check if given sample value isn't too close to existing sample point

Public function Virtual Const

bool

 

IsValidAdditiveType

(
    EAdditiveAnimationType AdditiveType
)

Returns whether or not the given additive animation type is compatible with the blendspace type

Public function Const

bool

 

IsValidBlendSampleIndex

(
    const int32 SampleIndex
)

Check whether or not the sample index is valid in combination with the stored sample data

Public function

bool

 

ReplaceSampleAnimation

(
    const int32 BlendSampleIndex,
    UAnimSequence* AnimationSequen...
)

Update animation on grid sample

Public function

void

 

ResampleData()

Runs triangulation/segmentation to update our grid and BlendSpaceData structures

Protected function Const

void

 

ResetToRefPose

(
    FCompactPose& OutPose
)

Reset to reference pose. It does apply different refpose based on additive or not

Public function

void

 

RuntimeValidateMarkerData()

Public function

void

 

SetBlendSpaceData

(
    const TArray< FBlendSpaceSegment > ...
)

Sets up BlendSpaceData based on Line elements

Public function Const

bool

 

ShouldAnimationBeAdditive()

Check if the the blendspace contains additive samples only

Protected function Virtual

void

 

SnapSamplesToClosestGridPoint()

If around border, snap to the border to avoid empty hole of data that is not valid

Protected function Const

void

 

TickFollowerSamples

(
    TArray< FBlendSampleData >& Sample...,
    const int32 HighestWeightIndex,
    FAnimAssetTickContext& Context,
    bool bResetMarkerDataOnFollowers,
    const UMirrorDataTable* Mirror...
)

Public function Const

bool

 

UpdateBlendSamples

(
    const FVector& InBlendSpacePositio...,
    float InDeltaTime,
    TArray< FBlendSampleData >& InOutS...,
    int32& InOutCachedTriangulationInd...
)

Updates a cached set of blend samples according to internal parameters, blendspace position and a delta time.

Public function Static

void

 

UpdateBlendSpacesUsingAnimSequence

(
    UAnimSequenceBase* Sequence
)

Validates sample data for blendspaces using the given animation sequence

Public function Const

void

 

UpdateFilterParams

(
    FBlendFilter* Filter
)

Update BlendSpace filtering parameters - values that don't require a full initialization

Protected function

void

 

UpdatePreviewBasePose()

Public function Const

bool

 

ValidateAnimationSequence

(
    const UAnimSequence* Animation...
)

Validate that the given animation sequence and contained blendspace data

Public function

void

 

ValidateSampleData()

Validates the contained data

Public function Const

bool

 

ValidateSampleValue

(
    const FVector& SampleValue,
    int32 OriginalIndex
)

Validates supplied blend sample against current contents of blendspace

Overridden from UAnimationAsset

Name Description

Public function Virtual

bool

 

GetAllAnimationSequencesReferred

(
    TArray< UAnimationAsset* >& A...,
    bool bRecursive
)

Retrieve all animations that are used by this asset

Public function Virtual Const

int32

 

GetMarkerUpdateCounter()

Public function Virtual Const

float

 

GetPlayLength()

This is used in editor only when used for transition getter this doesn't mean max time.

Public function Virtual

TArray< FNam...

 

GetUniqueMarkerNames()

Return a list of unique marker names for blending compatibility

Public function Virtual Const

bool

 

IsValidAdditive()

Return true if this is valid additive animation false otherwise

Public function Virtual

void

 

ReplaceReferredAnimations

(
    const TMap< UAnimationAsset*, ...
)

Replace this assets references to other animations based on ReplacementMap

Public function Virtual Const

void

 

TickAssetPlayer

(
    FAnimTickRecord& Instance,
    FAnimNotifyQueue& NotifyQueue,
    FAnimAssetTickContext& Context
)

Advances the asset player instance

Overridden from UObject

Name Description

Public function Virtual

void

 

PostEditChangeProperty

(
    FPropertyChangedEvent& PropertyCha...
)

Called when a property on this object has been modified externally

Public function Virtual

void

 

PostLoad()

Do any object-specific cleanup required immediately after loading an object.

Public function Virtual

void

 

PreEditChange

(
    FProperty* PropertyAboutToChan...
)

This is called when a property is about to be modified externally

Public function Virtual

void

 

Serialize

(
    FArchive& Ar
)

Handles reading, writing, and reference collecting using FArchive.

Overridden from IInterpolationIndexProvider

Name Description

Public function Virtual Const

TSharedPtr< ...

 

GetPerBoneInterpolationData

(
    const USkeleton* Skeleton
)

Sorts the PerBoneBlend data into a form that can be repeatedly used in GetPerBoneInterpolationIndex

Public function Virtual Const

int32

 

GetPerBoneInterpolationIndex

(
    const FCompactPoseBoneIndex& InCom...,
    const FBoneContainer& RequiredBone...,
    const IInterpolationIndexProvider::...
)

Get PerBoneInterpolationIndex for the input BoneIndex If nothing found, return INDEX_NONE

Deprecated Variables

Name Description

Public variable

bool

 

bRotationBlendInMeshSpace_DEPRECATED

This property is deprecated. Please use/see bContainsRotationOffsetMeshSpaceSamples instead

Deprecated Functions

Name Description

Public function Const

void

 

GetAnimationPose

(
    TArray< FBlendSampleData >& BlendS...,
    FCompactPose& OutPose,
    FBlendedCurve& OutCurve
)

Use GetAnimationPose with other signature

Public function Const

void

 

GetAnimationPose

(
    TArray< FBlendSampleData >& BlendS...,
    TArrayView< FPoseLink > InPoseLinks,
    FPoseContext& Output
)

Use GetAnimationPose with extraction context signature

Public function Const

void

 

GetAnimationPose

(
    TArray< FBlendSampleData >& BlendS...,
    FAnimationPoseData& OutAnimationPo...
)

Use GetAnimationPose with extraction context signature

Public function

bool

 

UpdateSampleAnimation

(
    UAnimSequence* AnimationSequen...,
    const FVector& SampleValue
)

Please use ReplaceSampleAnimation instead

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Cancel