cars: allow sparse vehicle lights on remote side roads

This commit is contained in:
Richard Zink committed 2026-10-12 20:13:12 +02:00
1 parent 1f621d749a
commit 81791baa09
1 file changed
+5 -5
+5 -5
View File
@@ -3345,7 +3345,7 @@ var CAR_M_DASH = carMetres(CAR_TUN.dashM || 620);
// density sits below the motorway peak and the gaussian falloff shapes it
// further by distance to the nearest motorway.
var CAR_M_SPEED = 0.055 * CAR_SPEED, CAR_M_DENS = 0.85 * CAR_DENS;
var CAR_B_DASH = CAR_M_DASH * 2.8, CAR_B_SPEED = 0.017 * CAR_SPEED, CAR_B_DENS = 0.75 * CAR_DENS;
var CAR_B_DASH = CAR_M_DASH * 2.4, CAR_B_SPEED = 0.017 * CAR_SPEED, CAR_B_DENS = 0.85 * CAR_DENS;
var carGeo = null; // { motorway: packedChains, secondary: packedChains }
var carVboM = null, carCountM = 0;
var carVboB = null, carCountB = 0;
@@ -4284,7 +4284,7 @@ function buildCarGeometry(chainsM, chainsB, ts, cfg, places) {
// spreadKm is the sigma of the motorway distribution.
function densScale(x, z) {
var st = settleAt(x, z);
if (!distField) return Math.min(1, 0.16 + 0.84 * st);
if (!distField) return Math.min(1, 0.22 + 0.78 * st);
var i = Math.max(0, Math.min(ts.gw - 1, Math.round((x + ts.halfX) / ts.s)));
var j = Math.max(0, Math.min(ts.gh - 1, Math.round((ts.halfY - z) / ts.s)));
var d = distField[j * ts.gw + i] * ts.s; // world units to a motorway
@@ -4292,7 +4292,7 @@ function buildCarGeometry(chainsM, chainsB, ts, cfg, places) {
var mw = cfg.CAR_FLOOR + (1 - cfg.CAR_FLOOR) * Math.exp(-t * t);
// Side roads are sparse unless they are near the A-net or a town.
// Motorways/settlements get the bulk; remote secondary roads stay faint.
return Math.min(1, 0.12 + 0.58 * mw + 0.62 * st);
return Math.min(1, 0.20 + 0.55 * mw + 0.60 * st);
}
function build(polys, withField, dash) {
var li, i, segs = 0, totalLen = 0;
@@ -4354,8 +4354,8 @@ function buildCarGeometry(chainsM, chainsB, ts, cfg, places) {
var f = next - acc;
if (f < 0) f = 0;
var qx = a.x + dx * f, qz = a.z + dz * f;
var slotWeight = withField ? Math.max(0.12, Math.min(1.25, (dens - 0.10) / 0.72)) : 1.18;
if (inView(qx, qz) && pi + 20 <= pArr.length && slotWeight > 0.14) {
var slotWeight = withField ? Math.max(0.22, Math.min(1.25, (dens - 0.08) / 0.70)) : 1.18;
if (inView(qx, qz) && pi + 20 <= pArr.length && slotWeight > 0.05) {
// one shared slide phase per chain: every vehicle of
// a chain moves in lockstep, so a wrap lands exactly
// on the slot the neighbour just left - continuous