29 template <
class TriangleMeshType,
class IterableTriangleIndices>
45 for (
int tid : Triangles)
58 for (
int tid : Triangles)
60 Mesh.GetTriVertices(
tid, P0, P1, P2);
83 template <
class TriangleMeshType>
123 Out.Area =
A.Area +
B.Area;
144 Mesh.GetTriVertices(
tid, P0, P1, P2);
166 Out.Order1 =
A.Order1 +
B.Order1;
167 Out.Order2 =
A.Order2 +
B.Order2;
168 Out.RSq = FMath::Max(
A.RSq,
B.RSq);
173 OrderData{ FVector3d::Zero(), FMatrix3d::Zero(), 0.0 },
194 template <
class TriangleMeshType>
195 UE_DEPRECATED(5.7,
"Use the above version of ComputeCoeffs, which takes a TArray of triangle indices instead")
197 const TSet<
int>& TriangleSet,
227 return (1.0 / FMathd::FourPi) *
Order1Coeff.Dot(
dpq / (len * len * len));
237 double len3 = len * len * len;
243 double c = -3.0 / (FMathd::FourPi *
len3 * len * len);
267 double len3 = len * len * len;
269 return (1.0 / FMathd::FourPi) *
at0.Dot(
dpq / (len * len * len));
280 double len3 = len * len * len;
287 xqxq *= 3.0 / (FMathd::FourPi *
len3 * len * len);
288 double diag = 1 / (FMathd::FourPi *
len3);
293 (T.
V[0].
X + T.
V[1].
X + T.
V[2].
X) / 3.0, (T.
V[0].
Y + T.
V[1].
Y + T.
V[2].
Y) / 3.0, (T.
V[0].
Z + T.
V[1].
Z + T.
V[2].
Z) / 3.0);
314template <
class TriangleMeshType>
329 int32 FastWindingCacheOffset = 0;
330 uint64 FastWindingCacheMeshChangeStamp = 0;
362 void Build(
bool bForceRebuild =
true)
365 if ( Tree->IsValid(
false) ==
false )
369 if (bForceRebuild || FastWindingCacheMeshChangeStamp != Tree->MeshChangeStamp)
371 build_fast_winding_cache();
372 FastWindingCacheMeshChangeStamp = Tree->MeshChangeStamp;
378 return Tree->IsValid(
false) && FastWindingCacheMeshChangeStamp == Tree->MeshChangeStamp;
390 double sum = branch_fast_winding_num(Tree->RootIndex, P);
400 double sum = branch_fast_winding_num(Tree->RootIndex, P);
418 int idx = Tree->BoxToIndex[
IBox];
421 int num_tris = Tree->IndexList[idx];
425 int ti = Tree->IndexList[idx + i];
426 Tree->Mesh->GetTriVertices(ti, a, b, c);
434 int iChild1 = Tree->IndexList[idx];
481 void build_fast_winding_cache()
491 for (FastWindingCacheOffset = 0; FastWindingCacheOffset <
Tree->BoxToIndex.Num(); ++FastWindingCacheOffset)
493 if (
Tree->BoxToIndex[FastWindingCacheOffset] >=
Tree->TrianglesEnd)
498 int32 CacheSize =
Tree->BoxToIndex.Num() - FastWindingCacheOffset;
499 FastWindingCache.
Empty(CacheSize);
500 FastWindingCache.
Init({ .bValid =
false }, CacheSize);
579 bool can_use_fast_winding_cache(
int IBox,
const FVector3d& Q)
const
587 const FWNInfo& CacheInfo = FastWindingCache[
CacheIdx];
588 if (!CacheInfo.bValid)
601 check(!FastWindingCache[
IBox - FastWindingCacheOffset].bValid);
612 double evaluate_box_fast_winding_cache(
int IBox,
const FVector3d& Q)
const
614 const FWNInfo&
cacheInfo = FastWindingCache[
IBox - FastWindingCacheOffset];
635 Triangles.
Add(
Tree->IndexList[idx + i]);
643 collect_triangles((-
iChild1) - 1, Triangles);
647 collect_triangles(
iChild1 - 1, Triangles);
648 collect_triangles(
Tree->IndexList[idx + 1] - 1, Triangles);
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
#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
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
void Init(const ElementType &Element, SizeType Number)
Definition Array.h:3043
void Empty(SizeType Slack=0)
Definition Array.h:2273
Definition FastWinding.h:316
bool IsInside(const FVector3d &P, double WindingIsoThreshold=0.5) const
Definition FastWinding.h:407
TFastWindingTree(TMeshAABBTree3< TriangleMeshType > *TreeToRef, bool bAutoBuild=true)
Definition FastWinding.h:343
double FastWindingNumber(const FVector3d &P)
Definition FastWinding.h:387
void SetTree(TMeshAABBTree3< TriangleMeshType > *TreeToRef, bool bAutoBuild=true)
Definition FastWinding.h:348
TMeshAABBTree3< TriangleMeshType > * GetTree() const
Definition FastWinding.h:357
double FWNBeta
Definition FastWinding.h:336
double FastWindingNumber(const FVector3d &P) const
Definition FastWinding.h:397
int FWNApproxOrder
Definition FastWinding.h:341
bool IsBuilt() const
Definition FastWinding.h:376
void Build(bool bForceRebuild=true)
Definition FastWinding.h:362
Definition MeshAABBTree3.h:61
@ Tree
Definition ITypedTableView.h:40
Definition FastWinding.h:16
double Order1Approx(const FTriangle3d &T, const FVector3d &P, const FVector3d &XN, double XA, const FVector3d &Q)
Definition FastWinding.h:261
void ComputeCoeffs(const TriangleMeshType &Mesh, const TArray< int > &TriangleArray, const FMeshTriInfoCache &TriCache, FVector3d &P, double &R, FVector3d &Order1, FMatrix3d &Order2, int NumTasks=16)
Definition FastWinding.h:84
void ComputeCoeffsSerial(const TriangleMeshType &Mesh, const IterableTriangleIndices &Triangles, const FMeshTriInfoCache &TriCache, FVector3d &P, double &R, FVector3d &Order1, FMatrix3d &Order2)
Definition FastWinding.h:30
double Order2Approx(const FTriangle3d &T, const FVector3d &P, const FVector3d &XN, double XA, const FVector3d &Q)
Definition FastWinding.h:275
double EvaluateOrder1Approx(const FVector3d &Center, const FVector3d &Order1Coeff, const FVector3d &Q)
Definition FastWinding.h:222
double EvaluateOrder2Approx(const FVector3d &Center, const FVector3d &Order1Coeff, const FMatrix3d &Order2Coeff, const FVector3d &Q)
Definition FastWinding.h:233
RealType TriSolidAngle(TVector< RealType > A, TVector< RealType > B, TVector< RealType > C, const TVector< RealType > &P)
Definition VectorUtil.h:468
Definition ParametricSurfaceData.h:18
TMatrix3< double > FMatrix3d
Definition MatrixTypes.h:510
T DistanceSquared(const UE::Math::TVector2< T > &V1, const UE::Math::TVector2< T > &V2)
Definition VectorTypes.h:82
@ Area
Definition FitOrientedBox2.h:17
T ParallelTransformReduce(IntType Num, const T &Init, TransformFuncT Transform, ReduceFuncT Reduce, int64 InNumTasks)
Definition ParallelTransformReduce.h:17
TTriangle3< double > FTriangle3d
Definition TriangleTypes.h:325
Definition AdvancedWidgetsModule.cpp:13
static constexpr UE_FORCEINLINE_HINT T Max3(const T A, const T B, const T C)
Definition UnrealMathUtility.h:551
Definition Optional.h:131
Definition MeshCaches.h:19
static FMeshTriInfoCache BuildTriInfoCache(const TriangleMeshType &Mesh)
Definition MeshCaches.h:32
static TMatrix3< double > Zero()
Definition MatrixTypes.h:82
Definition TriangleTypes.h:263
TVector< RealType > V[3]
Definition TriangleTypes.h:264
T Z
Definition Vector.h:68
static TVector< double > Zero()
Definition Vector.h:112
T Y
Definition Vector.h:65
T Length() const
Definition Vector.h:1722
T X
Definition Vector.h:62