Remove door blocking cell portal polys from casting mesh

This commit is contained in:
Jarrod Doyle 2025-02-21 17:29:46 +00:00
parent cab85f3ea1
commit e78e53ff51
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 5 additions and 30 deletions

View File

@ -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;
} }