Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/OpenApparatus.Core/Geometry/BoundaryWallBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ static MeshData EmptyResult()

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

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

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

/// <summary>Lengthens a segment by <paramref name="d"/> at each end, keeping
/// its direction — used to overlap walls at corners.</summary>
static EdgeSegment Extend(EdgeSegment seg, float d)
{
var dir = seg.Direction;
return new EdgeSegment(seg.Start - dir * d, seg.End + dir * d);
}

// -------------------- Slab frame helper --------------------

/// <summary>
Expand Down
7 changes: 3 additions & 4 deletions src/OpenApparatus.IO/OpenApparatus.IO.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- net8.0 covers both consumers (desktop Studio + studio-web WASM at net10.0,
which forward-resolves net8.0 assets). The IO lib isn't a Unity-runtime
concern — exports are a build-time / authoring-time activity, and Unity
has its own OBJ/glTF importers. So no netstandard2.1 target needed. -->
<!-- net8.0 targets the desktop Studio app. The IO lib is authoring/build-time
only; the Unity package consumes its export *outputs*, not its types, and
doesn't need this DLL at runtime. -->
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
Loading