17 template<
typename T,
int d>
26 template<
class T,
int d>
42 , Center(
Other.Center)
44 SetRadius(
Other.GetRadiusf());
51 SetRadius(
Other.GetRadiusf());
61 SetRadius(
InSteal.GetRadiusf());
87 return OutNormal.SafeNormalize() -
GetRadiusf();
103 virtual bool Raycast(
const TVector<T, d>& StartPoint,
const TVector<T, d>& Dir,
const T
Length,
const T Thickness, T& OutTime,
TVector<T, d>& OutPosition,
TVector<T, d>& OutNormal,
int32& OutFaceIndex)
const override
112 T
Length = Direction.Size();
113 Direction = Direction.GetSafeNormal();
155 T
SizeSqr = Direction.SizeSquared();
181 return Center *
Scale;
317 static const T
TwoThirds =
static_cast<T
>(2.0 / 3.0);
318 static const T
TwoFifths =
static_cast<T
>(2.0 / 5.0);
365 friend FImplicitObject;
383 ComputeGoldenSpiralPoints(Points,
Sphere, NumPoints);
391 ComputeGoldenSpiralPoints(Points,
Sphere.Center(),
Sphere.GetRadius(), NumPoints);
398 const int32 NumPoints,
401 const int32 Offset = Points.AddUninitialized(NumPoints);
410 static const T Increment =
static_cast<T
>(
UE_PI * (1.0 +
sqrt(5)));
411 for (
int32 i = 0; i < NumPoints; i++)
413 const T
Z =
static_cast<T
>(0.5 + i);
416 const T
R = FMath::Sqrt(
Z /
static_cast<T
>(NumPoints)) * Radius;
441 ComputeGoldenSpiralPoints(Points,
Sphere, NumPoints);
480 const int32 NumPoints,
490 const int32 Offset = Points.AddUninitialized(NumPoints);
509 for (
int32 i = 0; i < NumPoints; i++)
511 const T Sample =
static_cast<T
>(0.5 + i);
515 const T V =
static_cast<T
>((2.0 * (0.5 + i) / (2.0 * NumPoints)) - 1.0);
516 const T Phi = FMath::Acos(V);
521 const T
SinPhi = FMath::Sin(Phi);
527 Radius * FMath::Cos(Phi));
535 for (
int32 i = 0; i < NumPoints; i++)
537 const T Sample =
static_cast<T
>(0.5 + i);
538 const T V =
static_cast<T
>((2.0 * (0.5 + i) / (2.0 * NumPoints)));
539 const T Phi = FMath::Acos(V);
544 const T
SinPhi = FMath::Sin(Phi);
550 Radius * FMath::Cos(Phi));
558 for (
int32 i = 0; i < NumPoints; i++)
560 const T Sample =
static_cast<T
>(0.5 + i);
566 const T Phi =
static_cast<T
>(FMath::Acos(1.0 - 2.0 * Sample / NumPoints));
571 const T
SinPhi = FMath::Sin(Phi);
577 Radius * FMath::Cos(Phi));
587 ComputeGoldenSpiralPoints(Points,
Sphere, NumPoints,
true,
false,
SpiralSeed);
593 ComputeGoldenSpiralPoints(Points,
Sphere, NumPoints,
false,
true,
SpiralSeed);
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
FORCEINLINE VectorRegister4Float MakeVectorRegisterFloat(uint32 X, uint32 Y, uint32 Z, uint32 W)
Definition UnrealMathFPU.h:175
#define UE_PI
Definition UnrealMathUtility.h:129
#define UE_KINDA_SMALL_NUMBER
Definition UnrealMathUtility.h:131
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32 Offset
Definition VulkanMemory.cpp:4033
uint32 Size
Definition VulkanMemory.cpp:4034
Definition ChaosArchive.h:364
Definition ChaosArchive.h:167
Definition ImplicitObject.h:111
bool bHasBoundingBox
Definition ImplicitObject.h:574
FRealSingle Margin
Definition ImplicitObject.h:571
bool HasBoundingBox() const
Definition ImplicitObject.h:275
EImplicitObjectType Type
Definition ImplicitObject.h:585
bool bDoCollide
Definition ImplicitObject.h:573
bool IsConvex() const
Definition ImplicitObject.h:277
virtual FName GetTypeName() const
Definition ImplicitObject.h:414
CHAOS_API void SerializeImp(FArchive &Ar)
Definition ImplicitObject.cpp:337
void SetMargin(FReal InMargin)
Definition ImplicitObject.h:567
bool bIsConvex
Definition ImplicitObject.h:572
TSphere & operator=(TSphere< T, d > &&InSteal)
Definition Sphere.h:54
virtual Chaos::FImplicitObjectPtr CopyGeometryWithScale(const FVec3 &Scale) const override
Definition Sphere.h:340
TSphere(const TVector< T, d > &InCenter, const T InRadius)
Definition Sphere.h:33
virtual FString ToString() const override
Definition Sphere.h:241
FORCEINLINE TVector< T, d > SupportCoreScaled(const TVector< T, d > &Direction, const FReal InMargin, const TVector< T, d > &Scale, FReal *OutSupportDelta, int32 &VertexIndex) const
Definition Sphere.h:177
virtual FReal GetRadius() const override
Definition Sphere.h:74
TSphere(TSphere< T, d > &&Other)
Definition Sphere.h:47
virtual FRealSingle GetRadiusf() const override
Definition Sphere.h:79
PMatrix< T, d, d > GetInertiaTensor(const T InMass, const bool bInThinShell=false) const
Definition Sphere.h:310
TVector< T, d > FindClosestPoint(const TVector< T, d > &StartPoint, const T Thickness=(T) 0) const
Definition Sphere.h:97
static constexpr EImplicitObjectType StaticType()
Definition Sphere.h:68
TArray< TVector< T, d > > ComputeSamplePoints(const T PointsPerUnitArea, const int32 MinPoints=0, const int32 MaxPoints=1000) const
Definition Sphere.h:305
static T GetVolume(const T InRadius)
Definition Sphere.h:213
FORCEINLINE VectorRegister4Float SupportCoreSimd(const VectorRegister4Float &Direction, const FReal InMargin) const
Definition Sphere.h:173
static PMatrix< T, d, d > GetInertiaTensor(const T InMass, const T InRadius, const bool bInThinShell=false)
Definition Sphere.h:315
virtual T PhiWithNormal(const TVector< T, d > &InSamplePoint, TVector< T, d > &OutNormal) const override
Definition Sphere.h:84
virtual Pair< TVector< T, d >, bool > FindClosestIntersectionImp(const TVector< T, d > &StartPoint, const TVector< T, d > &EndPoint, const T Thickness) const override
Definition Sphere.h:109
TSphere(const TSphere< T, d > &Other)
Definition Sphere.h:40
virtual bool Raycast(const TVector< T, d > &StartPoint, const TVector< T, d > &Dir, const T Length, const T Thickness, T &OutTime, TVector< T, d > &OutPosition, TVector< T, d > &OutNormal, int32 &OutFaceIndex) const override
Definition Sphere.h:103
bool Intersects(const TSphere< T, d > &Other) const
Definition Sphere.h:90
const TVector< T, d > GetCenterOfMass() const
Definition Sphere.h:231
virtual ~TSphere()
Definition Sphere.h:66
virtual FName GetTypeName() const
Definition ImplicitObject.h:414
TRotation< T, d > GetRotationOfMass() const
Definition Sphere.h:323
virtual void Serialize(FArchive &Ar) override
Definition Sphere.h:263
virtual const TAABB< T, d > BoundingBox() const override
Definition Sphere.h:184
TArray< TVector< T, d > > ComputeSamplePoints(const int NumPoints) const
Definition Sphere.h:298
FORCEINLINE void SerializeImp(FArchive &Ar)
Definition Sphere.h:246
virtual void Serialize(FChaosArchive &Ar) override
Definition Sphere.h:257
virtual Chaos::FImplicitObjectPtr CopyGeometry() const override
Definition Sphere.h:335
const FVec3f & GetCenterf() const
Definition Sphere.h:226
T GetArea() const
Definition Sphere.h:196
T GetVolume() const
Definition Sphere.h:208
TArray< TVector< T, d > > ComputeLocalSamplePoints(const int NumPoints) const
Definition Sphere.h:271
const FVec3f & GetCenterOfMassf() const
Definition Sphere.h:236
const TVector< T, d > GetCenter() const
Definition Sphere.h:221
TVector< T, d > Support(const TVector< T, d > &Direction, const T Thickness, int32 &VertexIndex) const
Definition Sphere.h:151
virtual uint32 GetTypeHash() const override
Definition Sphere.h:328
FORCEINLINE const TVector< T, d > SupportCore(const TVector< T, d > &Direction, const FReal InMargin, FReal *OutSupportDelta, int32 &VertexIndex) const
Definition Sphere.h:166
static T GetArea(const T InRadius)
Definition Sphere.h:201
TArray< TVector< T, d > > ComputeLocalSamplePoints(const T PointsPerUnitArea, const int32 MinPoints=0, const int32 MaxPoints=1000) const
Definition Sphere.h:290
virtual FAABB3 CalculateTransformedBounds(const FRigidTransform3 &Transform) const override
Definition Sphere.h:189
FRealSingle Min() const
Definition Vector.h:523
Definition Archive.h:1208
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
UE_FORCEINLINE_HINT void Reserve(SizeType Number)
Definition Array.h:3016
@ Sphere
Definition ImplicitObjectType.h:13
bool RaySphere(const TVector< T, d > &RayStart, const TVector< T, d > &RayDir, const T RayLength, const T RayThickness, const FVec3f &SphereCenter, const FRealSingle SphereRadius, T &OutTime, TVector< T, d > &OutPosition, TVector< T, d > &OutNormal)
Definition Raycasts.h:72
Definition SkeletalMeshComponent.h:307
TSphere< FReal, 3 > FSphere
Definition ImplicitObject.h:36
TVector< FRealSingle, 3 > FVec3f
Definition Core.h:27
TRefCountPtr< FImplicitObject > FImplicitObjectPtr
Definition ImplicitFwd.h:33
uint8 EImplicitObjectType
Definition ImplicitObjectType.h:41
FRealDouble FReal
Definition Real.h:22
Pair< T1, T2 > MakePair(const T1 &First, const T2 &Second)
Definition Pair.h:45
float FRealSingle
Definition Real.h:14
TVector< FReal, 3 > FVec3
Definition Core.h:17
TAABB< FReal, 3 > FAABB3
Definition ImplicitObject.h:34
@ Diagonal
Definition BlockSparseLinearSystem.cpp:34
uint32 GetTypeHash(const TBox< T > &Box)
Definition Box.h:1008
U16 Index
Definition radfft.cpp:71
static FORCEINLINE void ComputeSamplePoints(TArray< TVec2< T > > &Points, const TSphere< T, 2 > &Sphere, const int32 NumPoints)
Definition Sphere.h:375
static FORCEINLINE void ComputeGoldenSpiralPoints(TArray< TVec2< T > > &Points, const TVec2< T > &Center, const T Radius, const int32 NumPoints, const int32 SpiralSeed=0)
Definition Sphere.h:394
static FORCEINLINE void ComputeGoldenSpiralPoints(TArray< TVec2< T > > &Points, const TSphere< T, 2 > &Sphere, const int32 NumPoints)
Definition Sphere.h:389
static FORCEINLINE void ComputeSamplePoints(TArray< TVec3< T > > &Points, const TSphere< T, 3 > &Sphere, const int32 NumPoints)
Definition Sphere.h:433
static FORCEINLINE void ComputeGoldenSpiralPoints(TArray< TVec3< T > > &Points, const TVec3< T > &Center, const T Radius, const int32 NumPoints, const bool BottomHalf=true, const bool TopHalf=true, const int32 SpiralSeed=0)
Definition Sphere.h:476
static FORCEINLINE void ComputeBottomHalfSemiSphere(TArray< TVec3< T > > &Points, const TSphere< T, 3 > &Sphere, const int32 NumPoints, const int32 SpiralSeed=0)
Definition Sphere.h:584
static FORCEINLINE void ComputeTopHalfSemiSphere(TArray< TVec3< T > > &Points, const TSphere< T, 3 > &Sphere, const int32 NumPoints, const int32 SpiralSeed=0)
Definition Sphere.h:590
static FORCEINLINE void ComputeGoldenSpiralPoints(TArray< TVec3< T > > &Points, const TSphere< T, 3 > &Sphere, const int32 NumPoints, const bool FirstHalf=true, const bool SecondHalf=true, const int32 SpiralSeed=0)
Definition Sphere.h:447
static FORCEINLINE void ComputeSamplePoints(TArray< TVec3< T > > &Points, const class TSphere< T, 3 > &Sphere, const int32 NumPoints)
Definition Sphere.h:20
static constexpr UE_FORCEINLINE_HINT T Clamp(const T X, const T MinValue, const T MaxValue)
Definition UnrealMathUtility.h:592
Definition NumericLimits.h:41
FString ToString() const
Definition Vector.h:2304
static UE_FORCEINLINE_HINT FRealSingle DistSquared(const TVector< FRealSingle > &V1, const TVector< FRealSingle > &V2)
Definition Vector.h:2478
Definition UnrealMathFPU.h:20