2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "AnimNode_SkeletalControlBase.h"
|
|
|
|
|
#include "AnimNode_SpringBone.generated.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Simple controller that replaces or adds to the translation/rotation of a single bone.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
USTRUCT()
|
2015-06-10 10:57:15 -04:00
|
|
|
struct ANIMGRAPHRUNTIME_API FAnimNode_SpringBone : public FAnimNode_SkeletalControlBase
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-03-17 05:38:32 -04:00
|
|
|
GENERATED_USTRUCT_BODY()
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
/** Name of bone to control. This is the main bone chain to modify from. **/
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Spring)
|
|
|
|
|
FBoneReference SpringBone;
|
|
|
|
|
|
|
|
|
|
/** Limit the amount that a bone can stretch from its ref-pose length. */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Spring)
|
|
|
|
|
bool bLimitDisplacement;
|
|
|
|
|
|
|
|
|
|
/** If bLimitDisplacement is true, this indicates how long a bone can stretch beyond its length in the ref-pose. */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Spring, meta=(EditCondition="bLimitDisplacement"))
|
|
|
|
|
float MaxDisplacement;
|
|
|
|
|
|
|
|
|
|
/** Stiffness of spring */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Spring)
|
|
|
|
|
float SpringStiffness;
|
|
|
|
|
|
|
|
|
|
/** Damping of spring */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Spring)
|
|
|
|
|
float SpringDamping;
|
|
|
|
|
|
|
|
|
|
/** If spring stretches more than this, reset it. Useful for catching teleports etc */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Spring)
|
|
|
|
|
float ErrorResetThresh;
|
|
|
|
|
|
|
|
|
|
/** If true, Z position is always correct, no spring applied */
|
2015-05-22 10:45:10 -04:00
|
|
|
UPROPERTY()
|
|
|
|
|
bool bNoZSpring_DEPRECATED;
|
|
|
|
|
|
|
|
|
|
/** If true take the spring calculation for translation in X */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=FilterChannels)
|
|
|
|
|
bool bTranslateX;
|
|
|
|
|
|
|
|
|
|
/** If true take the spring calculation for translation in Y */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=FilterChannels)
|
|
|
|
|
bool bTranslateY;
|
|
|
|
|
|
|
|
|
|
/** If true take the spring calculation for translation in Z */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=FilterChannels)
|
|
|
|
|
bool bTranslateZ;
|
|
|
|
|
|
|
|
|
|
/** If true take the spring calculation for rotation in X */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=FilterChannels)
|
|
|
|
|
bool bRotateX;
|
|
|
|
|
|
|
|
|
|
/** If true take the spring calculation for rotation in Y */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=FilterChannels)
|
|
|
|
|
bool bRotateY;
|
|
|
|
|
|
|
|
|
|
/** If true take the spring calculation for rotation in Z */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=FilterChannels)
|
|
|
|
|
bool bRotateZ;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
/** Internal use - Amount of time we need to simulate. */
|
|
|
|
|
float RemainingTime;
|
|
|
|
|
|
2015-02-11 10:02:27 -05:00
|
|
|
/** Internal use - Current timestep */
|
|
|
|
|
float FixedTimeStep;
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
/** Did we have a non-zero ControlStrength last frame. */
|
|
|
|
|
bool bHadValidStrength;
|
|
|
|
|
|
|
|
|
|
/** World-space location of the bone. */
|
|
|
|
|
FVector BoneLocation;
|
|
|
|
|
|
|
|
|
|
/** World-space velocity of the bone. */
|
|
|
|
|
FVector BoneVelocity;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
FAnimNode_SpringBone();
|
|
|
|
|
|
|
|
|
|
// FAnimNode_Base interface
|
2014-06-13 06:14:46 -04:00
|
|
|
virtual void Initialize(const FAnimationInitializeContext& Context) override;
|
2014-10-01 14:45:04 -04:00
|
|
|
virtual void CacheBones(const FAnimationCacheBonesContext& Context) override;
|
2014-06-13 06:14:46 -04:00
|
|
|
virtual void Update(const FAnimationUpdateContext& Context) override;
|
|
|
|
|
virtual void GatherDebugData(FNodeDebugData& DebugData) override;
|
2014-03-14 14:13:41 -04:00
|
|
|
// End of FAnimNode_Base interface
|
|
|
|
|
|
|
|
|
|
// FAnimNode_SkeletalControlBase interface
|
2015-05-19 06:19:22 -04:00
|
|
|
virtual void EvaluateBoneTransforms(USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases, TArray<FBoneTransform>& OutBoneTransforms) override;
|
2014-10-01 14:45:04 -04:00
|
|
|
virtual bool IsValidToEvaluate(const USkeleton* Skeleton, const FBoneContainer& RequiredBones) override;
|
2014-03-14 14:13:41 -04:00
|
|
|
// End of FAnimNode_SkeletalControlBase interface
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// FAnimNode_SkeletalControlBase interface
|
2014-10-01 14:45:04 -04:00
|
|
|
virtual void InitializeBoneReferences(const FBoneContainer& RequiredBones) override;
|
2014-03-14 14:13:41 -04:00
|
|
|
// End of FAnimNode_SkeletalControlBase interface
|
|
|
|
|
};
|