mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-03 18:45:55 +00:00
Viewport culling test: each box's triangles from its mesh, not 12
SMLib meshes a 10 mm box in 108 triangles, so the hard-coded 12 a box stopped the test before it reached the culling. The expected counts are now each body's span in the scene. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SdcgEu4Lr3moCCisdZShKz
This commit is contained in:
@@ -313,15 +313,23 @@ fn bodies_out_of_the_view_are_not_drawn() {
|
||||
let scene = build_scene(&app);
|
||||
let spans: usize = scene.blocks.iter().map(|b| b.bytes.bodies.len()).sum();
|
||||
assert_eq!(spans, 2, "each body's box is kept with its block");
|
||||
// Each box's triangles as the mesher made them (12 or more, by kernel), told apart by where
|
||||
// they lie: the near box at the origin, the far one 1000 mm along x.
|
||||
let triangles = |near: bool| -> u64 {
|
||||
let spans = scene.blocks.iter().flat_map(|b| b.bytes.bodies.iter());
|
||||
spans.filter(|s| (s.bounds[0][0] < 500.0) == near).map(|s| u64::from(s.vertices.end.saturating_sub(s.vertices.start)) / 3).sum()
|
||||
};
|
||||
let (near, far) = (triangles(true), triangles(false));
|
||||
assert!(near >= 12 && far >= 12, "a box is at least two triangles a side: {near} and {far}");
|
||||
let slot: crate::gpu::SceneSlot = std::sync::Arc::new(std::sync::Mutex::new(Some(scene)));
|
||||
let none: crate::gpu::SceneSlot = std::sync::Arc::new(std::sync::Mutex::new(None));
|
||||
frames.frame(crate::scale_tests::view_frame(&app, SIZE, (1, &slot), (0, &none)));
|
||||
let both = frames.stats().triangles;
|
||||
assert_eq!(both, 24, "both boxes in view");
|
||||
assert_eq!(both, near + far, "both boxes in view");
|
||||
app.cam.target = solidcraft_engine::geom::Vec3::new(5.0, 5.0, 5.0);
|
||||
app.cam.distance = 40.0;
|
||||
frames.frame(crate::scale_tests::view_frame(&app, SIZE, (1, &slot), (0, &none)));
|
||||
assert_eq!(frames.stats().triangles, 12, "the far box is not drawn");
|
||||
assert_eq!(frames.stats().triangles, near, "the far box is not drawn");
|
||||
app.fit_view();
|
||||
frames.frame(crate::scale_tests::view_frame(&app, SIZE, (1, &slot), (0, &none)));
|
||||
assert_eq!(frames.stats().triangles, both, "and drawn again once in view");
|
||||
|
||||
@@ -22,4 +22,3 @@ solidcraft-kernel::corner_g2::tests::the_box_corner_g2_patch_is_a_closed_solid_c
|
||||
solidcraft-kernel::tests::fillet_tabbed_plate_outer_loop_and_partial_selection_after_hole the arc and tab rounds together remove 9.20067 against 9.20420 (3.8e-4 off, 1e-5 allowed)
|
||||
solidcraft-smlib::ops::tests::a_variable_round_with_a_corner_in_its_law_is_its_balls_union the two halves' rounds end on their own touch circles at the law's corner, not where they cross: 39.6456 removed against 39.5421
|
||||
solidcraft-ui-egui::timeline::tests::each_chip_finds_its_own_result main's test: its radius 20 fillet with fit reduce on a 10 mm box builds on SMLib without a reduced-radius warning, so the fixture has no warned feature (same reply on develop's kernel)
|
||||
solidcraft-ui-egui::viewport::appearance_tests::bodies_out_of_the_view_are_not_drawn main's test counts 12 triangles a box; SMLib's mesher gives a 10 mm box 108, so it stops at 216 against 24 before it reaches the culling
|
||||
|
||||
Reference in New Issue
Block a user