Log inGet started
World

Car Forge: Procedural Car Generator and Traffic Fleet Kit

Branchmain
Branchesmain
Commit98552b9f03

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 = false checks the physics numbers only.
  • Validate.sweep(presets, seeds, opts) checks every seed of every preset (seeds a 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 = true releases meshes the test itself made (Mesh.release).
  • Validate.RULES holds every rule in words, Validate.MASS the kerb weight window of each body style, Validate.LIMITS the tolerances.

The rules

rulewhat must hold
geom.finiteevery position and normal of body, wheel and cabin is finite; normals unit length
geom.indicesindices in threes, each naming a vertex
geom.degenerateno triangle under 1e-9 m2
geom.normalsvertex normals agree with each triangle's winding
geom.boundsbody 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.closedthe body's main shell is closed and consistently wound (welded at 0.5 mm, every edge once each way)
collide.covercolliders 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.bedOpena pickup's bed is open: nothing above its floor
wheel.archaxle on its arch's axle; inner face inboard of the body side; outer face at most 1 cm outside it
wheel.clearno point of the drawn wheel inside the body, at loaded rest, straight and at full lock both ways
wheel.groundat 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.massmass inside the style's real-world window (electric +15%)
weight.balance38-66% on the front axle; static stability factor >= 0.95
weight.springsride frequency 0.9-3.2 Hz, damping ratio 0.2-0.9