Files
UnrealEngineUWP/Engine/Source/Runtime/AnimGraphRuntime/Public/BoneControllers/AnimNode_CCDIK.h
aurel cordonnier 50944fd712 Merge UE5/RES @ 16162155 to UE5/Main
This represents UE4/Main @ 16130047 and Dev-PerfTest @ 16126156

[CL 16163576 by aurel cordonnier in ue5-main branch]
2021-04-29 19:32:06 -04:00

88 lines
3.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "AnimNode_SkeletalControlBase.h"
#include "CCDIK.h"
#include "AnimNode_CCDIK.generated.h"
/**
* Controller which implements the CCDIK IK approximation algorithm
*/
USTRUCT()
struct ANIMGRAPHRUNTIME_API FAnimNode_CCDIK : public FAnimNode_SkeletalControlBase
{
GENERATED_USTRUCT_BODY()
/** Coordinates for target location of tip bone - if EffectorLocationSpace is bone, this is the offset from Target Bone to use as target location*/
UPROPERTY(EditAnywhere, Category = Effector, meta = (PinShownByDefault))
FVector EffectorLocation;
/** Reference frame of Effector Transform. */
UPROPERTY(EditAnywhere, Category = Effector)
TEnumAsByte<enum EBoneControlSpace> EffectorLocationSpace;
/** If EffectorTransformSpace is a bone, this is the bone to use. **/
UPROPERTY(EditAnywhere, Category = Effector)
FBoneSocketTarget EffectorTarget;
/** Name of tip bone */
UPROPERTY(EditAnywhere, Category = Solver)
FBoneReference TipBone;
/** Name of the root bone*/
UPROPERTY(EditAnywhere, Category = Solver)
FBoneReference RootBone;
/** Tolerance for final tip location delta from EffectorLocation*/
UPROPERTY(EditAnywhere, Category = Solver)
float Precision;
/** Maximum number of iterations allowed, to control performance. */
UPROPERTY(EditAnywhere, Category = Solver)
int32 MaxIterations;
/** Toggle drawing of axes to debug joint rotation*/
UPROPERTY(EditAnywhere, Category = Solver)
bool bStartFromTail;
/** Tolerance for final tip location delta from EffectorLocation*/
UPROPERTY(EditAnywhere, Category = Solver)
bool bEnableRotationLimit;
private:
/** symmetry rotation limit per joint. Index 0 matches with root bone and last index matches with tip bone. */
UPROPERTY(EditAnywhere, EditFixedSize, Category = Solver)
TArray<float> RotationLimitPerJoints;
public:
FAnimNode_CCDIK();
// FAnimNode_Base interface
virtual void GatherDebugData(FNodeDebugData& DebugData) override;
// End of FAnimNode_Base interface
// FAnimNode_SkeletalControlBase interface
virtual void EvaluateSkeletalControl_AnyThread(FComponentSpacePoseContext& Output, TArray<FBoneTransform>& OutBoneTransforms) override;
virtual bool IsValidToEvaluate(const USkeleton* Skeleton, const FBoneContainer& RequiredBones) override;
// End of FAnimNode_SkeletalControlBase interface
private:
// FAnimNode_SkeletalControlBase interface
virtual void InitializeBoneReferences(const FBoneContainer& RequiredBones) override;
// End of FAnimNode_SkeletalControlBase interface
// Convenience function to get current (pre-translation iteration) component space location of bone by bone index
FVector GetCurrentLocation(FCSPose<FCompactPose>& MeshBases, const FCompactPoseBoneIndex& BoneIndex);
static FTransform GetTargetTransform(const FTransform& InComponentTransform, FCSPose<FCompactPose>& MeshBases, FBoneSocketTarget& InTarget, EBoneControlSpace Space, const FVector& InOffset);
public:
#if WITH_EDITOR
#if UE_ENABLE_DEBUG_DRAWING
TArray<FVector> DebugLines;
#endif // #if UE_ENABLE_DEBUG_DRAWING
// resize rotation limit array based on set up
void ResizeRotationLimitPerJoints(int32 NewSize);
#endif
};