diff --git a/crates/kernel/src/face_source_tests.rs b/crates/kernel/src/face_source_tests.rs index c46f0008bf..2ba51f6c18 100644 --- a/crates/kernel/src/face_source_tests.rs +++ b/crates/kernel/src/face_source_tests.rs @@ -100,7 +100,14 @@ fn construction_planes_follow_reflected_and_sheared_affine_images() { [[-1., 0., 0., 0.], [0.4, 2., 0., 0.], [0., 0.3, 1., 0.], [8., 9., 10., 1.]], ] { let placed = transform_matrix(&body, m).unwrap(); - for (original, transformed) in body.face_sources().unwrap().iter().zip(placed.face_sources().unwrap()) { + // SMLib numbers the placed faces afresh: each is matched with the face its history names. + let history = placed.history().unwrap(); + let originals = body.face_sources().unwrap(); + for (f, transformed) in placed.face_sources().unwrap().iter().enumerate() { + let [crate::history::FaceOrigin::Face { operand: 0, face }] = history.faces[f].origins.as_slice() else { + panic!("face {f} has no one origin") + }; + let original = &originals[*face]; let ( Some(FaceSource::Box { producer: a, axis: aa, high: ah, plane: ap }), Some(FaceSource::Box { producer: b, axis: ba, high: bh, plane: bp }), diff --git a/crates/kernel/src/ops.rs b/crates/kernel/src/ops.rs index fe9b33ad2d..053368f669 100644 --- a/crates/kernel/src/ops.rs +++ b/crates/kernel/src/ops.rs @@ -141,15 +141,44 @@ pub fn transform_matrix(body: &Body, m: [[f64; 4]; 4]) -> Result
{ return placed.with_history(history, &[body]); } let sources = body.transformed_sources(m)?; - let placed = match Rigid::of_matrix(&m) { + let (placed, sources, paint) = match Rigid::of_matrix(&m) { Some(motion) => { let moved = Body::from_record(body.record().moved(&motion))?; let history = History::identity(&moved); - moved.with_history(history, &[body])? + (moved.with_history(history, &[body])?, sources, body.paint().cloned()) + } + None => { + // SMLib numbers the moved body's faces afresh: each face's source and paint follow it + // by the history (a face whose origin is not known keeps no source; with no history + // the paint stays as it was). + let placed = transformed(body, &m)?; + let origin: Vec