Always create a new edge to the portal graph
This commit is contained in:
parent
c5cbeddcd5
commit
74283f976d
|
@ -77,28 +77,22 @@ public class PotentiallyVisibleSet
|
||||||
|
|
||||||
var other = poly.Destination;
|
var other = poly.Destination;
|
||||||
|
|
||||||
// If there's already an existing edge between the two cells then we just need to add a reference to it
|
// Checking if there's already an edge is super slow. It's much faster to just add a new edge, even with
|
||||||
// otherwise we need to actually build the edge
|
// the duplicated poly
|
||||||
var edgeIndex = _edges.FindIndex(e => (e.Left == i && e.Right == other) || (e.Left == other && e.Right == i));
|
var vs = new Vector3[poly.VertexCount];
|
||||||
if (edgeIndex == -1)
|
for (var vIdx = 0; vIdx < poly.VertexCount; vIdx++)
|
||||||
{
|
{
|
||||||
var vs = new Vector3[poly.VertexCount];
|
vs[vIdx] = cell.Vertices[cell.Indices[indicesOffset + vIdx]];
|
||||||
for (var vIdx = 0; vIdx < poly.VertexCount; vIdx++)
|
|
||||||
{
|
|
||||||
vs[vIdx] = cell.Vertices[cell.Indices[indicesOffset + vIdx]];
|
|
||||||
}
|
|
||||||
|
|
||||||
var edge = new Edge
|
|
||||||
{
|
|
||||||
Left = i,
|
|
||||||
Right = other,
|
|
||||||
Poly = new Poly(vs, cell.Planes[poly.PlaneId]),
|
|
||||||
};
|
|
||||||
_edges.Add(edge);
|
|
||||||
edgeIndex = _edges.Count - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_portalGraph[i].Add(edgeIndex);
|
var edge = new Edge
|
||||||
|
{
|
||||||
|
Left = i,
|
||||||
|
Right = other,
|
||||||
|
Poly = new Poly(vs, cell.Planes[poly.PlaneId]),
|
||||||
|
};
|
||||||
|
_edges.Add(edge);
|
||||||
|
_portalGraph[i].Add(_edges.Count - 1);
|
||||||
indicesOffset += poly.VertexCount;
|
indicesOffset += poly.VertexCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue