Add option to drive adding more negative space samples when the current samples don't cover the space identified by Voxel Search (and are farther apart than the target Sample Spacing), to make the negative space coverage algorithm better able to protect space in challenging cases where a smaller fixed number of samples would fail.

#rb rinat.abdrashitov

[CL 26314665 by jimmy andrews in ue5-main branch]
This commit is contained in:
jimmy andrews
2023-06-29 11:28:58 -04:00
parent b1344e9984
commit 874bb70ad5
4 changed files with 45 additions and 0 deletions
@@ -265,6 +265,31 @@ bool FSphereCovering::AddNegativeSpace(const TFastWindingTree<FDynamicMesh3>& Sp
int32 VID = Ordering.Order[SampleIdx];
AddSample(MorphologyMesh.GetVertex(VID));
}
if (SampleSettings.bRequireSearchSampleCoverage)
{
double SpacingThresholdSq = SampleSettings.MinSpacing * SampleSettings.MinSpacing;
for (int32 SampleIdx = NumSamples; SampleIdx < Ordering.Order.Num(); ++SampleIdx)
{
int32 VID = Ordering.Order[SampleIdx];
FVector3d Pos = MorphologyMesh.GetVertex(VID);
// TODO: Consider accelerating this coverage search w/ e.g. a sparse dynamic octree representation of the sphere covering
bool bFoundCover = false;
for (int32 SphereIdx = 0; SphereIdx < Position.Num(); ++SphereIdx)
{
double ThreshSq = FMath::Max(SpacingThresholdSq, Radius[SphereIdx] * Radius[SphereIdx]);
if (FVector3d::DistSquared(Position[SphereIdx], Pos) < ThreshSq)
{
bFoundCover = true;
break;
}
}
if (!bFoundCover)
{
AddSample(Pos);
}
}
}
}
else
{