fix: leere Zusicherung und mutierende Ringumkehr
Die Zusicherung im Löcher-Test stand mit "or True" in meiner eigenen Fix-Vorgabe und prüfte damit nichts; ersetzt durch zwei Zusicherungen, die die Lage des Lochs im Außenring tatsächlich belegen. Im Planentwurf zu Task 7 hätte clockwise(hole).reverse() die Eingabe des Aufrufers verändert, weil clockwise() denselben Array zurückgibt, wenn der Ring schon passt. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
857121e5fb
commit
0bf2c29061
2 files changed
+10
-4
No files matched your search
@@ -1806,7 +1806,9 @@ export function flatPolygons(polygons, { y = 0, uvScale = 8 } = {}) {
|
|||||||
const pos = [], idx = [], uv = [];
|
const pos = [], idx = [], uv = [];
|
||||||
for (const raw of polygons) {
|
for (const raw of polygons) {
|
||||||
const outer = clockwise(raw[0]);
|
const outer = clockwise(raw[0]);
|
||||||
const holes = raw.slice(1).map((hole) => clockwise(hole).reverse());
|
// clockwise() gibt denselben Array zurueck, wenn der Ring schon passt — deshalb
|
||||||
|
// vor dem Umdrehen kopieren, sonst wird die Eingabe des Aufrufers veraendert.
|
||||||
|
const holes = raw.slice(1).map((hole) => [...clockwise(hole)].reverse());
|
||||||
const base = pos.length / 3;
|
const base = pos.length / 3;
|
||||||
for (const ring of [outer, ...holes]) {
|
for (const ring of [outer, ...holes]) {
|
||||||
for (const [x, z] of ring) {
|
for (const [x, z] of ring) {
|
||||||
@@ -1828,7 +1830,9 @@ export function extrudePolygons(polygons, { base = 0, top = 10, uvScale = 4, tin
|
|||||||
// Jede Fläche ist eine Liste von Ringen: Außenring zuerst, danach die Löcher.
|
// Jede Fläche ist eine Liste von Ringen: Außenring zuerst, danach die Löcher.
|
||||||
// triangulateShape erwartet die Löcher gegenläufig zum Außenring.
|
// triangulateShape erwartet die Löcher gegenläufig zum Außenring.
|
||||||
const outer = clockwise(raw[0]);
|
const outer = clockwise(raw[0]);
|
||||||
const holes = raw.slice(1).map((hole) => clockwise(hole).reverse());
|
// clockwise() gibt denselben Array zurueck, wenn der Ring schon passt — deshalb
|
||||||
|
// vor dem Umdrehen kopieren, sonst wird die Eingabe des Aufrufers veraendert.
|
||||||
|
const holes = raw.slice(1).map((hole) => [...clockwise(hole)].reverse());
|
||||||
for (const ring of [outer, ...holes]) {
|
for (const ring of [outer, ...holes]) {
|
||||||
const n = ring.length;
|
const n = ring.length;
|
||||||
for (let i = 0; i < n; i++) {
|
for (let i = 0; i < n; i++) {
|
||||||
|
|||||||
@@ -33,8 +33,10 @@ def test_polygon_holes_survive_into_the_payload():
|
|||||||
assert len(payload["land"]) == 1
|
assert len(payload["land"]) == 1
|
||||||
rings = payload["land"][0]
|
rings = payload["land"][0]
|
||||||
assert len(rings) == 2 # Aussenring und Loch
|
assert len(rings) == 2 # Aussenring und Loch
|
||||||
assert len(rings[0]) > len(rings[1]) or True
|
exterior, hole = rings
|
||||||
hole = rings[1]
|
# Das Loch liegt innerhalb des Aussenrings, nicht daneben.
|
||||||
|
assert min(x for x, _ in exterior) < min(x for x, _ in hole)
|
||||||
|
assert max(x for x, _ in exterior) > max(x for x, _ in hole)
|
||||||
assert all(0 <= x <= 250 and 0 <= z <= 250 for x, z in hole)
|
assert all(0 <= x <= 250 and 0 <= z <= 250 for x, z in hole)
|
||||||
|
|
||||||
def test_split_by_chunk_all_yields_polygons_for_a_multi_part_intersection():
|
def test_split_by_chunk_all_yields_polygons_for_a_multi_part_intersection():
|
||||||
|
|||||||
Reference in new issue
Block a user