From 6d0408fd072b5a6d779caa80fa366e6306202db4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 09:36:04 -0800 Subject: [PATCH] 3D: say what an uncompared pair does in the sort limit's doc, and test the exact entries read MAX_LOCAL_CHECKS's doc comment said pairs not reached keep their depth order; an uncompared pair adds no constraint, and past the step limit the first face left by depth goes next only when no face can. a_list_longer_than_the_room_left_is_not_read now asserts how many list entries are read at each room size, and fails when an over-long list is counted as read. --- crates/effects/src/solids.rs | 6 ++++-- crates/effects/src/solids/tests.rs | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/effects/src/solids.rs b/crates/effects/src/solids.rs index 04685e29dc..326e9d6115 100644 --- a/crates/effects/src/solids.rs +++ b/crates/effects/src/solids.rs @@ -1181,8 +1181,10 @@ impl Placed { } /// The most pairs of faces [`local_order`] compares, together with the steps it takes to break -/// rings of them ([`drawn_in_pairs_order`]), and the most pairs [`cut_stroke_faces`] compares; the -/// pairs they have not reached by then keep the order of their depths. +/// rings of them ([`drawn_in_pairs_order`]), and the most pairs [`cut_stroke_faces`] compares. A +/// pair not compared by then adds no constraint on the order (the pairs that were compared can +/// still move its faces), and once the steps run out the first face left by depth goes next only +/// when no face can. const MAX_LOCAL_CHECKS: usize = 4_000_000; /// The polygon of `f` and the sign of its turns, when `f` is a face turned toward the viewer other diff --git a/crates/effects/src/solids/tests.rs b/crates/effects/src/solids/tests.rs index a61ec728ec..49c301dd75 100644 --- a/crates/effects/src/solids/tests.rs +++ b/crates/effects/src/solids/tests.rs @@ -1214,10 +1214,12 @@ fn a_list_longer_than_the_room_left_is_not_read() { before.extend((2..2 + wide).flat_map(|f| [(f, 1), (1, f)])); let order: Vec = (0..2 + wide).collect(); // Room for the lists (a quarter of the pairs) but not for 1's list, and room for it. - for room in [before.len().div_ceil(4), wide - 1, wide + 3] { + // With too little room only 0's one-entry list is read; with room for both, 1's list as well. + for (room, want) in [(before.len().div_ceil(4), 1), (wide - 1, 1), (wide + 3, wide + 1)] { super::LIST_ENTRIES_READ.with(|read| read.set(0)); let (drawn, taken) = in_pairs_order(&order, &before, &[], room); let read = super::LIST_ENTRIES_READ.with(|read| read.get()); + assert_eq!(read, want, "room {room}: {read} entries read, {taken} steps"); assert!(read <= taken && taken <= room, "room {room}: {read} entries read, {taken} steps"); assert_eq!(drawn.len(), order.len()); }