import type { CabinTriangles, OccupantPull, Vec3 } from './vehicleMath'; export type BodyPart = 'head' | 'torso' | 'arm' | 'hand' | 'hip' | 'thigh' | 'knee' | 'leg' | 'foot'; /** What the penetrated surface is. `self` = the occupant's own body (a hand through its own thigh). */ export type CabinPart = 'roof' | 'pillar' | 'door' | 'glass' | 'seat' | 'dash' | 'wheel' | 'pedals' | 'floor' | 'console' | 'self' | 'other'; export declare const PENETRATION_THRESHOLDS: { /** A vertex counts as through a surface beyond this depth (below it is touching). */ readonly contactMinM: 0.001; /** A cluster deeper than this... */ readonly failDepthM: 0.008; /** ...over at least this much area (of the part deeper than `failDepthM`) fails the seat. 4 cm². */ readonly failAreaM2: 0.0004; /** A part sunk deeper than a finger is thick has disappeared, whatever its footprint: deeper than this... */ readonly swallowDepthM: 0.025; /** ...over at least this much (fingertips 46 mm into a thigh measured 3.1 cm²) fails too. */ readonly swallowAreaM2: 0.00015; /** A cluster needs this many vertices (or object samples) past the fail depth: one or two vertices of a sparse * garment poking through a card (a sleeve corner) is a near-contact, never a fail. */ readonly failMinPoints: 3; /** A hand closing on the steering wheel rim, a sole pressing a pedal pad: the part is MEANT to touch, and a grip or a * press always sinks a few millimetres into the other surface. Those pairings fail only beyond this depth. */ readonly contactPairDepthM: 0.02; /** GROSS (blocks): a body part sunk this deep into the car... */ readonly grossDepthM: 0.06; /** ...over at least this much of the part past `failDepthM`. 6 cm². */ readonly grossAreaM2: 0.0006; /** A hand in the wheel, a sole in a pedal pad are meant to touch and are small, hard-edged objects: gross only this deep. */ readonly grossPairDepthM: 0.1; /** GROSS (blocks): through the car's exterior skin, seen from outside: at least this deep, over this area, at this many vertices. */ readonly exteriorDepthM: 0.025; readonly exteriorAreaM2: 0.0004; readonly exteriorMinPoints: 3; /** Penetrating vertices closer than this belong to the same cluster. */ readonly linkM: 0.03; /** A breached bone's recorded entry point is this far back from its crossing, on the free side. */ readonly anchorBackoffM: 0.005; }; export type PenetrationThresholds = typeof PENETRATION_THRESHOLDS; /** What one seat's pull can carry beyond the base occupant pull (all optional: older dumps have neither). */ export interface PenetrationPull extends OccupantPull { /** Parent bone name per bone (null for the skeleton root). Without it a UE-mannequin parent table is assumed. */ boneParents?: Record; /** Per point (same order as `points`), the index into `boneNames` of the bone with the largest skin weight. */ pointBone?: number[]; boneNames?: string[]; } export interface PenetrationCluster { seat: string; bodyPart: BodyPart; /** Body parts in the cluster with their vertex counts, largest first. */ bodyParts: Array<[BodyPart, number]>; cabinPart: CabinPart; /** The penetrated mesh (or `thigh_l` / `thigh_r` for a hand through its own thigh). */ cabinMesh: string; maxDepthM: number; meanDepthM: number; /** Projected area of every penetrating vertex of the cluster, and of the part deeper than the fail depth. */ areaM2: number; areaDeepM2: number; vertices: number; centroid: Vec3; /** The penetrated surface's mean normal there, pointing INTO the occupant (from the surface toward the bone). */ normal: Vec3; /** The cluster's extent: the largest distance of one of its points from the centroid. */ radiusM: number; /** Up to 800 of the cluster's points (body frame), for drawing evidence; dropped before the cluster is recorded. */ points?: Vec3[]; /** The fail depth that applied (larger for a grip or a pedal press). */ failDepthM: number; verdict: 'fail' | 'near'; /** * A `fail` that blocks: through the exterior skin seen from outside, or buried >= 60 mm. A `fail` that is not gross is a * MINOR clip (warn). Absent on a `near` and on records made before this field existed (read as not gross). */ gross?: boolean; /** Why it is gross (`exterior` or `buried`), and for `exterior` how many of the sampled vertices lie outside the skin. */ grossWhy?: 'exterior' | 'buried'; exposed?: { outside: number; sampled: number; }; } export interface SupportContact { bodyPart: BodyPart; cabinMesh: string; maxDepthM: number; areaM2: number; vertices: number; } export interface PenetrationResult { seat: string; vertices: number; cabinTriangles: number; /** Triangles taken as the occupant's own seat (support), and the meshes they are in. */ ownSeat: { triangles: number; meshes: string[]; }; /** Bones whose chain from the pelvis crosses a cabin surface an odd number of times (informational: the wall there is * measured against the limb by the envelope test). */ breached: Array<{ bone: string; throughMesh: string; }>; clusters: PenetrationCluster[]; support: SupportContact[]; /** Whether a skin-weight bone per vertex was available (else nearest bone by a radius-normalised distance). */ assignment: 'skin-weights' | 'nearest-bone'; /** Vertices on secondary/accessory bones (tail, skirt, hair, coat flaps): the avatar's, not judged. */ accessoryVertices: number; ms: number; } export declare function bodyPartOfBone(name: string): BodyPart | null; export declare function isAccessoryBone(name: string): boolean; export interface Segment { start: string; end: string | null; a: Vec3; b: Vec3; part: BodyPart; r: number; accessory?: boolean; } export interface Skeleton { root: string; segments: Segment[]; /** Nearest non-excluded ancestor per bone. */ parent: Map; children: Map; } /** Bone segments from the pelvis outwards (twist/facial/ik helpers skipped), plus a short extension past each head, * hand and foot leaf so the skull, finger tips and toes have a segment of their own. */ export declare function buildSkeleton(bones: Record, parentsIn?: Record): Skeleton | null; /** Cabin part from a mesh name, or `generic` when the name says nothing (a `bodyshell_1` that holds half the cabin). */ export declare function cabinPartOfMesh(name: string): CabinPart | 'generic'; export declare class TriGrid { readonly tris: ArrayLike; readonly cell: number; readonly min: Vec3; readonly dims: [number, number, number]; readonly cells: Map; private stamp; private tick; constructor(tris: ArrayLike, cell?: number); private ix; /** Every triangle in a cell overlapping the box, once. */ query(lo: Vec3, hi: Vec3, out: number[]): number[]; } /** Segment p->q against one triangle (two-sided). Returns the crossing parameter in (0, 1], or -1. */ export declare function segTri(tris: ArrayLike, t: number, p: Vec3, q: Vec3): number; /** * The triangles of the occupant's own seat: the first surface straight under the hips and thighs and straight behind the * spine, then (a) every triangle of a seat-NAMED mesh that holds one of them, or (b) for a generic mesh (a seat baked into * `bodyshell_1`), the surface connected to them inside a box around the seat. Floor-level flats are never grown into. */ export declare function ownSeatTriangles(cabin: CabinTriangles, bones: Record, pelvis: Vec3, grid: TriGrid): Uint8Array; /** The vertex spacing of a set of surface points: the median distance to each point's nearest neighbour (pairs closer * than 1 mm, a cloth layer lying on the skin, are not neighbours). One point alone stands for a 1 cm patch. */ export declare function vertexSpacing(points: Vec3[]): number; /** * Projected area of surface points onto the plane with normal `normal`: each vertex stands for the `spacing` x `spacing` * patch of surface around it (its share of a mesh sampled at that spacing), rasterised on a fine grid so overlapping * patches (a sleeve over the skin, a curved region folding over itself in projection) count once. */ export declare function projectedArea(points: Vec3[], normal: Vec3, spacing?: number | number[]): number; /** Every penetration of one seated occupant into the cabin around it (and of its hands into its own thighs). Pure. */ export declare function measurePenetration(pull: PenetrationPull, T?: PenetrationThresholds): PenetrationResult; /** * Mark a `fail` cluster gross (exterior or buried), in place. EXTERIOR: the vertices lie outside every drawn surface. The * cluster's normal points from the surface INTO the occupant, so the way out is its opposite; it must point outward from the * car (sideways away from the car's centre line for a door, pillar, glass or bodyshell flank; up for a roof), and a ray from * each sampled vertex that way must cross no triangle (a door card behind a door skin crosses the skin: not exposed). */ export declare function classifyGross(c: PenetrationCluster, cabin: CabinTriangles, T?: PenetrationThresholds): void; /** The failing clusters worth a picture: deduped by (seat, body part, cabin part), worst first (depth x sqrt(area)). */ export declare function evidenceClusters(clusters: PenetrationCluster[], max?: number): PenetrationCluster[]; /** * A camera that shows a cluster as geometry crossing, for a frame in which only the occupant and the clashing mesh are * drawn: from the far side of the penetrated surface (the cluster normal points into the occupant, so the camera stands * along its opposite, where the body part comes THROUGH the surface towards it), tilted outboard for a floor or a roof (a * camera under the car would be under the ground), and side-on along the thigh for a hand in its own thigh. Never a * clipping near plane: slicing the occupant reads as torn geometry. */ export declare function evidenceCamera(c: PenetrationCluster, outboard: number, occupant?: ArrayLike): { pos: Vec3; target: Vec3; fov: number; near: number; occluders: number; }; /** One table row per cluster, for facts and the assert's measured block. */ export declare function clusterRow(c: PenetrationCluster): Record; export interface PenetrationVerdict { id: string; pass: boolean; severity: 'block' | 'warn'; detail: string; measured: Record; } /** `vehicle.occupants.penetration` (block) and `vehicle.occupants.near_contact` (warn) over every measured seat. */ export declare function judgePenetration(results: Array, seats: string[], T?: PenetrationThresholds, /** Other minor clipping the caller measured (a sole a few cm under the floor...): listed with the minor clusters in the warn assert. */ extraMinor?: Array<{ text: string; measured?: unknown; }>, /** The seats a driver sits in: their feet and shins are judged against the footwell (`vehicle.occupants.driver_foot_clear`). */ driverSeats?: string[]): PenetrationVerdict[];