carForge.package
- ..
- .metadata17 B
- README.md3.3 KB
- RESULTS.md7.6 KB
- init.luau31.9 KB
README.md
validate
Proof that a Car Forge car is sound, by written rules checked on the car's real geometry, colliders, wheels and physics numbers. Used by the carForge test suite (a sample of every preset) and for full sweeps (every preset x 200 seeds; see RESULTS.md).
local Validate = require("~carForge.validate")
local r = Validate.car(Cars.describe(42, { preset = "workPickup" })) -- { ok, failures = { { rule, part, message } }, metrics }
local c = Validate.sweep(nil, 200) -- every preset, seeds 1..200: { cars, failed, byRule, byPreset, examples, ms }
local p = Validate.settle(list, { release = true }) -- play mode: spawn, settle, measure every wheel
Validate.car(d, opts)builds the body (torqueCars bodygen), wheel and cabin straight from the generators, with no GPU upload and no caching, so a sweep of thousands of cars leaves the shared mesh caches alone.opts.geometry = falsechecks the physics numbers only.Validate.sweep(presets, seeds, opts)checks every seed of every preset (seedsa count or a list) and counts failures by rule and preset, with a few examples per rule.Validate.settle(list, opts)(play mode) spawns the cars as real, local vehiclesKit vehicles on a flat slab far from everything, lets them settle and reads each wheel back: where the tyre meets the ground, where the wheel centre stands in the chassis frame and how far the spring compressed, against the analytic rest.release = truereleases meshes the test itself made (Mesh.release).Validate.RULESholds every rule in words,Validate.MASSthe kerb weight window of each body style,Validate.LIMITSthe tolerances.
The rules
| rule | what must hold |
|---|---|
geom.finite | every position and normal of body, wheel and cabin is finite; normals unit length |
geom.indices | indices in threes, each naming a vertex |
geom.degenerate | no triangle under 1e-9 m2 |
geom.normals | vertex normals agree with each triangle's winding |
geom.bounds | body within its length / width (+ flare, mirrors) / height, shell above the ride height; wheel within radius and width; cabin inside the body shell (an open car's cockpit above the belt excepted) |
shell.closed | the body's main shell is closed and consistently wound (welded at 0.5 mm, every edge once each way) |
collide.cover | colliders hold >= 85% of the body's volume (10 cm grid, less a 3 cm skin); their bottom within 6 cm of the floor |
collide.overhang | <= 6% of the colliders' volume outside the body (wheel openings excepted) |
collide.bedOpen | a pickup's bed is open: nothing above its floor |
wheel.arch | axle on its arch's axle; inner face inboard of the body side; outer face at most 1 cm outside it |
wheel.clear | no point of the drawn wheel inside the body, at loaded rest, straight and at full lock both ways |
wheel.ground | at rest under its weight every wheel centre is at its radius above the ground in the chassis frame (1 cm), compression leaves >= 20% travel |
weight.mass | mass inside the style's real-world window (electric +15%) |
weight.balance | 38-66% on the front axle; static stability factor >= 0.95 |
weight.springs | ride frequency 0.9-3.2 Hz, damping ratio 0.2-0.9 |