本文整理汇总了C++中FVector2D::GetSafeNormal方法的典型用法代码示例。如果您正苦于以下问题:C++ FVector2D::GetSafeNormal方法的具体用法?C++ FVector2D::GetSafeNormal怎么用?C++ FVector2D::GetSafeNormal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FVector2D
的用法示例。
在下文中一共展示了FVector2D::GetSafeNormal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPreferredVelocity
FVector2D UAvoidanceComponent::GetPreferredVelocity()
{
FVector2D ToTarget;
if (bUseAITargetLocation && aiController)
{
ToTarget = FVector2D{ aiController->GetPathFollowingComponent()->GetCurrentTargetLocation() };
//FVector2D actLoc {pawn->GetActorLocation() };
//UE_LOG(LogRVOTest, Warning, TEXT("UAv::prefv GetCurrentTargetLocation, %f %f, actloc: %f %f"), CurrentTarget.X, CurrentTarget.Y, actLoc.X, actLoc.Y);
//UE_LOG(LogRVOTest, Warning, TEXT("UAv::Totarget: %f %f"), ToTarget.X, ToTarget.Y);
}
else
{
ToTarget = FVector2D{ CurrentTarget - FVector2D{ pawn->GetActorLocation() } };
}
float sqrDist = ToTarget.SizeSquared();
if (sqrDist < AcceptanceSquared)
return FVector2D::ZeroVector;
float m = 1.f / (SlowdownSquared - AcceptanceSquared);
float b = -m * AcceptanceSquared;
float k = (sqrDist < SlowdownSquared && pathFollowSlowdown) ? sqrDist * m + b : 1.f;
if (k < SMALL_NUMBER)
{
return FVector2D::ZeroVector;
}
FVector2D res = ToTarget.GetSafeNormal() * MaxVelocity * k;
if (res.ContainsNaN())
{
UE_LOG(LogRVOTest, VeryVerbose, TEXT("UAvoidanceComp:: GetPreferredV , %f %f"), res.X, res.Y);
}
return res;
}
示例2:
FVector2D UKismetMathLibrary::Normal2D(FVector2D A)
{
return A.GetSafeNormal();
}