remove bulk rendering

This commit is contained in:
2018-04-05 17:02:37 -04:00
parent bd44b4898c
commit d5feb8facd

View File

@@ -23,8 +23,8 @@ namespace Tetrahedrons
private MVec4D _a = MVec4D.UnitX; private MVec4D _a = MVec4D.UnitX;
private MVec4D _b = MVec4D.UnitY; private MVec4D _b = MVec4D.UnitY;
private Simplex[] _simplexes; private Simplex _sim;
private Simplex[] _intersections; private Simplex _int;
private double _t; private double _t;
private bool _pause; private bool _pause;
@@ -39,27 +39,13 @@ namespace Tetrahedrons
_view = Matrix4.LookAt(Vector3.Zero, -new Vector3(.86f, .5f, 1), Vector3.UnitZ); _view = Matrix4.LookAt(Vector3.Zero, -new Vector3(.86f, .5f, 1), Vector3.UnitZ);
const int n = 5; _sim = new Simplex( // not-quite-regular pentatope
_simplexes = new Simplex[n * n * n * n]; new Vector4d(+.5, -.5, -.5, -.5),
_intersections = new Simplex[_simplexes.Length]; new Vector4d(-.5, +.5, -.5, -.5),
new Vector4d(-.5, -.5, +.5, -.5),
var off = (new Vector4d(n - 1, n - 1, n - 1, n - 1)) / 2; new Vector4d(-.5, -.5, -.5, +.5),
int i = 0; new Vector4d(+.5, +.5, +.5, +.5));
for (var x = 0; x < n; x++) _int = new Simplex();
for (var y = 0; y < n; y++)
for (var z = 0; z < n; z++)
for (var w = 0; w < n; w++)
{
var d = new Vector4d(x, y, z, w);
_simplexes[i] = new Simplex( // not-quite-regular pentatope
new Vector4d(+.5, -.5, -.5, -.5) + d - off,
new Vector4d(-.5, +.5, -.5, -.5) + d - off,
new Vector4d(-.5, -.5, +.5, -.5) + d - off,
new Vector4d(-.5, -.5, -.5, +.5) + d - off,
new Vector4d(+.5, +.5, +.5, +.5) + d - off);
_intersections[i] = new Simplex();
i++;
}
} }
protected override void OnRenderFrame(FrameEventArgs e) protected override void OnRenderFrame(FrameEventArgs e)
@@ -83,17 +69,15 @@ namespace Tetrahedrons
GL.Begin(PrimitiveType.Lines); GL.Begin(PrimitiveType.Lines);
GL.Color3(0f, 0, 0); GL.Color3(0f, 0, 0);
foreach (var intr in _intersections) foreach (var f in _int.Edjes)
foreach (var f in intr.Edjes) Util.Vertex3(_int.Verts[f]);
Util.Vertex3(intr.Verts[f]);
GL.End(); GL.End();
GL.Begin(PrimitiveType.Triangles); GL.Begin(PrimitiveType.Triangles);
foreach (var intr in _intersections) foreach (var f in _int.Faces)
foreach (var f in intr.Faces)
{ {
Util.Color3(intr.Verts[f]); Util.Color3(_int.Verts[f]);
Util.Vertex3(intr.Verts[f]); Util.Vertex3(_int.Verts[f]);
} }
GL.End(); GL.End();
@@ -102,9 +86,8 @@ namespace Tetrahedrons
if (_wire) if (_wire)
{ {
GL.Begin(PrimitiveType.Lines); GL.Begin(PrimitiveType.Lines);
foreach (var sim in _simplexes) foreach (var f in _sim.Edjes)
foreach (var f in sim.Edjes) Util.Vertex4(_sim.Verts[f]);
Util.Vertex4(sim.Verts[f]);
GL.End(); GL.End();
} }
@@ -116,7 +99,7 @@ namespace Tetrahedrons
{ {
base.OnUpdateFrame(e); base.OnUpdateFrame(e);
var w = 10f; var w = 2f;
var d = w; var d = w;
_proj3d = Matrix4.CreateOrthographic(w, w * Height / Width, -d / 2, d / 2); _proj3d = Matrix4.CreateOrthographic(w, w * Height / Width, -d / 2, d / 2);
@@ -124,19 +107,15 @@ namespace Tetrahedrons
_t += e.Time; _t += e.Time;
var pln = MVec4D.UnitXy + MVec4D.UnitXz + MVec4D.UnitYw; var plane = MVec4D.UnitXw-2*MVec4D.UnitXy;
var r = MVec4D.Rotor(e.Time / 10, pln.Normalized);
foreach (var pent in _simplexes)
for (var i = 0; i < pent.Verts.Length; i++)
pent.Verts[i] |= r;
var blade = MVec4D.UnitXyz; var blade = MVec4D.UnitXyz;
var pivot = MVec4D.Zero; var pivot = .1 * MVec4D.UnitW;
for (var i = 0; i < _simplexes.Length; i++) var r = MVec4D.Rotor(e.Time / 10, plane.Normalized);
{ for (var i = 0; i < _sim.Verts.Length; i++)
_intersections[i] = _simplexes[i].Intersect(blade, pivot); _sim.Verts[i] |= r;
}
_int = _sim.Intersect(blade, pivot);
} }
protected override void OnKeyDown(KeyboardKeyEventArgs e) protected override void OnKeyDown(KeyboardKeyEventArgs e)