import { TriangleGrid } from './math'; import { type BodyModel, type GarmentModel, type GarmentUnit } from './model'; /** * The poke-through measurement — a port of `pokethrough-check.mjs`'s `checkPose` (see `posing.ts` for the one * deliberate difference: duplicated skeletons are posed as one). For every BODY vertex within `proximity` of * the garment's posed surface, the signed distance from the nearest garment point along that garment * triangle's own normal decides: > `threshold` and ≤ `ceiling` is a violation; > `ceiling` is `beyondCeiling` * (a point the garment was never meant to cover); a vertex outside the slot's region scope is `outOfScope`. * The garment surface is the UNION of every skinned garment mesh (every LOD level), as in the checker. * * ORIENTATION (found building this stage, 2026-09-28; landed in the canonical checker the same day as its * ORIENTATION_REASONING): the raw signed distance trusts each garment triangle's own winding as "outward". A * lined or two-sided garment's nearest surface to the body is its LINING, whose normal faces INTO the body, * so a body vertex sitting safely 5mm behind the lining read as "5mm past the garment" — ~90% of Male Casual * Blazer's violations. When every body primitive carries NORMAL, a garment normal that opposes the body * vertex's own normal has the signed distance's sign flipped first, exactly as the checker now does. * `violationCount` is that (canonical) count; the old un-oriented count is kept as `rawViolationCount` for * comparison only — it is not gated on, because it REWARDS pushing a lining into the body. * * EXPOSED COUNT (informational + a no-worse gate clause, not in the checker): of the counted violations, * those with NO sheet of the same LOD's garment over them along the body vertex's own normal (a ray to * `proximity`). A violation under an outer layer (body through the lining but still under the shell) is * invisible; an exposed one is skin you can actually see. On Male Casual Blazer ~80% of the oriented count is * covered this way — the exposed count is the closest geometric proxy for "visible poke-through" we have. * * The nearest-triangle search is `TriangleGrid.nearest` — exact, with a provable stopping rule — so a * vertex's verdict here equals the checker's except where two garment triangles tie exactly for nearest * (a shared edge or corner) and the checker's scan order happens to pick the other one; ties here always * go to the lower triangle index. */ export interface PoseMeasurement { pass: boolean; bodyVerticesConsidered: number; violationCount: number; outOfScope: number; beyondCeiling: number; maxViolationMm: number; /** Garment normals flipped to face away from the body before measuring (0 when the body has no normals). */ orientationFlipped: number; /** The pre-orientation-fix count (the checker before 2026-09-28) — informational only. */ rawViolationCount: number; /** Violations with no sheet of the garment over them along the body normal (null without body normals). */ exposedViolationCount: number | null; } export interface Measurement { poses: Record; totalViolations: number; totalBeyondCeiling: number; totalRawViolations: number; totalExposedViolations: number | null; } export interface MeasureSettings { thresholdM: number; ceilingM: number; proximityM: number; /** Region scope (the slot's granted hide regions); null = unscoped. */ inScope: ((region: string | null) => boolean) | null; poseNames: readonly string[]; } /** Grid cell for garment-surface lookups. 1cm keeps the typical near-surface query to one 27-cell shell. */ export declare const SURFACE_CELL_M = 0.01; export interface PosedSurface { grid: TriangleGrid; /** Unit normal per grid triangle (3 each). */ normals: Float64Array; /** For each grid triangle: [unitIndex, vA, vB, vC] (vertex indices local to that unit). */ corners: Int32Array; } /** * Posed garment triangles for `units` at rest displacement `deltas` (per unit, 3 per vertex), skipping * degenerate triangles exactly where the checker does (a zero-length cross product). */ export declare function buildPosedSurface(units: readonly GarmentUnit[], unitIds: readonly number[], poseName: string, deltas: readonly Float64Array[]): PosedSurface; export declare function measurePokethrough(body: BodyModel, garment: GarmentModel, deltas: readonly Float64Array[], settings: MeasureSettings): Measurement; /** * The gate's verdict: `after` counts as an improvement only if * - its total violation count (the checker's) is STRICTLY lower than `before`'s, and * - no single pose shows MORE VISIBLE poke-through than before: the exposed count per pose may not rise * (fewer violations in total must never mean more skin showing in one motion). When the body carries no * normals there is no exposed count, and the per-pose violation count is held to the same rule instead. * The per-pose rule is deliberately on the exposed count, not the raw per-pose count: most of a lined * garment's counted violations are covered by an outer layer, and those shuffle between poses as cloth * moves without anything becoming visible; holding them to a per-pose ratchet rejected fits that removed * 80% of the visible poke-through (Male Casual Blazer, 2026-09-28). */ export declare function isStrictImprovement(before: Measurement, after: Measurement): boolean; /** The first gate clause `after` fails (see `isStrictImprovement`), or null when it passes. */ export declare function gateRejection(before: Measurement, after: Measurement, layerCrossings: number): string | null;