Skip to content

Commit

Permalink
Add "Open" button in TessBed for easy external tests
Browse files Browse the repository at this point in the history
  • Loading branch information
speps committed Feb 4, 2016
1 parent 7572f7b commit 75d891a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
15 changes: 14 additions & 1 deletion TessBed/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 24 additions & 14 deletions TessBed/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,34 @@ public MainForm()
{
_canvas.ShowInput = toolStripButtonShowInput.Checked;
toolStripButtonShowWinding.Enabled = _canvas.ShowInput;
if (toolStripAssets.SelectedIndex >= 0)
{
RefreshAsset(toolStripAssets.SelectedIndex);
}
RefreshAsset(toolStripAssets.SelectedIndex);
};

toolStripButtonShowWinding.CheckedChanged += delegate(object sender, EventArgs e)
{
_canvas.ShowWinding = toolStripButtonShowWinding.Checked;
if (toolStripAssets.SelectedIndex >= 0)
{
RefreshAsset(toolStripAssets.SelectedIndex);
}
RefreshAsset(toolStripAssets.SelectedIndex);
};

toolStripButtonBench.Click += delegate(object sender, EventArgs e)
{
new BenchForm().ShowDialog(this);
};

toolStripButtonOpen.Click += delegate(object sender, EventArgs e)
{
var dialog = new OpenFileDialog();
dialog.Filter = "Test Files (*.dat)|*.dat|All Files (*.*)|*.*";
dialog.FilterIndex = 1;
dialog.RestoreDirectory = true;
if (dialog.ShowDialog() == DialogResult.OK)
{
var polygons = DataLoader.LoadDat(dialog.OpenFile());
RefreshAsset(polygons);
toolStripAssets.SelectedIndex = -1;
}
};

SetAsset("redbook-winding");
SetShowInput(true);
SetShowWinding(false);
Expand Down Expand Up @@ -151,7 +159,11 @@ private void SetPolySize(int polySize)

private void RefreshAsset(int index)
{
RefreshAsset(_assets[index]);
if (index >= 0)
{
var asset = _data.GetAsset(_assets[index]);
RefreshAsset(asset.Polygons);
}
}

private Vec3 Project(Vec3 v)
Expand Down Expand Up @@ -188,13 +200,11 @@ private object VertexCombine(Vec3 position, object[] data, float[] weights)
return Color.FromArgb((int)rgba[3], (int)rgba[0], (int)rgba[1], (int)rgba[2]);
}

private void RefreshAsset(string name)
private void RefreshAsset(PolygonSet polygons)
{
var asset = _data.GetAsset(name);

_sw.Reset();

foreach (var poly in asset.Polygons)
foreach (var poly in polygons)
{
var v = new ContourVertex[poly.Count];
for (int i = 0; i < poly.Count; i++)
Expand Down Expand Up @@ -232,7 +242,7 @@ private void RefreshAsset(string name)
}

var input = new PolygonSet();
foreach (var poly in asset.Polygons)
foreach (var poly in polygons)
{
var projPoly = new Polygon();
for (int i = 0; i < poly.Count; i++)
Expand Down

0 comments on commit 75d891a

Please sign in to comment.