refactor(display): trim isolines follow-up comments

This commit is contained in:
Hakan Seven committed 2026-09-10 18:05:42 +03:00
1 parent a202a61ffe
commit 5ffbf598a9
6 files changed
+8 -91

No files matched your search

+3 -43
View File
@@ -502,23 +502,8 @@ impl OpenCADStudio {
self.command_line.push_output(crate::t!("REDRAWALL: viewports refreshed.").as_ref());
return Some(Task::none());
}
// REGEN — full model regeneration (bump_geometry: geometry_epoch AND
// block_epoch; C4). No undo, no DB mutation, so do NOT touch
// self.tabs[i].dirty — a newly opened drawing must not become
// "modified" merely because tessellation caches were invalidated (C7).
// REGENALL is functionally identical (C5).
// Rebuild tessellation caches without modifying the document.
"REGEN" | "REGENALL" => {
// Solid meshes carry the isoline count they were tessellated
// with: `add_entity_internal` and `update_entity` pass
// `header.isolines` into `tessellate_volume` and store the
// result. Bumping the geometry epoch clears the wire memo but
// never re-runs that, so changing ISOLINES left every existing
// solid showing the density it was born with, and REGEN — the
// command whose whole job is this — did not help.
//
// `populate_meshes_from_document` re-tessellates from the
// document and bumps the epoch itself, so it replaces the bump
// rather than adding to it.
self.tabs[i].scene.populate_meshes_from_document();
self.command_line.push_output(crate::t!("REGEN: regenerated model.").as_ref());
return Some(Task::none());
@@ -1903,32 +1888,13 @@ mod tests {
let _ = app.run_command_line("REGENALL");
assert!(!app.tabs[i].dirty, "REGENALL must not dirty the document either");
}
}
#[cfg(test)]
mod regen_tests {
use crate::app::OpenCADStudio;
/// A solid's mesh carries the isoline count it was tessellated with:
/// `add_entity_internal` and `update_entity` pass `header.isolines` into
/// `tessellate_volume` and store the result. REGEN used to bump the
/// geometry epoch and stop, which clears the wire memo but leaves
/// `scene.meshes` exactly as it was — reported on #1123 as "REGEN should
/// fix this, but the isolines keep visible".
///
/// Building ACIS geometry here would be out of proportion, so the mesh map
/// is seeded with a stale entry instead: REGEN must rebuild the map from
/// the document, and an entry belonging to no entity cannot survive that.
/// Bumping alone would leave it in place.
#[test]
fn regen_rebuilds_the_mesh_map_rather_than_only_bumping_the_epoch() {
let mut app = OpenCADStudio::new_for_test();
app.automation_op(r#"{"op":"new"}"#);
let i = app.active_tab;
// An entry belonging to no entity. Rebuilding the map from the document
// drops it; bumping the geometry epoch leaves it exactly where it is,
// which is the whole difference this fix turns on.
let stale = acadrust::Handle::new(0xDEAD);
app.tabs[i].scene.meshes.insert(stale, stale_mesh());
let epoch_before = app.tabs[i].scene.geometry_epoch;
@@ -1937,17 +1903,14 @@ mod regen_tests {
assert!(
!app.tabs[i].scene.meshes.contains_key(&stale),
"REGEN must rebuild the mesh map, not leave what was there",
"REGEN left a stale mesh",
);
assert_ne!(
app.tabs[i].scene.geometry_epoch, epoch_before,
"and it still has to bump the geometry epoch",
"REGEN did not bump the geometry epoch",
);
}
/// Dragging the isolines slider must not rebuild every solid's mesh on the
/// way — a drag emits a message per pixel, and the rebuild is the same work
/// REGEN does. It waits for the release, and only runs if the value moved.
#[test]
fn the_isolines_slider_rebuilds_once_on_release_and_not_while_dragging() {
use crate::app::Message;
@@ -1978,8 +1941,6 @@ mod regen_tests {
"releasing after a change rebuilds them",
);
// A release with nothing changed since the last one is a click that
// moved nothing, and must not pay for a rebuild.
let stale = seed(&mut app, i);
let _ = app.update(Message::IsolinesChanged(0));
let _ = app.update(Message::IsolinesReleased);
@@ -2010,4 +1971,3 @@ mod regen_tests {
}
}
}