Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of unnecessary DebugStep debug object #3

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 69 additions & 69 deletions BepuPhysics/Collidables/ConvexHullHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -592,70 +592,70 @@ static void AddIfNotPresent(ref QuickList<int> list, int value, BufferPool pool)
list.Allocate(pool) = value;
}

public struct DebugStep
{
public EdgeEndpoints SourceEdge;
public List<int> Raw;
public List<int> Reduced;
public bool[] AllowVertex;
public Vector3 FaceNormal;
public Vector3 BasisX;
public Vector3 BasisY;
public List<int> FaceStarts;
public List<int> FaceIndices;
public bool[] FaceDeleted;
public int[] MergedFaceIndices;
public int FaceIndex;
public Vector3[] FaceNormals;

internal DebugStep(EdgeEndpoints sourceEdge, ref QuickList<int> raw, Vector3 faceNormal, Vector3 basisX, Vector3 basisY, ref QuickList<int> reduced, ref Buffer<int> allowVertex, ref QuickList<EarlyFace> faces, Span<int> mergedFaceIndices, int faceIndex)
{
SourceEdge = sourceEdge;
FaceNormal = faceNormal;
BasisX = basisX;
BasisY = basisY;
Raw = new List<int>();
for (int i = 0; i < raw.Count; ++i)
{
Raw.Add(raw[i]);
}
Reduced = new List<int>();
for (int i = 0; i < reduced.Count; ++i)
{
Reduced.Add(reduced[i]);
}
AllowVertex = new bool[allowVertex.Length];
for (int i = 0; i < allowVertex.Length; ++i)
{
AllowVertex[i] = allowVertex[i] != 0;
}
FaceStarts = new List<int>(faces.Count);
FaceIndices = new List<int>();
FaceDeleted = new bool[faces.Count];
FaceNormals = new Vector3[faces.Count];
for (int i = 0; i < faces.Count; ++i)
{
ref var face = ref faces[i];
FaceStarts.Add(FaceIndices.Count);
for (int j = 0; j < face.VertexIndices.Count; ++j)
FaceIndices.Add(face.VertexIndices[j]);
FaceDeleted[i] = face.Deleted;
FaceNormals[i] = face.Normal;
}
MergedFaceIndices = mergedFaceIndices.ToArray();
FaceIndex = faceIndex;
}
}
/// <summary>
/// Computes the convex hull of a set of points.
/// </summary>
/// <param name="points">Point set to compute the convex hull of.</param>
/// <param name="pool">Buffer pool to pull memory from when creating the hull.</param>
/// <param name="hullData">Convex hull of the input point set.</param>
public static void ComputeHull(Span<Vector3> points, BufferPool pool, out HullData hullData)
{
ComputeHull(points, pool, out hullData, out _);
}
//public struct DebugStep
//{
// public EdgeEndpoints SourceEdge;
// public List<int> Raw;
// public List<int> Reduced;
// public bool[] AllowVertex;
// public Vector3 FaceNormal;
// public Vector3 BasisX;
// public Vector3 BasisY;
// public List<int> FaceStarts;
// public List<int> FaceIndices;
// public bool[] FaceDeleted;
// public int[] MergedFaceIndices;
// public int FaceIndex;
// public Vector3[] FaceNormals;

// internal DebugStep(EdgeEndpoints sourceEdge, ref QuickList<int> raw, Vector3 faceNormal, Vector3 basisX, Vector3 basisY, ref QuickList<int> reduced, ref Buffer<int> allowVertex, ref QuickList<EarlyFace> faces, Span<int> mergedFaceIndices, int faceIndex)
// {
// SourceEdge = sourceEdge;
// FaceNormal = faceNormal;
// BasisX = basisX;
// BasisY = basisY;
// Raw = new List<int>();
// for (int i = 0; i < raw.Count; ++i)
// {
// Raw.Add(raw[i]);
// }
// Reduced = new List<int>();
// for (int i = 0; i < reduced.Count; ++i)
// {
// Reduced.Add(reduced[i]);
// }
// AllowVertex = new bool[allowVertex.Length];
// for (int i = 0; i < allowVertex.Length; ++i)
// {
// AllowVertex[i] = allowVertex[i] != 0;
// }
// FaceStarts = new List<int>(faces.Count);
// FaceIndices = new List<int>();
// FaceDeleted = new bool[faces.Count];
// FaceNormals = new Vector3[faces.Count];
// for (int i = 0; i < faces.Count; ++i)
// {
// ref var face = ref faces[i];
// FaceStarts.Add(FaceIndices.Count);
// for (int j = 0; j < face.VertexIndices.Count; ++j)
// FaceIndices.Add(face.VertexIndices[j]);
// FaceDeleted[i] = face.Deleted;
// FaceNormals[i] = face.Normal;
// }
// MergedFaceIndices = mergedFaceIndices.ToArray();
// FaceIndex = faceIndex;
// }
//}
///// <summary>
///// Computes the convex hull of a set of points.
///// </summary>
///// <param name="points">Point set to compute the convex hull of.</param>
///// <param name="pool">Buffer pool to pull memory from when creating the hull.</param>
///// <param name="hullData">Convex hull of the input point set.</param>
//public static void ComputeHull(Span<Vector3> points, BufferPool pool, out HullData hullData)
//{
// ComputeHull(points, pool, out hullData, out _);
//}


