Refactored Feet Position Animation Data.
Optimization for FeetPosition
This commit is contained in:
parent
a17d3ca74a
commit
7286acad8b
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 51 KiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -25,4 +25,6 @@ LastGPUBenchmarkResult=-1.000000
|
||||
LastGPUBenchmarkMultiplier=1.000000
|
||||
bUseHDRDisplayOutput=False
|
||||
HDRDisplayOutputNits=1000
|
||||
WindowPosX=-1
|
||||
WindowPosY=-1
|
||||
|
||||
|
||||
@ -426,6 +426,11 @@ const FVector& UOLSBaseLayerAnimInstance::GetWorldVelocity() const
|
||||
return WorldVelocity;
|
||||
}
|
||||
|
||||
const FRotator& UOLSBaseLayerAnimInstance::GetWorldRotation() const
|
||||
{
|
||||
return WorldRotation;
|
||||
}
|
||||
|
||||
const float& UOLSBaseLayerAnimInstance::GetLocalVelocityDirectionAngle() const
|
||||
{
|
||||
return LocalVelocityDirectionAngle;
|
||||
|
||||
@ -39,6 +39,7 @@ void UOLSBaseLinkedLayerAnimInstance::NativeUpdateEssentialValues(const float de
|
||||
if (BaseMainAnimInstance)
|
||||
{
|
||||
WorldVelocity = BaseMainAnimInstance->GetWorldVelocity();
|
||||
WorldRotation = BaseMainAnimInstance->GetWorldRotation();
|
||||
LocalVelocityDirectionAngle = BaseMainAnimInstance->GetLocalVelocityDirectionAngle();
|
||||
DisplacementSpeed = BaseMainAnimInstance->GetDisplacementSpeed();
|
||||
LocalAcceleration2D = BaseMainAnimInstance->GetLocalAcceleration2D();
|
||||
@ -52,6 +53,10 @@ void UOLSBaseLinkedLayerAnimInstance::NativeUpdateEssentialValues(const float de
|
||||
RotationMode = BaseMainAnimInstance->GetRotationMode();
|
||||
|
||||
OwningPawnMaxSpeed = BaseMainAnimInstance->GetOwningPawnMaxSpeed();
|
||||
|
||||
FeetPositionData.RootTransform = GetOwningActor()->GetTransform();
|
||||
FeetPositionData.LeftFootLocation = GetOwningComponent()->GetSocketLocation(FeetPositionSettings.LeftFootName);
|
||||
FeetPositionData.RightFootLocation = GetOwningComponent()->GetSocketLocation(FeetPositionSettings.RightFootName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,33 +64,7 @@ void UOLSBaseLinkedLayerAnimInstance::NativeThreadSafeUpdateSkeletonControlData(
|
||||
{
|
||||
OrientationWarpingAlpha = GetCurveValue(EnableOrientationWarpingName);
|
||||
|
||||
bIsLeftFootFarFromTarget = UKismetAnimationLibrary::K2_DistanceBetweenTwoSocketsAndMapRange(
|
||||
GetOwningComponent(), FeetPositionSettings.IKFootLeft, RTS_World,
|
||||
FeetPositionSettings.IKTargetFootLeft, RTS_World, false,
|
||||
0.f, 0.f, 0.f, 0.f) > 8.0f;
|
||||
|
||||
bIsRightFootFarFromTarget = UKismetAnimationLibrary::K2_DistanceBetweenTwoSocketsAndMapRange(
|
||||
GetOwningComponent(), FeetPositionSettings.IKFootRight, RTS_World,
|
||||
FeetPositionSettings.IKTargetFootRight, RTS_World, false,
|
||||
0.f, 0.f, 0.f, 0.f) > 8.0f;
|
||||
|
||||
// If neither foot is planted, use the last valid foot
|
||||
if (!bIsRightFootFarFromTarget && !bIsLeftFootFarFromTarget)
|
||||
{
|
||||
if (bWasRightFootPlantingChanged)
|
||||
{
|
||||
bIsRightFootFarFromTarget = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bIsLeftFootFarFromTarget = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update the last valid foot
|
||||
bWasRightFootPlantingChanged = bIsRightFootFarFromTarget;
|
||||
}
|
||||
// FeetPositionData.DetermineIfRightFootIsFront();
|
||||
}
|
||||
|
||||
void UOLSBaseLinkedLayerAnimInstance::NativeThreadSafeUpdateLocomotionStateData(const float deltaSeconds)
|
||||
@ -160,12 +139,12 @@ UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectStartCycleAnimation(const
|
||||
{
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_CameraFacing.GetStartCycleFromHipDirection(hipDirection).
|
||||
GetMovementAnimByCardinalDirection(
|
||||
velocityDirection, bIsRightFootFarFromTarget);
|
||||
velocityDirection, FeetPositionData.IsRightFootIsFront());
|
||||
}
|
||||
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.StartCycle.
|
||||
GetMovementAnimationByAngle(
|
||||
velocityDirection, angle, bIsRightFootFarFromTarget);
|
||||
velocityDirection, angle, FeetPositionData.IsRightFootIsFront());
|
||||
}
|
||||
|
||||
UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectCycleAnimation(const bool isCrouching,
|
||||
@ -178,7 +157,7 @@ UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectCycleAnimation(const bool
|
||||
{
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_CameraFacing.GetCycleFromHipDirection(hipDirection).
|
||||
GetMovementAnimByCardinalDirection(
|
||||
velocityDirection, bIsRightFootFarFromTarget);
|
||||
velocityDirection, FeetPositionData.IsRightFootIsFront());
|
||||
}
|
||||
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.Cycle;
|
||||
@ -195,11 +174,11 @@ UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectPivotAnimation(const bool
|
||||
{
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_CameraFacing.GetPivotFromHipDirection(hipDirection).
|
||||
GetMovementAnimByCardinalDirection(
|
||||
velocityDirection, bIsRightFootFarFromTarget);
|
||||
velocityDirection, FeetPositionData.IsRightFootIsFront());
|
||||
}
|
||||
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.Pivot.GetLeftOrRightByAngle(
|
||||
angle, bIsRightFootFarFromTarget);
|
||||
angle, FeetPositionData.IsRightFootIsFront());
|
||||
}
|
||||
|
||||
UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectStopCycleAnimation(const bool isCrouching,
|
||||
@ -212,10 +191,10 @@ UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectStopCycleAnimation(const b
|
||||
{
|
||||
return GetGaitAnimSets(isCrouching, gait).
|
||||
GaitAnimSet_CameraFacing.GetStopCycleFromHipDirection(hipDirection).GetMovementAnimByCardinalDirection(
|
||||
velocityDirection, bIsRightFootFarFromTarget);
|
||||
velocityDirection, FeetPositionData.IsRightFootIsFront());
|
||||
}
|
||||
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.StopCycle.GetLeftOrRightAnim(bIsRightFootFarFromTarget);
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.StopCycle.GetLeftOrRightAnim(FeetPositionData.IsRightFootIsFront());
|
||||
}
|
||||
|
||||
FVector2D UOLSBaseLinkedLayerAnimInstance::SelectPlayRateByLocomotionState(
|
||||
|
||||
@ -5,6 +5,22 @@
|
||||
|
||||
#include "Data/OLSEnumLibrary.h"
|
||||
|
||||
void FOLSFeetPositionData::DetermineIfRightFootIsFront()
|
||||
{
|
||||
const FVector rightFootLocal = RootTransform.InverseTransformPosition(RightFootLocation);
|
||||
const FVector leftFootLocal = RootTransform.InverseTransformPosition(LeftFootLocation);
|
||||
|
||||
bIsRightFootFront = rightFootLocal.X > leftFootLocal.X;
|
||||
}
|
||||
|
||||
bool FOLSFeetPositionData::IsRightFootIsFront() const
|
||||
{
|
||||
const FVector rightFootLocal = RootTransform.InverseTransformPosition(RightFootLocation);
|
||||
const FVector leftFootLocal = RootTransform.InverseTransformPosition(LeftFootLocation);
|
||||
|
||||
return rightFootLocal.X > leftFootLocal.X;
|
||||
}
|
||||
|
||||
UAnimSequence* FOLSTurnInPlaceAnimSet::GetTurnInPlaceAnimationByDirection(const float direction) const
|
||||
{
|
||||
if (FMath::Abs(direction) < 130.f)
|
||||
|
||||
@ -87,7 +87,10 @@ public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe))
|
||||
const FVector& GetWorldVelocity() const;
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe))
|
||||
const FRotator& GetWorldRotation() const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe))
|
||||
const float& GetLocalVelocityDirectionAngle() const;
|
||||
|
||||
|
||||
@ -130,6 +130,9 @@ protected:
|
||||
UPROPERTY(BlueprintReadOnly, Category = "BaseMainAnimInstance|Cache")
|
||||
FVector WorldVelocity = FVector::ZeroVector;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "BaseMainAnimInstance|Cache")
|
||||
FRotator WorldRotation = FRotator::ZeroRotator;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "BaseMainAnimInstance|Cache")
|
||||
float DisplacementSpeed = 0.f;
|
||||
|
||||
@ -201,14 +204,8 @@ protected:
|
||||
|
||||
protected:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
||||
uint8 bWasRightFootPlantingChanged : 1 = false;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
||||
uint8 bIsRightFootFarFromTarget : 1 = true;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
||||
uint8 bIsLeftFootFarFromTarget : 1 = true;
|
||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPositionData")
|
||||
FOLSFeetPositionData FeetPositionData;
|
||||
|
||||
protected:
|
||||
|
||||
@ -262,7 +259,7 @@ protected:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|AnimSet|DistanceMatching")
|
||||
FName JumpDistanceCurveName = NAME_None;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|FeetPosition")
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings")
|
||||
FOLSFeetPositionSettings FeetPositionSettings;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|StrideWarping")
|
||||
|
||||
@ -17,16 +17,37 @@ struct FOLSFeetPositionSettings
|
||||
public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
||||
FName IKFootRight = NAME_None;
|
||||
FName RightFootName = NAME_None;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
||||
FName IKTargetFootRight = NAME_None;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
||||
FName IKFootLeft = NAME_None;
|
||||
FName LeftFootName = NAME_None;
|
||||
};
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
||||
FName IKTargetFootLeft = NAME_None;
|
||||
USTRUCT(BlueprintType)
|
||||
struct FOLSFeetPositionData
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
void DetermineIfRightFootIsFront();
|
||||
bool IsRightFootIsFront() const;
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FTransform RootTransform = FTransform::Identity;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FVector RightFootLocation = FVector::ZeroVector;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FVector LeftFootLocation = FVector::ZeroVector;
|
||||
|
||||
protected:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
uint8 bIsRightFootFront : 1 = false;
|
||||
};
|
||||
|
||||
#pragma region Idle and Turn In-Place AnimSets
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user