You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
This represents UE4/Main @ 15913390 and Dev-PerfTest @ 15913304 [CL 15958515 by Marc Audy in ue5-main branch]
45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "ClothCollisionPrim.h"
|
|
|
|
void FClothCollisionPrim_Convex::RebuildSurfacePoints()
|
|
{
|
|
const int32 NumPlanes = Faces.Num();
|
|
if (NumPlanes >= 3)
|
|
{
|
|
SurfacePoints.Reset(NumPlanes * (NumPlanes - 1) * (NumPlanes - 2) / 6); // Maximum number of intersections
|
|
|
|
auto PointInHull = [this](const FVector& Point) -> bool
|
|
{
|
|
for (const FClothCollisionPrim_ConvexFace& Face : Faces)
|
|
{
|
|
if (Face.Plane.PlaneDot(Point) > KINDA_SMALL_NUMBER)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
|
|
for (int32 Index0 = 0; Index0 < NumPlanes; ++Index0)
|
|
{
|
|
for (int32 Index1 = Index0 + 1; Index1 < NumPlanes; ++Index1)
|
|
{
|
|
for (int32 Index2 = Index1 + 1; Index2 < NumPlanes; ++Index2)
|
|
{
|
|
FVector Intersection;
|
|
if (FMath::IntersectPlanes3(Intersection, Faces[Index0].Plane, Faces[Index1].Plane, Faces[Index2].Plane) &&
|
|
PointInHull(Intersection))
|
|
{
|
|
SurfacePoints.Add(Intersection);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SurfacePoints.Reset();
|
|
}
|
|
}
|