feat(world): Materialien, Kollision und Laternen für die neuen Straßen
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ca4f7161af
commit
25248b3929
8 files changed
+205
-110
No files matched your search
@@ -2,7 +2,7 @@ import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { CHUNKS_PER_SIDE, CHUNK_SIZE, SLICE, chunkForWorld } from "../src/world/coords.js";
|
||||
import { PLACES, PLACE_HIDE_RADIUS, PLACE_SHOW_RADIUS, placeTransform } from "../src/world/places.js";
|
||||
import { lampPoints, pointInPolygon, vergeLampPoints } from "../src/world/props.js";
|
||||
import { chunkLampPoints, pointInPolygon } from "../src/world/props.js";
|
||||
import { withoutReplacedBuildings } from "../src/world/streaming.js";
|
||||
|
||||
// Radien aus ChunkStreamer.update (src/world/streaming.js), gemessen zum Chunk-Mittelpunkt.
|
||||
@@ -72,7 +72,9 @@ describe.each(PLACES.map((place) => [place.id, place]))("Ort %s auf der Karte",
|
||||
const c = chunk(i, j);
|
||||
const u = X - c.origin[0], v = -Y - c.origin[1];
|
||||
const onLand = c.land.some((rings) => pointInPolygon(u, v, rings));
|
||||
const onRoad = c.roads.some((road) => pointInPolygon(u, v, road.poly));
|
||||
// Straße ist seit Teil 2 alles, was früher der Korridor war: Fahrbahn, Gehweg und Restflächen.
|
||||
const onRoad = [...(c.carriageway ?? []), ...(c.sidewalk ?? []), ...(c.lots ?? [])]
|
||||
.some((road) => pointInPolygon(u, v, road.poly));
|
||||
const inBuilding = standingBuildings(i, j).some((building) => pointInPolygon(u, v, building.poly));
|
||||
return !onLand || onRoad || inBuilding;
|
||||
});
|
||||
@@ -106,7 +108,7 @@ describe.each(PLACES.map((place) => [place.id, place]))("Ort %s auf der Karte",
|
||||
});
|
||||
|
||||
// Bruch: eine Palme oder Laterne mitten im Ort. Beide entstehen je Chunk und wissen nichts von Orten;
|
||||
// Laternen stehen bis 16 m neben ihrer Mittellinie, deshalb zählen auch die Nachbarchunks.
|
||||
// Laternen stehen bis 12 m neben ihrer Straßenkante (LAMP_VERGE), deshalb zählen auch die Nachbarchunks.
|
||||
it("enthält keine Palme und keine Laterne", () => {
|
||||
const nearby = new Set();
|
||||
for (const [i, j] of under) {
|
||||
@@ -120,7 +122,7 @@ describe.each(PLACES.map((place) => [place.id, place]))("Ort %s auf der Karte",
|
||||
const c = chunk(...key.split("_").map(Number));
|
||||
const toWorld = (u, v) => ({ X: c.origin[0] + u, Y: -(c.origin[1] + v) });
|
||||
const palms = (c.palms ?? []).map(([u, v]) => toWorld(u, v));
|
||||
const lamps = vergeLampPoints(lampPoints(c.centerlines ?? []), c.roads ?? []).map((p) => toWorld(p.x, p.z));
|
||||
const lamps = chunkLampPoints(c).map((p) => toWorld(p.x, p.z));
|
||||
return [...palms, ...lamps];
|
||||
});
|
||||
expect(props.filter(({ X, Y }) => insideBounds(place, X, Y))).toEqual([]);
|
||||
|
||||
Reference in new issue
Block a user