Skip to content

Commit 29cdf93

Browse files
committed
Revert "Extend wall slabs past their ends to close corner gaps (#4)"
This reverts commit 66a030e.
1 parent 66a030e commit 29cdf93

2 files changed

Lines changed: 15 additions & 26 deletions

File tree

src/OpenApparatus.Core/Geometry/BoundaryWallBuilder.cs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ static MeshData EmptyResult()
5050

5151
static MeshData BuildClosed(Adjacency adj, float t, float h)
5252
{
53-
// Extend the slab half a thickness past each end so perpendicular walls
54-
// overlap at corners instead of leaving a t/2 square gap.
55-
var slab = SlabFrame.From(Extend(adj.SharedSegment, t * 0.5f), t);
53+
var slab = SlabFrame.From(adj.SharedSegment, t);
5654
var b = new MeshDataBuilder();
5755
EmitClosedWallFaces(b, slab, h);
5856
b.EnsureSubmeshCount(SubmeshIndex.Count);
@@ -87,16 +85,11 @@ static void EmitClosedWallFaces(MeshDataBuilder b, SlabFrame slab, float h)
8785

8886
static MeshData BuildDoorway(Adjacency adj, float t, float h, Passage.Doorway door)
8987
{
90-
// Extend the slab half a thickness past each end (see BuildClosed).
91-
float ext = t * 0.5f;
92-
var slab = SlabFrame.From(Extend(adj.SharedSegment, ext), t);
88+
var slab = SlabFrame.From(adj.SharedSegment, t);
9389
const float EPS = 1e-5f;
9490

95-
// Sort openings by offset and validate fit + non-overlap. Offsets shift
96-
// by the extension because the slab now starts ext before the segment.
97-
var openings = new List<Opening>(door.Openings.Count);
98-
foreach (var op in door.Openings)
99-
openings.Add(op.With(offsetAlongEdge: op.OffsetAlongEdge + ext));
91+
// Sort openings by offset and validate fit + non-overlap.
92+
var openings = new List<Opening>(door.Openings);
10093
openings.Sort((a, c) => a.OffsetAlongEdge.CompareTo(c.OffsetAlongEdge));
10194
for (int i = 0; i < openings.Count; i++)
10295
{
@@ -261,14 +254,6 @@ static void EmitBottomStrip(MeshDataBuilder b, SlabFrame slab, float xStart, flo
261254
slab.Corner(false, xStart, 0f));
262255
}
263256

264-
/// <summary>Lengthens a segment by <paramref name="d"/> at each end, keeping
265-
/// its direction — used to overlap walls at corners.</summary>
266-
static EdgeSegment Extend(EdgeSegment seg, float d)
267-
{
268-
var dir = seg.Direction;
269-
return new EdgeSegment(seg.Start - dir * d, seg.End + dir * d);
270-
}
271-
272257
// -------------------- Slab frame helper --------------------
273258

274259
/// <summary>

tests/OpenApparatus.Core.Tests/Geometry/BoundaryWallBuilderTests.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,21 @@ public void DoorwayPassage_VertexCount_Matches15FacesAt4VertsEach()
106106
}
107107

108108
[Fact]
109-
public void DoorwayAtSegmentStart_StillGetsLeftJamb_FromCornerExtension()
109+
public void DoorwayFlushWithStart_OmitsLeftJambAndLeftBottomAndLeftTunnelSide()
110110
{
111-
// A doorway authored flush with the segment start (offset 0) is no
112-
// longer flush with the rendered slab: each slab is extended half a
113-
// thickness past its ends to close corner gaps, so a stub of wall sits
114-
// to the left of the opening. The full jamb set is therefore emitted,
115-
// giving the same 14 wall faces as an interior doorway.
111+
// doorOffset=0 → no left jamb on either side, no left bottom rim.
112+
// Tunnel left side stays (still bounds the door); right side stays; ceiling stays.
113+
// Faces: 2 (right-jamb each side) + 1 (top) + 1 (right bottom only) +
114+
// 2 (caps) + 3 (tunnel left/right/ceiling) = 9. Wait — both tunnel sides
115+
// are still emitted because the door has finite width with two side walls.
116+
// Reconsider: 2 (right jamb each side) + 1 (top) + 1 (right bottom only) + 2 (caps) +
117+
// 3 (tunnel) + 0 (no lintel split) ... but lintel IS still present (door
118+
// height < wall height). Lintel = 2 (one per side).
119+
// Total: 2 + 2 + 1 + 1 + 2 + 3 = 11 faces.
116120
var (_, _, adj) = MakeInternalAdjacency(
117121
new Passage.Doorway(offsetAlongEdge: 0f, width: 0.4f, height: 2.2f));
118122
var mesh = new BoundaryWallBuilder().Build(adj, 0.2f, 3f);
119-
Assert.Equal(14 * 2, mesh.TriangleCount(SubmeshIndex.Walls));
123+
Assert.Equal(11 * 2, mesh.TriangleCount(SubmeshIndex.Walls));
120124
Assert.Equal(1 * 2, mesh.TriangleCount(SubmeshIndex.Floor));
121125
}
122126

0 commit comments

Comments
 (0)