Collisions editing progress

This commit is contained in:
dexy 2020-01-12 14:25:27 +11:00
parent 16982d7219
commit 581ae73db5

View File

@ -1133,7 +1133,7 @@ namespace CodeWalker.GameFiles
{
BuildMaterials();
CalculateQuantum();
//UpdateEdgeIndices(); //TODO: reinstate this?
UpdateEdgeIndices();
var list = new List<IResourceBlock>(base.GetReferences());
if (Vertices2 != null)
@ -1558,9 +1558,10 @@ namespace CodeWalker.GameFiles
{
//update all triangle edge indices, based on shared vertex indices
if (Polygons == null)
{ return; }
var edgedict = new Dictionary<BoundEdgeRef, BoundEdge>();
if (Polygons != null)
{
foreach (var poly in Polygons)
{
if (poly is BoundPolygonTriangle btri)
@ -1572,10 +1573,15 @@ namespace CodeWalker.GameFiles
if (edgedict.TryGetValue(e1, out BoundEdge edge1))
{
if (edge1.Triangle2 != null)
{ }
{
btri.SetEdgeIndex(1, (short)edge1.Triangle1.Index);
}
else
{
edge1.Triangle2 = btri;
edge1.EdgeID2 = 1;
}
}
else
{
edgedict[e1] = new BoundEdge(btri, 1);
@ -1583,10 +1589,15 @@ namespace CodeWalker.GameFiles
if (edgedict.TryGetValue(e2, out BoundEdge edge2))
{
if (edge2.Triangle2 != null)
{ }
{
btri.SetEdgeIndex(2, (short)edge2.Triangle1.Index);
}
else
{
edge2.Triangle2 = btri;
edge2.EdgeID2 = 2;
}
}
else
{
edgedict[e2] = new BoundEdge(btri, 2);
@ -1594,10 +1605,15 @@ namespace CodeWalker.GameFiles
if (edgedict.TryGetValue(e3, out BoundEdge edge3))
{
if (edge3.Triangle2 != null)
{ }
{
btri.SetEdgeIndex(3, (short)edge3.Triangle1.Index);
}
else
{
edge3.Triangle2 = btri;
edge3.EdgeID2 = 3;
}
}
else
{
edgedict[e3] = new BoundEdge(btri, 3);
@ -1626,6 +1642,18 @@ namespace CodeWalker.GameFiles
}
}
foreach (var poly in Polygons)
{
if (poly is BoundPolygonTriangle btri)
{
if (btri.edgeIndex1 >= Polygons.Length)
{ } //just checking....
if (btri.edgeIndex2 >= Polygons.Length)
{ }
if (btri.edgeIndex3 >= Polygons.Length)
{ }
}
}
}