You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#ROBOMERGE-AUTHOR: michael.balzer #ROBOMERGE-SOURCE: CL 18227685 in //UE5/Release-5.0/... via CL 18229350 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469) #ROBOMERGE[STARSHIP]: UE5-Main [CL 18231457 by michael balzer in ue5-release-engine-test branch]
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "FitCapsule3.h"
|
|
#include "ThirdParty/GTEngine/Mathematics/GteCapsule.h"
|
|
#include "ThirdParty/GTEngine/Mathematics/GteContCapsule3.h"
|
|
|
|
using namespace UE::Geometry;
|
|
using namespace UE::Math;
|
|
|
|
template<typename RealType>
|
|
bool TFitCapsule3<RealType>::Solve(int32 NumPoints, TFunctionRef<TVector<RealType>(int32)> GetPointFunc)
|
|
{
|
|
using ComputeType = double;
|
|
|
|
TArray<gte::Vector3<ComputeType>> PointList;
|
|
PointList.SetNum(NumPoints);
|
|
for (int32 k = 0; k < NumPoints; ++k)
|
|
{
|
|
TVector<RealType> Point = GetPointFunc(k);
|
|
PointList[k] = { {(ComputeType)Point.X, (ComputeType)Point.Y, (ComputeType)Point.Z} };
|
|
}
|
|
|
|
gte::Capsule3<ComputeType> FitCapsule;
|
|
bResultValid = GetContainer(NumPoints, &PointList[0], FitCapsule);
|
|
if (bResultValid)
|
|
{
|
|
gte::Vector3<ComputeType> Center, Direction;
|
|
ComputeType Extent;
|
|
FitCapsule.segment.GetCenteredForm(Center, Direction, Extent);
|
|
|
|
Capsule.Segment = TSegment3<RealType>(
|
|
TVector<RealType>((RealType)Center[0], (RealType)Center[1], (RealType)Center[2]),
|
|
TVector<RealType>((RealType)Direction[0], (RealType)Direction[1], (RealType)Direction[2]),
|
|
(RealType)Extent);
|
|
|
|
Capsule.Radius = (RealType)FitCapsule.radius;
|
|
}
|
|
|
|
return bResultValid;
|
|
}
|
|
|
|
|
|
namespace UE
|
|
{
|
|
namespace Geometry
|
|
{
|
|
|
|
template class GEOMETRYALGORITHMS_API TFitCapsule3<float>;
|
|
template class GEOMETRYALGORITHMS_API TFitCapsule3<double>;
|
|
|
|
} // end namespace UE::Geometry
|
|
} // end namespace UE
|