Remove door blocking cell portal polys from casting mesh
This commit is contained in:
parent
cab85f3ea1
commit
e78e53ff51
|
@ -35,38 +35,12 @@ public class MeshBuilder
|
||||||
var polyVertices = new List<Vector3>();
|
var polyVertices = new List<Vector3>();
|
||||||
foreach (var cell in worldRep.Cells)
|
foreach (var cell in worldRep.Cells)
|
||||||
{
|
{
|
||||||
var numPolys = cell.PolyCount;
|
// We only care about polys representing solid terrain. We can't use RenderPolyCount because that includes
|
||||||
var numRenderPolys = cell.RenderPolyCount;
|
// water surfaces.
|
||||||
var numPortalPolys = cell.PortalPolyCount;
|
var solidPolys = cell.PolyCount - cell.PortalPolyCount;
|
||||||
var solidPolys = numPolys - numPortalPolys;
|
|
||||||
|
|
||||||
var cellIdxOffset = 0;
|
var cellIdxOffset = 0;
|
||||||
for (var polyIdx = 0; polyIdx < numPolys; polyIdx++)
|
for (var polyIdx = 0; polyIdx < solidPolys; polyIdx++)
|
||||||
{
|
{
|
||||||
// There's 2 types of poly that we need to include in the mesh:
|
|
||||||
// - Terrain
|
|
||||||
// - Door vision blockers
|
|
||||||
//
|
|
||||||
// Door vision blockers are the interesting one. They're not RenderPolys at all, just flagged Polys.
|
|
||||||
SurfaceType primType;
|
|
||||||
if (polyIdx < solidPolys)
|
|
||||||
{
|
|
||||||
primType = cell.RenderPolys[polyIdx].TextureId == 249 ? SurfaceType.Sky : SurfaceType.Solid;
|
|
||||||
}
|
|
||||||
else if (polyIdx < numRenderPolys)
|
|
||||||
{
|
|
||||||
// we no longer want water polys :)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if ((cell.Flags & 8) != 0)
|
|
||||||
{
|
|
||||||
primType = SurfaceType.Solid;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var poly = cell.Polys[polyIdx];
|
var poly = cell.Polys[polyIdx];
|
||||||
polyVertices.Clear();
|
polyVertices.Clear();
|
||||||
polyVertices.EnsureCapacity(poly.VertexCount);
|
polyVertices.EnsureCapacity(poly.VertexCount);
|
||||||
|
@ -75,6 +49,7 @@ public class MeshBuilder
|
||||||
polyVertices.Add(cell.Vertices[cell.Indices[cellIdxOffset + i]]);
|
polyVertices.Add(cell.Vertices[cell.Indices[cellIdxOffset + i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var primType = cell.RenderPolys[polyIdx].TextureId == 249 ? SurfaceType.Sky : SurfaceType.Solid;
|
||||||
AddPolygon(polyVertices, primType);
|
AddPolygon(polyVertices, primType);
|
||||||
cellIdxOffset += poly.VertexCount;
|
cellIdxOffset += poly.VertexCount;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue