Skip to content

Commit

Permalink
Multitest selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
RossNordby committed Jan 21, 2025
1 parent d87ad8c commit c40801d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Demos/SpecializedTests/ConvexHullTestDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,9 @@ public override void Initialize(ContentArchive content, Camera camera)
y - 8), new Vector3(1, 1, 1), BufferPool);
Simulation.Statics.Add(new StaticDescription(new Vector3(64, 0, 0), Simulation.Shapes.Add(mesh)));

#if DEBUG_STEPS
stepIndices = new int[hullTests.Length];
#endif
}

void TestConvexHullCreation()
Expand All @@ -723,6 +725,7 @@ void TestConvexHullCreation()
}
}

#if DEBUG_STEPS
int testIndex;
int[] stepIndices;

Expand All @@ -737,6 +740,14 @@ public override void Update(Window window, Camera camera, Input input, float dt)
{
stepIndex = Math.Min(stepIndex + 1, hullTests[testIndex].DebugSteps.Count - 1);
}
if (input.TypedCharacters.Contains('n'))
{
testIndex = Math.Max(testIndex - 1, 0);
}
if (input.TypedCharacters.Contains('m'))
{
testIndex = Math.Min(testIndex + 1, hullTests.Length - 1);
}
if (input.WasPushed(OpenTK.Input.Key.P))
{
showWireframe = !showWireframe;
Expand Down Expand Up @@ -901,7 +912,11 @@ void DrawFace(DebugStep step, int[] reduced, Vector3 color, float offsetScale)
renderer.Lines.Allocate() = new LineInstance(edgeMidpoint, edgeMidpoint + step.BasisX * scale * 0.5f, new Vector3(1, 1, 0), new Vector3());
renderer.Lines.Allocate() = new LineInstance(edgeMidpoint, edgeMidpoint + step.BasisY * scale * 0.5f, new Vector3(0, 1, 0), new Vector3());
renderer.TextBatcher.Write(
text.Clear().Append($"Enumerate step with X and C. Current step: ").Append(stepIndex + 1).Append(" out of ").Append(debugSteps.Count),
text.Clear().Append("Step: ").Append(stepIndex + 1).Append(" out of ").Append(debugSteps.Count).Append(" for test ").Append(testIndex).Append("."),
new Vector2(32, renderer.Surface.Resolution.Y - 170), 20, new Vector3(1), font);

renderer.TextBatcher.Write(
text.Clear().Append($"Enumerate step with X and C, change test with N and M."),
new Vector2(32, renderer.Surface.Resolution.Y - 140), 20, new Vector3(1), font);
renderer.TextBatcher.Write(text.Clear().Append("Show wireframe: P ").Append(showWireframe ? "(on)" : "(off)"), new Vector2(32, renderer.Surface.Resolution.Y - 120), 20, new Vector3(1), font);
renderer.TextBatcher.Write(text.Clear().Append("Show deleted: U ").Append(showDeleted ? "(on)" : "(off)"), new Vector2(32, renderer.Surface.Resolution.Y - 100), 20, new Vector3(1), font);
Expand All @@ -912,4 +927,5 @@ void DrawFace(DebugStep step, int[] reduced, Vector3 color, float offsetScale)

base.Render(renderer, camera, input, text, font);
}
#endif
}

0 comments on commit c40801d

Please sign in to comment.