Shorten how intersectors are added to the grid in the Intersector constructor

Thanks to modern JavaScript features this code can be simplified a tiny bit.
This commit is contained in:
Jonas Jenwald 2026-04-30 12:02:10 +02:00
parent d92db130da
commit 4a5c455c0b

View File

@ -192,11 +192,7 @@ class Intersector {
const h = Math.floor((iMax - iMin) / STEPS);
for (let i = iMin; i <= iMin + h * STEPS; i += STEPS) {
for (let j = 0; j <= w; j++) {
let existing = this.#grid[i + j];
if (!existing) {
this.#grid[i + j] = existing = [];
}
existing.push(intersector);
(this.#grid[i + j] ??= []).push(intersector);
}
}
}