UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Sphere.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "Chaos/Box.h"
5#include "Chaos/GJKShape.h"
6#include "Chaos/ImplicitFwd.h"
8#include "Chaos/Raycasts.h"
9#include "ChaosArchive.h"
10
11#include "Math/VectorRegister.h"
12
14
15namespace Chaos
16{
17 template<typename T, int d>
19 {
20 static FORCEINLINE void ComputeSamplePoints(TArray<TVec3<T>>& Points, const class TSphere<T, 3>& Sphere, const int32 NumPoints)
21 {
22 check(false);
23 }
24 };
25
26 template<class T, int d>
27 class TSphere final : public FImplicitObject
28 {
29 public:
30
32
34 : FImplicitObject(EImplicitObject::IsConvex | EImplicitObject::HasBoundingBox, ImplicitObjectType::Sphere)
35 , Center(InCenter)
36 {
37 SetRadius(FRealSingle(InRadius));
38 }
39
41 : FImplicitObject(EImplicitObject::IsConvex | EImplicitObject::HasBoundingBox, ImplicitObjectType::Sphere)
42 , Center(Other.Center)
43 {
44 SetRadius(Other.GetRadiusf());
45 }
46
48 : FImplicitObject(EImplicitObject::IsConvex | EImplicitObject::HasBoundingBox, ImplicitObjectType::Sphere)
49 , Center(MoveTemp(Other.Center))
50 {
51 SetRadius(Other.GetRadiusf());
52 }
53
55 {
56 this->Type = InSteal.Type;
57 this->bIsConvex = InSteal.bIsConvex;
58 this->bDoCollide = InSteal.bDoCollide;
59 this->bHasBoundingBox = InSteal.bHasBoundingBox;
60 Center = MoveTemp(InSteal.Center);
61 SetRadius(InSteal.GetRadiusf());
62
63 return *this;
64 }
65
66 virtual ~TSphere() {}
67
69 {
71 }
72
73 UE_DEPRECATED(5.6, "Use GetRadiusf instead.")
74 virtual FReal GetRadius() const override
75 {
76 return Margin;
77 }
78
79 virtual FRealSingle GetRadiusf() const override
80 {
81 return Margin;
82 }
83
84 virtual T PhiWithNormal(const TVector<T, d>& InSamplePoint, TVector<T, d>& OutNormal) const override
85 {
86 OutNormal = InSamplePoint - Center;
87 return OutNormal.SafeNormalize() - GetRadiusf();
88 }
89
90 bool Intersects(const TSphere<T, d>& Other) const
91 {
93 FRealSingle RadialSum = Other.GetRadiusf() + GetRadiusf();
94 return RadialSum >= CenterDistance;
95 }
96
97 TVector<T, d> FindClosestPoint(const TVector<T, d>& StartPoint, const T Thickness = (T)0) const
98 {
99 TVector<T, d> Result = Center + (StartPoint - Center).GetSafeNormal() * (GetRadiusf() + Thickness);
100 return Result;
101 }
102
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
104 {
105 OutFaceIndex = INDEX_NONE;
106 return Raycasts::RaySphere(StartPoint, Dir, Length, Thickness, Center, GetRadiusf(), OutTime, OutPosition, OutNormal);
107 }
108
109 virtual Pair<TVector<T, d>, bool> FindClosestIntersectionImp(const TVector<T, d>& StartPoint, const TVector<T, d>& EndPoint, const T Thickness) const override
110 {
111 TVector<T, d> Direction = EndPoint - StartPoint;
112 T Length = Direction.Size();
113 Direction = Direction.GetSafeNormal();
114 TVector<T, d> SphereToStart = StartPoint - Center;
116 T EffectiveRadius = GetRadiusf() + Thickness;
118 if (UnderRoot < 0)
119 {
120 return MakePair(TVector<T, d>(0), false);
121 }
122 if (UnderRoot == 0)
123 {
125 {
126 return MakePair(TVector<T, d>(0), false);
127 }
128 return MakePair(TVector<T, d>(-DistanceProjected * Direction + StartPoint), true);
129 }
133 {
135 {
136 return MakePair(TVector<T, d>(0), false);
137 }
138 return MakePair(TVector<T, d>(Root2 * Direction + StartPoint), true);
139 }
141 {
142 return MakePair(TVector<T, d>(Root1 * Direction + StartPoint), true);
143 }
144 if (Root1 < Root2)
145 {
146 return MakePair(TVector<T, d>(Root1 * Direction + StartPoint), true);
147 }
148 return MakePair(TVector<T, d>(Root2 * Direction + StartPoint), true);
149 }
150
151 TVector<T, d> Support(const TVector<T, d>& Direction, const T Thickness, int32& VertexIndex) const
152 {
153 //We want N / ||N|| and to avoid inf
154 //So we want N / ||N|| < 1 / eps => N eps < ||N||, but this is clearly true for all eps < 1 and N > 0
155 T SizeSqr = Direction.SizeSquared();
156 VertexIndex = 0;
158 {
159 return Center;
160 }
161 const TVector<T,d> Normalized = Direction / sqrt(SizeSqr);
162
163 return Center + Normalized * (GetRadiusf() + Thickness);
164 }
165
166 FORCEINLINE const TVector<T, d> SupportCore(const TVector<T, d>& Direction, const FReal InMargin, FReal* OutSupportDelta, int32& VertexIndex) const
167 {
168 VertexIndex = 0;
169 // Note: ignores InMargin, assumed Radius
170 return Center;
171 }
172
174 {
175 return MakeVectorRegisterFloat(Center[0], Center[1], Center[2], 0.0f);
176 }
178 {
179 VertexIndex = 0;
180 // Note: ignores InMargin, assumed Radius
181 return Center * Scale;
182 }
183
184 virtual const TAABB<T, d> BoundingBox() const override
185 {
186 return TAABB<T,d>(Center - FVec3f(GetRadiusf()),Center + FVec3f(GetRadiusf()));
187 }
188
190 {
191 const FVec3 TransformedCenter = Transform.TransformPosition(FVec3(Center));
192 const FVec3 Extents = FVec3(GetRadiusf());
193 return FAABB3(TransformedCenter - Extents, TransformedCenter + Extents);
194 }
195
196 T GetArea() const
197 {
198 return GetArea(GetRadiusf());
199 }
200
201 static T GetArea(const T InRadius)
202 {
203 static const T FourPI = UE_PI * 4;
204 static const T TwoPI = UE_PI * 2;
205 return d == 3 ? FourPI * InRadius * InRadius : TwoPI * InRadius;
206 }
207
208 T GetVolume() const
209 {
210 return GetVolume(GetRadiusf());
211 }
212
213 static T GetVolume(const T InRadius)
214 {
215 check(d == 3);
216 static const T FourThirdsPI = 4. / 3 * UE_PI;
218 }
219
220 UE_DEPRECATED(5.6, "Use GetCenterf instead")
221 const TVector<T, d> GetCenter() const
222 {
223 return Center;
224 }
225
226 const FVec3f& GetCenterf() const
227 {
228 return Center;
229 }
230
232 {
233 return Center;
234 }
235
237 {
238 return Center;
239 }
240
241 virtual FString ToString() const override
242 {
243 return FString::Printf(TEXT("Sphere: Center:%s, Radius:%f"), *Center.ToString(), GetRadiusf());
244 }
245
247 {
249 Ar << Center;
250
251 // Radius is now stored in the base class Margin
253 Ar << ArRadius;
254 SetRadius(ArRadius);
255 }
256
257 virtual void Serialize(FChaosArchive& Ar) override
258 {
260 SerializeImp(Ar);
261 }
262
263 virtual void Serialize(FArchive& Ar) override
264 {
265 SerializeImp(Ar);
266 }
267
272 {
273 TArray<TVector<T, d>> Points;
274
276 {
277 // If we're too small (and will create NaNs) then just take the centre
278 Points.Add(TVector<T, d>(0.0));
279 }
280 else
281 {
282 Points.Reserve(NumPoints);
285 }
286
287 return Points;
288 }
289
290 TArray<TVector<T, d>> ComputeLocalSamplePoints(const T PointsPerUnitArea, const int32 MinPoints = 0, const int32 MaxPoints = 1000) const
291 {
292 return ComputeLocalSamplePoints(FMath::Clamp(static_cast<int32>(ceil(PointsPerUnitArea * GetArea())), MinPoints, MaxPoints));
293 }
294
298 TArray<TVector<T, d>> ComputeSamplePoints(const int NumPoints) const
299 {
300 TArray<TVector<T, d>> Points;
302 return Points;
303 }
304
305 TArray<TVector<T, d>> ComputeSamplePoints(const T PointsPerUnitArea, const int32 MinPoints = 0, const int32 MaxPoints = 1000) const
306 {
307 return ComputeSamplePoints(FMath::Clamp(static_cast<int32>(ceil(PointsPerUnitArea * GetArea())), MinPoints, MaxPoints));
308 }
309
310 PMatrix<T, d, d> GetInertiaTensor(const T InMass, const bool bInThinShell = false) const
311 {
313 }
314
315 static PMatrix<T, d, d> GetInertiaTensor(const T InMass, const T InRadius, const bool bInThinShell = false)
316 {
317 static const T TwoThirds = static_cast<T>(2.0 / 3.0);
318 static const T TwoFifths = static_cast<T>(2.0 / 5.0);
321 }
322
327
328 virtual uint32 GetTypeHash() const override
329 {
333 }
334
336 {
337 return Chaos::FImplicitObjectPtr(new FSphere(Center, GetRadiusf()));
338 }
339
341 {
342 return Chaos::FImplicitObjectPtr(new FSphere(Center * Scale, GetRadiusf() * Scale.Min()));
343 }
344
345#if INTEL_ISPC
346 // See PerParticlePBDCollisionConstraint.cpp
347 // ISPC code has matching structs for interpreting FImplicitObjects.
348 // This is used to verify that the structs stay the same.
349 struct FISPCDataVerifier
350 {
351 static constexpr int32 OffsetOfCenter() { return offsetof(TSphere, Center); }
352 static constexpr int32 SizeOfCenter() { return sizeof(TSphere::Center); }
353 };
354 friend FISPCDataVerifier;
355#endif // #if INTEL_ISPC
356
357 private:
358 void SetRadius(FRealSingle InRadius) { SetMargin(InRadius); }
359
360 FVec3f Center;
361
362 private:
363
364 // TImplicitObject requires ability to default construct when deserializing shapes
365 friend FImplicitObject;
366 TSphere()
367 : FImplicitObject(EImplicitObject::IsConvex | EImplicitObject::HasBoundingBox, ImplicitObjectType::Sphere)
368 {}
369
370 };
371
372 template<typename T>
374 {
375 static FORCEINLINE void ComputeSamplePoints(TArray<TVec2<T>>& Points, const TSphere<T, 2>& Sphere, const int32 NumPoints)
376 {
377 if (NumPoints <= 1 || Sphere.GetRadiusf() < UE_KINDA_SMALL_NUMBER)
378 {
379 const int32 Offset = Points.AddUninitialized(1);
380 Points[Offset] = Sphere.Center();
381 return;
382 }
383 ComputeGoldenSpiralPoints(Points, Sphere, NumPoints);
384 }
385
389 static FORCEINLINE void ComputeGoldenSpiralPoints(TArray<TVec2<T>>& Points, const TSphere<T, 2>& Sphere, const int32 NumPoints)
390 {
391 ComputeGoldenSpiralPoints(Points, Sphere.Center(), Sphere.GetRadius(), NumPoints);
392 }
393
395 TArray<TVec2<T>>& Points,
396 const TVec2<T>& Center,
397 const T Radius,
398 const int32 NumPoints,
399 const int32 SpiralSeed = 0)
400 {
401 const int32 Offset = Points.AddUninitialized(NumPoints);
402
403 // Stand at the center, turn a golden ratio of whole turns, then emit
404 // a point in that direction.
405 //
406 // Golden ratio: (1 + sqrt(5)) / 2
407 // Polar sunflower increment: pi * (1 + sqrt(5))
408
409 // Increment = 10.16640738463053...
410 static const T Increment = static_cast<T>(UE_PI * (1.0 + sqrt(5)));
411 for (int32 i = 0; i < NumPoints; i++)
412 {
413 const T Z = static_cast<T>(0.5 + i);
414 // sqrt((i+0.5) / NumPoints) sampling i = [0, NumPoints) varies: (0, 1).
415 // We then scale to the radius of our Sphere.
416 const T R = FMath::Sqrt(Z / static_cast<T>(NumPoints)) * Radius;
417 // Theta increases linearly from [Increment/2, Increment*NumPoints)
418 const T Theta = Increment * (Z + static_cast<T>(SpiralSeed));
419
420 // Convert polar coordinates to Cartesian, offset by the Sphere's location.
421 const int32 Index = i + Offset;
422 Points[Index] = Center +TVec2<T>(R * FMath::Cos(Theta), R * FMath::Sin(Theta));
423
424 // Check to make sure the point is inside the sphere
425 checkSlow((Points[Index] - Center).Size() - Radius < UE_KINDA_SMALL_NUMBER);
426 }
427 }
428 };
429
430 template<typename T>
432 {
433 static FORCEINLINE void ComputeSamplePoints(TArray<TVec3<T>>& Points, const TSphere<T, 3>& Sphere, const int32 NumPoints)
434 {
435 if (NumPoints <= 1 || Sphere.GetRadiusf() < UE_KINDA_SMALL_NUMBER)
436 {
437 const int32 Offset = Points.AddUninitialized(1);
438 Points[Offset] = Sphere.GetCenterf();
439 return;
440 }
441 ComputeGoldenSpiralPoints(Points, Sphere, NumPoints);
442 }
443
448 TArray<TVec3<T>>& Points, const TSphere<T, 3>& Sphere, const int32 NumPoints,
449 const bool FirstHalf = true, const bool SecondHalf = true, const int32 SpiralSeed = 0)
450 {
451 ComputeGoldenSpiralPoints(Points, Sphere.GetCenterf(), Sphere.GetRadiusf(), NumPoints, FirstHalf, SecondHalf, SpiralSeed);
452 }
453
477 TArray<TVec3<T>>& Points,
478 const TVec3<T>& Center,
479 const T Radius,
480 const int32 NumPoints,
481 const bool BottomHalf = true,
482 const bool TopHalf = true,
483 const int32 SpiralSeed = 0)
484 {
485 if (!TopHalf && !BottomHalf)
486 {
487 return;
488 }
489
490 const int32 Offset = Points.AddUninitialized(NumPoints);
491
492 // We use the same method in 3D as 2D, but in spherical coordinates rather than polar.
493 //
494 // Theta is the angle about the Z axis, relative to the positive X axis.
495 // Phi is the angle between the positive Z axis and the line from the origin to the point
496
497 // GRIncrement = 10.16640738463053...
498 static const T GRIncrement = static_cast<FReal>(UE_PI * (1.0 + sqrt(5)));
499
500 // If PhiSteps is 2X NumPoints, then we'll only generate half the sphere.
501 //const int32 PhiSteps = TopHalf + BottomHalf == 1 ? NumPoints * 2 : NumPoints;
502 // If PhiSeed is 0, then we'll generate the sphere from the beginning - the bottom.
503 // Otherwise, we'll generate the sphere from the middle.
504 //const int32 PhiSeed = !TopHalf && BottomHalf ? NumPoints : 0;
505
507 if (BottomHalf && !TopHalf)
508 {
509 for (int32 i = 0; i < NumPoints; i++)
510 {
511 const T Sample = static_cast<T>(0.5 + i);
512 // ((i + 0.5) / (NumPoints * 2)) varies: (0.0, 0.5)
513 // So, (2 * (i + 0.5) / (NumPoints * 2)) varies: (0.0, 1.0)
514 // So, ((2 * (i + 0.5) / (NumPoints * 2)) - 1) varies: (-1, 0.0)
515 const T V = static_cast<T>((2.0 * (0.5 + i) / (2.0 * NumPoints)) - 1.0);
516 const T Phi = FMath::Acos(V);
518 const T Theta = GRIncrement * (Sample + static_cast<T>(SpiralSeed));
519
520 // Convert spherical coordinates to Cartesian, scaled by the radius of our Sphere, and offset by its location.
521 const T SinPhi = FMath::Sin(Phi);
522 TVec3<T>& Pt = Points[Index++];
523 Pt = Center +
524 TVec3<T>(
525 Radius * FMath::Cos(Theta) * SinPhi,
526 Radius * FMath::Sin(Theta) * SinPhi,
527 Radius * FMath::Cos(Phi));
528
529 checkSlow(FMath::Abs(TSphere<T, 3>(Center, Radius).SignedDistance(Pt)) < UE_KINDA_SMALL_NUMBER);
531 }
532 }
533 else if (!BottomHalf && TopHalf)
534 {
535 for (int32 i = 0; i < NumPoints; i++)
536 {
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))); // varies: (0.0, 1.0)
539 const T Phi = FMath::Acos(V);
541 const T Theta = GRIncrement * (Sample + static_cast<T>(SpiralSeed));
542
543 // Convert spherical coordinates to Cartesian, scaled by the radius of our Sphere, and offset by its location.
544 const T SinPhi = FMath::Sin(Phi);
545 TVec3<T>& Pt = Points[Index++];
546 Pt = Center +
547 TVec3<T>(
548 Radius * FMath::Cos(Theta) * SinPhi,
549 Radius * FMath::Sin(Theta) * SinPhi,
550 Radius * FMath::Cos(Phi));
551
552 checkSlow(FMath::Abs(TSphere<T, 3>(Center, Radius).SignedDistance(Pt)) < UE_KINDA_SMALL_NUMBER);
554 }
555 }
556 else
557 {
558 for (int32 i = 0; i < NumPoints; i++)
559 {
560 const T Sample = static_cast<T>(0.5 + i);
561 // arccos(x), where x = [-1, 1] varies: [PI, 0]
562 // ((i + 0.5) / NumPoints) varies: (0.0, 1.0)
563 // So, (2 * (i + 0.5) / NumPoints) varies: (0.0, 2.0)
564 // So, (1 - (2 * (i + 0.5) / NumPoints) varies: (-1.0, 1.0)
565 // So, Phi varies: (PI, 0) as i varies: [0, NumPoints-1].
566 const T Phi = static_cast<T>(FMath::Acos(1.0 - 2.0 * Sample / NumPoints));
567 // Theta varies: [5.0832036..., NumPoints*Increment)
568 const T Theta = GRIncrement * (Sample + static_cast<T>(SpiralSeed));
569
570 // Convert spherical coordinates to Cartesian, scaled by the radius of our Sphere, and offset by its location.
571 const T SinPhi = FMath::Sin(Phi);
572 TVec3<T>& Pt = Points[Index++];
573 Pt = Center +
574 TVec3<T>(
575 Radius * FMath::Cos(Theta) * SinPhi,
576 Radius * FMath::Sin(Theta) * SinPhi,
577 Radius * FMath::Cos(Phi));
578
579 checkSlow(FMath::Abs(TSphere<T, 3>(Center, Radius).SignedDistance(Pt)) < UE_KINDA_SMALL_NUMBER);
580 }
581 }
582 }
583
585 TArray<TVec3<T>>& Points, const TSphere<T, 3>& Sphere, const int32 NumPoints, const int32 SpiralSeed = 0)
586 {
587 ComputeGoldenSpiralPoints(Points, Sphere, NumPoints, true, false, SpiralSeed);
588 }
589
591 TArray<TVec3<T>>& Points, const TSphere<T, 3>& Sphere, const int32 NumPoints, const int32 SpiralSeed = 0)
592 {
593 ComputeGoldenSpiralPoints(Points, Sphere, NumPoints, false, true, SpiralSeed);
594 }
595 };
596
597} // namespace Chaos
#define FORCEINLINE
Definition AndroidPlatform.h:140
#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
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
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
uint32_t uint32
Definition binka_ue_file_header.h:6
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
Definition Matrix.h:21
Definition AABB.h:37
Definition Rotation.h:41
Definition Sphere.h:28
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
Definition Vector.h:407
FRealSingle Min() const
Definition Vector.h:523
Definition Vector.h:1000
Definition Vector.h:41
Definition Archive.h:1208
Definition Array.h:670
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
Definition Pair.h:8
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