Editor utility that carves a ring-shaped wall into an ArchMesh. It grows an outline by a thickness, creates an outer volume and subtracts the inner outline to produce a ring, then writes the resulting faces as polygons into the mesh with a given brush.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Sunless.Architecture;
// Walls lining a hole, grown OUTSIDE the outline - grown inward they would narrow the hole they line. A shaft, a
// stairwell and a wrapped flight all stand one, so the ring is kernel geometry rather than any one module's.
public static class ArchCarveRing
{
public static void Walls( ArchMesh canvas, IReadOnlyList<Vector2> outline, float thickness, float bottom, float top, ArchBrush brush )
{
if ( top - bottom < 0.05f )
{
return;
}
var carve = new ArchCarve();
carve.Plus( ArchCarveVolume.Over( ArchFootprint.Grow( new List<List<Vector2>> { outline.ToList() }, thickness ).First(), bottom, top ) );
carve.Less( ArchCarveVolume.Over( outline, bottom - 1f, top + 1f ) );
// Per ring - a shaft is a stack of rings, two meeting end to end are two solids.
using var welding = canvas.Welding();
foreach ( var face in carve.Resolve().Faces )
{
canvas.Polygon( face.Points, brush );
}
}
}