Editor/Services/ArchLap.cs
using System;

namespace Sunless.Architecture;

// One place for how deep a solid laps into its neighbour - every coplanar pair arch_audit reports is a missing copy.
public static class ArchLap {
	// Deep enough that no float error surfaces it, shallow enough to read as contact.
	public static float Bite( ArchKit kit ) => MathF.Max( 0.05f, kit?.ContactBite ?? 0.4f );

	// Never shallower than a bite, or the trim is inside what it is supposed to be trimming.
	public static float Proud( ArchKit kit ) => MathF.Max( Bite( kit ), kit?.WellTrimProud ?? 0.75f );

	// Held back off a shared plane to prevent coplanar flicker.
	public const float Shy = 1f;

	// Signed by the direction the solid faces - a tread's underside buries down, a skirting's foot up.
	public static float Bury( ArchKit kit, float plane, float outward ) => plane - MathF.Sign( outward ) * Bite( kit );

	// Grown a bite at both ends so the piece overlaps what it butts into.
	public static (float From, float To) Lapped( ArchKit kit, float from, float to ) {
		var bite = Bite( kit );

		return (from - bite, to + bite);
	}
}