Files
UnrealEngineUWP/Engine/Source/Runtime/ClothingSystemRuntimeInterface/Private/ClothCollisionPrim.cpp
kriss gossart 89ffedd265 Reworked the Chaos Cloth Convex collisions to use a Chaos TConvex implicit.
Also:
-Regenerate the convexes' surface points for the legacy apex cloth assets (apparently the only use of convexes in apex import was to emulate box collisions).
-Add debug draw visualization for the Chaos Cloth editor.

#rb Jaco.VanDyk
[FYI] Benn.Gallagher


#ROBOMERGE-SOURCE: CL 9894041 via CL 9894049
#ROBOMERGE-BOT: (v558-9892490)

[CL 9894053 by kriss gossart in Main branch]
2019-10-30 14:12:32 -04:00

45 lines
1011 B
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "ClothCollisionPrim.h"
void FClothCollisionPrim_Convex::RebuildSurfacePoints()
{
const int32 NumPlanes = Planes.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 FPlane& Plane : Planes)
{
if (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, Planes[Index0], Planes[Index1], Planes[Index2]) &&
PointInHull(Intersection))
{
SurfacePoints.Add(Intersection);
}
}
}
}
}
else
{
SurfacePoints.Reset();
}
}