/// <summary>
Expand All @@ -664,9 +664,9 @@ public static void ComputeHull(Span<Vector3> points, BufferPool pool, out HullDa
/// <param name="points">Point set to compute the convex hull of.</param>
/// <param name="pool">Buffer pool to pull memory from when creating the hull.</param>
/// <param name="hullData">Convex hull of the input point set.</param>
public static void ComputeHull(Span<Vector3> points, BufferPool pool, out HullData hullData, out List<DebugStep> steps)
public static void ComputeHull(Span<Vector3> points, BufferPool pool, out HullData hullData)//, out List<DebugStep> steps)
{
steps = new List<DebugStep>();
//steps = new List<DebugStep>();
if (points.Length <= 0)
{
hullData = default;
Expand Down Expand Up @@ -825,7 +825,7 @@ public static void ComputeHull(Span<Vector3> points, BufferPool pool, out HullDa
}
Vector3Wide.ReadFirst(initialBasisX, out var debugInitialBasisX);
Vector3Wide.ReadFirst(initialBasisY, out var debugInitialBasisY);
steps.Add(new DebugStep(initialSourceEdge, ref rawFaceVertexIndices, initialFaceNormal, debugInitialBasisX, debugInitialBasisY, ref reducedFaceIndices, ref allowVertices, ref faces, default, reducedFaceIndices.Count >= 3 ? 0 : -1));
//steps.Add(new DebugStep(initialSourceEdge, ref rawFaceVertexIndices, initialFaceNormal, debugInitialBasisX, debugInitialBasisY, ref reducedFaceIndices, ref allowVertices, ref faces, default, reducedFaceIndices.Count >= 3 ? 0 : -1));

int facesDeletedCount = 0;

Expand Down Expand Up @@ -858,7 +858,7 @@ public static void ComputeHull(Span<Vector3> points, BufferPool pool, out HullDa

if (reducedFaceIndices.Count < 3)
{
steps.Add(new DebugStep(edgeToTest.Endpoints, ref rawFaceVertexIndices, faceNormal, basisX, basisY, ref reducedFaceIndices, ref allowVertices, ref faces, default, -1));
//steps.Add(new DebugStep(edgeToTest.Endpoints, ref rawFaceVertexIndices, faceNormal, basisX, basisY, ref reducedFaceIndices, ref allowVertices, ref faces, default, -1));
//Degenerate face found; don't bother creating work for it.
continue;
}
Expand Down Expand Up @@ -984,7 +984,7 @@ public static void ComputeHull(Span<Vector3> points, BufferPool pool, out HullDa

AddFace(ref faces, pool, faceNormal, reducedFaceIndices);
AddFaceToEdgesAndTestList(pool, ref reducedFaceIndices, ref edgesToTest, ref facesForEdges, faceNormal, faceCountPriorToAdd);
steps.Add(new DebugStep(edgeToTest.Endpoints, ref rawFaceVertexIndices, faceNormal, basisX, basisY, ref reducedFaceIndices, ref allowVertices, ref faces, facesNeedingMerge, faceCountPriorToAdd));
//steps.Add(new DebugStep(edgeToTest.Endpoints, ref rawFaceVertexIndices, faceNormal, basisX, basisY, ref reducedFaceIndices, ref allowVertices, ref faces, facesNeedingMerge, faceCountPriorToAdd));
break;
}
}
Expand Down
Loading