2024-05-15 14:50:35 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "StateTreeConsiderationBase.h"
|
2024-05-17 13:45:28 -04:00
|
|
|
#include "AlphaBlend.h"
|
|
|
|
|
#include "StateTreeTypes.h"
|
2024-05-15 14:50:35 -04:00
|
|
|
|
|
|
|
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(StateTreeConsiderationBase)
|
|
|
|
|
|
2024-05-17 13:45:28 -04:00
|
|
|
FStateTreeConsiderationResponseCurve::FStateTreeConsiderationResponseCurve()
|
|
|
|
|
: BlendOption(EAlphaBlendOption::Linear)
|
|
|
|
|
, RawScoreLowerBound(.0f)
|
|
|
|
|
, RawScoreUpperBound(.1f)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FStateTreeConsiderationBase::FStateTreeConsiderationBase()
|
|
|
|
|
: Operand(EStateTreeExpressionOperand::And)
|
|
|
|
|
, DeltaIndent(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-15 14:50:35 -04:00
|
|
|
float FStateTreeConsiderationBase::ComputeNormalizedScore(FStateTreeExecutionContext& Context) const
|
|
|
|
|
{
|
|
|
|
|
const float RawScore = ComputeRawScore(Context);
|
|
|
|
|
const float NormalizedScore = FMath::Clamp<float>(
|
|
|
|
|
FMath::GetRangePct(ResponseCurve.RawScoreLowerBound,
|
|
|
|
|
ResponseCurve.RawScoreUpperBound,
|
|
|
|
|
RawScore),
|
|
|
|
|
0.f, 1.f);
|
|
|
|
|
|
|
|
|
|
constexpr class UCurveFloat* OptionalCurve = nullptr;
|
|
|
|
|
return FAlphaBlend::AlphaToBlendOption(NormalizedScore, ResponseCurve.BlendOption, OptionalCurve);
|
|
|
|
|
}
|