* claim: #7225 * fix: headless pictures no longer keep the previous picture's highlight Capturer::rgba_highlighted left the highlight slot empty when a picture had no highlight. The renderer keeps its last highlight scene while the slot is empty, so a selected edge's band drawn for one picture showed in the next one on the same capturer. The depth tests share their capturers across test threads, so they failed at random: an edge "192 of 612 px drawn", a washer showing through its plate, a cut showing what lies behind it. A picture now always gets a highlight scene of its own, empty without one. Clearing the leak showed that a_selected_edge_on_a_grazing_face_draws_whole passed at 88 degrees in a design of radius 30 only by counting the leaked band: its reference line lies 143 mm behind the sheet's middle, past that design's far plane, and drew nothing. The small design now holds the edge. New test: a_picture_without_a_highlight_shows_none_of_the_one_before. Full `--test depth` runs on Apple silicon: 10 of 10 failed before, 0 of 20 after.
This commit is contained in:
2 files changed
+35
-11
No files matched your search
@@ -194,10 +194,11 @@ impl Capturer {
|
||||
_ => None,
|
||||
};
|
||||
let mut frame = frame(scene, cam, [width, height], state.key, access);
|
||||
if let Some(h) = highlight {
|
||||
frame.hl_key = state.key;
|
||||
frame.hl_slot = Arc::new(Mutex::new(Some(h)));
|
||||
}
|
||||
// Always a highlight scene of the picture's own, empty without one: the renderer keeps
|
||||
// its last highlight scene while the slot is empty (as the viewport does until the next
|
||||
// is built), so the previous picture's highlight would show in this one.
|
||||
frame.hl_key = state.key;
|
||||
frame.hl_slot = Arc::new(Mutex::new(Some(highlight.unwrap_or_default())));
|
||||
let (device, queue) = (&self.device, &self.queue);
|
||||
let scopes = error_scopes(device);
|
||||
let size = wgpu::Extent3d { width, height, depth_or_array_layers: 1 };
|
||||
|
||||
@@ -189,18 +189,21 @@ fn an_edge_on_a_face_draws_whole_at_any_angle() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A selected edge's highlight from `a` to `b` on a face of normal `n`, in a highlight scene of
|
||||
/// its own: a 3 px core in a 6 px halo (`GpuScene::lifted_line`).
|
||||
fn highlight(a: Vec3, b: Vec3, n: Vec3) -> solidcraft_gpu::view::GpuScene {
|
||||
let mut sc = solidcraft_gpu::view::GpuScene::default();
|
||||
let red = sc.color([255, 0, 0, 255]);
|
||||
sc.lifted_line(a.to_f32(), b.to_f32(), red, 6.0, [n.to_f32(), n.to_f32()]);
|
||||
sc
|
||||
}
|
||||
|
||||
/// A selected edge's highlight (a 3 px core in a 6 px halo, drawn by `GpuScene::lifted_line`
|
||||
/// in the highlight scene) lying on a face seen almost edge on draws its whole width: the face
|
||||
/// no longer buries part of the band, which showed as a thin wedge instead of a line. The same
|
||||
/// band 5 mm behind a face seen square, beside faces seen square, stays hidden.
|
||||
#[test]
|
||||
fn a_selected_edge_on_a_grazing_face_draws_whole() {
|
||||
let highlight = |a: Vec3, b: Vec3, n: Vec3| {
|
||||
let mut sc = solidcraft_gpu::view::GpuScene::default();
|
||||
let red = sc.color([255, 0, 0, 255]);
|
||||
sc.lifted_line(a.to_f32(), b.to_f32(), red, 6.0, [n.to_f32(), n.to_f32()]);
|
||||
sc
|
||||
};
|
||||
let reference = |a: Vec3, b: Vec3| vec![SceneLine { points: vec![a, b], color: Rgb(255, 0, 0), alpha: 1.0, width: 6.0, on_top: true }];
|
||||
for (mode, c) in capturers() {
|
||||
for tilt in [60.0_f64, 80.0, 85.0, 88.0] {
|
||||
@@ -208,7 +211,10 @@ fn a_selected_edge_on_a_grazing_face_draws_whole() {
|
||||
let t = tr.tan();
|
||||
let n = Vec3::new(0.0, -tr.cos(), tr.sin());
|
||||
let (a, b) = (Vec3::new(-12.0, 5.0 * t, 5.0), Vec3::new(12.0, 5.0 * t, 5.0));
|
||||
for radius in [30.0, 17_000.0] {
|
||||
// The small design holds the edge, 5·tan(tilt) behind the sheet's middle: at 88° that
|
||||
// is 143 mm, past the far plane of a design of radius 30, where the reference band drew
|
||||
// nothing (the check only passed by counting a band left from another picture).
|
||||
for radius in [(5.0 * t).max(30.0), 17_000.0] {
|
||||
for fov in [0.0, 0.6] {
|
||||
let (plain, cam) = front(sheet(tr), Vec::new(), radius, fov, false);
|
||||
let (top, _) = front(sheet(tr), reference(a, b), radius, fov, false);
|
||||
@@ -231,6 +237,23 @@ fn a_selected_edge_on_a_grazing_face_draws_whole() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A picture drawn without a highlight shows none of the highlight of the picture before it. The
|
||||
/// capturer kept its last highlight scene, so a band drawn for one check showed in the next
|
||||
/// picture on the same capturer, and the checks here, which share their capturers across test
|
||||
/// threads, failed at random: an edge "192 of 612 px drawn", a washer through its plate.
|
||||
#[test]
|
||||
fn a_picture_without_a_highlight_shows_none_of_the_one_before() {
|
||||
for (mode, c) in capturers() {
|
||||
let (plain, cam) = front(sheet(0.0), Vec::new(), 30.0, 0.0, false);
|
||||
let (a, b) = (Vec3::new(-12.0, 0.0, 5.0), Vec3::new(12.0, 0.0, 5.0));
|
||||
let highlighted = c.rgba_highlighted(&plain, Some(highlight(a, b, Vec3::new(0.0, -1.0, 0.0))), &cam, 200, 200).unwrap();
|
||||
let band = pixels(&highlighted).filter(|p| red(*p)).count();
|
||||
assert!(band > 100, "{mode}: the band itself ({band} px)");
|
||||
let after = red_pixels(c, &plain, &cam);
|
||||
assert_eq!(after, 0, "{mode}: the picture after the highlighted one shows its band in {after} px");
|
||||
}
|
||||
}
|
||||
|
||||
/// An edge 0.5 mm behind a face seen square is hidden, however large the design, with a section
|
||||
/// shown or not: lines were pulled toward the eye by a share of the depth range, about 27 mm in a
|
||||
/// design 34 m across.
|
||||
|
||||
Reference in new issue
Block a user