[K3c] Schnitt/Ansicht schneller bei bitgleicher Ausgabe (Raster, nah→fern mit Abbruch)

render3d section.rs: Verdecker je Kante über ein u-Raster mit nach Tiefe sortierten Zellen (Einträge
mit Rahmen, ohne Merkliste), konservative Absage über Höhe/Tiefe und Abbruch, sobald ein Prisma die
Kante ganz verdeckt (die Vereinigung hängt nicht von der Reihenfolge ab). Kern: ugrid.rs (1D-Raster),
Ansicht (Verdecker nah→fern mit Abbruch, Punkt-Verdeckung, Schatten, Eck-Verlängerung über Raster),
Schnitt-Dominanz nur gegen treffende Schneider, Verschmelzen gleicher Komponente ohne Neustart über
alle Paare (Ergebnis wie die schlichte Fassung, Test), Monolith-Umriss per Bereichs-Malen,
Öffnungen je Wand einmal indiziert (auch emit_walls), Zahlen-Nachbildung mit Schnellweg und zmij.

Gleichheitstest nach jedem Schritt grün (Beispiel, 60 Zufallsprojekte, gekachelte Zufallsprojekte
4x4, Kacheln 6x6; Primitive, Szene, SVG), CLI byte-gleich. Messung (Node/WASM, Min.): Schnitt
Kacheln 6x6 10,2 s -> 0,10 s, 8x8 33 s -> 0,19 s; Ansicht 8x8 107 -> 29 ms. pkg3d (3D-Live-Schnitt)
nicht neu gebaut; render3d-Tests grün, der Kern baut render3d für wasm32 mit.
This commit is contained in:
Claude committed 2026-10-29 07:12:45 +00:00
1 parent c59619d1fc
commit b3f2666cf3
16 files changed
+981 -108

No files matched your search

+7 -5
View File
@@ -37,7 +37,7 @@ it.skipIf(!process.env.BENCH)("Messung Schnitt/Ansicht alt gegen neu", async ()
for (const [name, p] of cases) {
const codes = new Set(flattenCategories(p.layers).map((c) => c.code));
const levels = p.drawingLevels.filter((l) => (l.kind === "section" || l.kind === "elevation") && l.linePoints) as DrawingLevel[];
const runs = name === "big16" ? 1 : name === "Beispiel" ? 20 : 5;
const runs = Number(process.env.BENCH_RUNS ?? (name === "big16" ? 1 : name === "Beispiel" ? 20 : 5));
for (const l of levels) {
if (l.kind === "section") {
const oldP = async () => {
@@ -46,16 +46,18 @@ it.skipIf(!process.env.BENCH)("Messung Schnitt/Ansicht alt gegen neu", async ()
return { ...pl, primitives: [...pl.primitives, ...sectionOpeningPrimitives(p, l, codes)] };
};
const newP = async () => newGen((await newCompute(p, l))!, false, { hiddenLines: l.hiddenLines, visibleCodes: codes, openings: true });
const a = await time(oldP, runs);
const skipOld = !!process.env.BENCH_NEW_ONLY;
const a = skipOld ? ([NaN, NaN] as [number, number]) : await time(oldP, runs);
const b = await time(newP, runs);
const c = await time(async () => planToRenderScene(await oldP(), 100), runs);
const c = skipOld ? ([NaN, NaN] as [number, number]) : await time(async () => planToRenderScene(await oldP(), 100), runs);
const d = await time(async () => planToRenderScene(await newP(), 100), runs);
rows.push(`${name} | ${l.id} Schnitt | ${fmt(a)} | ${fmt(b)} | ${fmt(c)} | ${fmt(d)}`);
process.stderr.write(rows[rows.length - 1] + "\n");
} else {
const a = await time(() => oldElev(p, l), runs);
const skipOld = !!process.env.BENCH_NEW_ONLY;
const a = skipOld ? ([NaN, NaN] as [number, number]) : await time(() => oldElev(p, l), runs);
const b = await time(() => newElev(p, l), runs);
const c = await time(() => planToRenderScene(oldElev(p, l)!, 100), runs);
const c = skipOld ? ([NaN, NaN] as [number, number]) : await time(() => planToRenderScene(oldElev(p, l)!, 100), runs);
const d = await time(() => planToRenderScene(newElev(p, l)!, 100), runs);
rows.push(`${name} | ${l.id} Ansicht | ${fmt(a)} | ${fmt(b)} | ${fmt(c)} | ${fmt(d)}`);
process.stderr.write(rows[rows.length - 1] + "\n");
+18
View File
@@ -171,3 +171,21 @@ export function bigSectionProject(n: number): Project {
];
return { ...p, drawingLevels: [...p.drawingLevels, ...levels] };
}
/** Kachelt ein Projekt n × n (Wände, Öffnungen, Decken, Dächer, Treppen, Körper), für grosse Zufallsfälle. */
export function tileProject(s: Project, n: number, pitch = 9): Project {
const sh = (p: { x: number; y: number }, dx: number, dy: number) => ({ x: p.x + dx, y: p.y + dy });
const out: Project = { ...s, walls: [], openings: [], ceilings: [], roofs: [], stairs: [], extrudedSolids: [] };
for (let i = 0; i < n; i++) {
for (let j = 0; j < n; j++) {
const [dx, dy, sfx] = [i * pitch, j * pitch, `_${i}_${j}`];
for (const w of s.walls) out.walls.push({ ...w, id: w.id + sfx, start: sh(w.start, dx, dy), end: sh(w.end, dx, dy) });
for (const o of s.openings ?? []) out.openings!.push({ ...o, id: o.id + sfx, hostWallId: o.hostWallId + sfx });
for (const c of s.ceilings ?? []) out.ceilings!.push({ ...c, id: c.id + sfx, outline: c.outline.map((p) => sh(p, dx, dy)) });
for (const r of s.roofs ?? []) out.roofs!.push({ ...r, id: r.id + sfx, outline: r.outline.map((p) => sh(p, dx, dy)) });
for (const st of s.stairs ?? []) out.stairs!.push({ ...st, id: st.id + sfx, start: sh(st.start, dx, dy) });
for (const x of s.extrudedSolids ?? []) out.extrudedSolids!.push({ ...x, id: x.id + sfx, points: x.points.map((p) => sh(p, dx, dy)) });
}
}
return out;
}
+8 -1
View File
@@ -15,7 +15,7 @@ import type { DrawingLevel, Project } from "../model/types";
import type { CategoryDisplayResolver, Plan, Primitive } from "./generatePlan";
import { planToRenderScene } from "./toRenderScene";
import { planToSvgString } from "../export/planToSvgString";
import { bigSectionProject, randomSectionProject, rng, sectionLevels } from "./sectionParity.testing";
import { bigSectionProject, randomSectionProject, rng, sectionLevels, tileProject } from "./sectionParity.testing";
beforeAll(() => {
setWasmBytesProvider(async (name) =>
@@ -189,6 +189,13 @@ describe("Schnitt und Ansicht: Kern gleich alter TS-Fassung", () => {
console.log("Gleichheit:", stats);
}, 3_600_000);
it("Gekachelte Zufallsprojekte (4×4)", async () => {
for (let seed = 101; seed <= 100 + Number(process.env.PARITY_TILES ?? 6); seed++) {
const p = tileProject(randomSectionProject(seed), 4);
await check(p, sectionLevels(p, seed, 6), `Kacheln ${seed}`, seed);
}
}, 3_600_000);
it("Grosses Projekt (6×6)", async () => {
const p = bigSectionProject(6);
await check(p, p.drawingLevels, "big6");