Improved rendering for nav poly selection, path shader now batches selection lines and tris

This commit is contained in:
dexyfex
2018-05-01 18:03:20 +10:00
Unverified
parent a56e87d64a
commit 4c46a850f4
3 changed files with 112 additions and 81 deletions
+66 -1
View File
@@ -757,7 +757,7 @@ namespace CodeWalker.Rendering
public void RenderSelectionNavPoly(YnvPoly poly)
{
////draw poly triangles
var pcolour = new Color4(0.6f, 0.95f, 0.6f, 1.0f);
var pcolour = new Color4(1.0f, 1.0f, 1.0f, 0.2f);
var colourval = (uint)pcolour.ToRgba();
var ynv = poly.Ynv;
var ic = poly._RawData.IndexCount;
@@ -792,6 +792,71 @@ namespace CodeWalker.Rendering
}
}
public void RenderSelectionNavPolyOutline(YnvPoly poly, uint colourval)
{
//var colourval = (uint)colour.ToRgba();
var ynv = poly.Ynv;
var ic = poly._RawData.IndexCount;
var startid = poly._RawData.IndexID;
var endid = startid + ic;
var lastid = endid - 1;
var vc = ynv.Vertices.Count;
var startind = ynv.Indices[startid];
////draw poly outline
VertexTypePC v = new VertexTypePC();
v.Colour = colourval;
VertexTypePC v0 = new VertexTypePC();
for (int id = startid; id < endid; id++)
{
var ind = ynv.Indices[id];
if (ind >= vc)
{ continue; }
v.Position = ynv.Vertices[ind];
SelectionLineVerts.Add(v);
if (id == startid)
{
v0 = v;
}
else
{
SelectionLineVerts.Add(v);
}
if (id == lastid)
{
SelectionLineVerts.Add(v0);
}
}
////draw poly triangles
//VertexTypePC v0 = new VertexTypePC();
//VertexTypePC v1 = new VertexTypePC();
//VertexTypePC v2 = new VertexTypePC();
//v0.Position = ynv.Vertices[startind];
//v0.Colour = colourval;
//v1.Colour = colourval;
//v2.Colour = colourval;
//int tricount = ic - 2;
//for (int t = 0; t < tricount; t++)
//{
// int tid = startid + t;
// int ind1 = ynv.Indices[tid + 1];
// int ind2 = ynv.Indices[tid + 2];
// if ((ind1 >= vc) || (ind2 >= vc))
// { continue; }
// v1.Position = ynv.Vertices[ind1];
// v2.Position = ynv.Vertices[ind2];
// Renderer.SelectionTriVerts.Add(v0);
// Renderer.SelectionTriVerts.Add(v1);
// Renderer.SelectionTriVerts.Add(v2);
// Renderer.SelectionTriVerts.Add(v0);
// Renderer.SelectionTriVerts.Add(v2);
// Renderer.SelectionTriVerts.Add(v1);
//}
}
public void RenderSelectionGeometry(MapSelectionMode mode)
{