fix(section): align live section wireframe and grips

This commit is contained in:
ramox81 committed 2026-09-10 10:42:19 +03:00
1 parent b19992cbcb
commit 78bbd1065a
2 files changed
+270 -15

No files matched your search

+90 -5
View File
@@ -5410,8 +5410,12 @@ impl Scene {
// changed entities into it, instead of re-cloning + re-sorting the whole
// set. Falls back to the full build below when it can't (no cache entry,
// journal un-replayable, or a structural assumption violated).
if let Some(arc) =
self.try_resident_patch(
// A live section changes the displayed wires of every intersected
// solid, even when the delta journal contains only the section entity.
// Rebuild the resident set in that case so an incremental patch cannot
// retain the source solid's uncut edge cache.
if self.active_live_section(block).is_none() {
if let Some(arc) = self.try_resident_patch(
key,
block,
bg,
@@ -5420,9 +5424,9 @@ impl Scene {
all_visible,
frozen_layers,
style_viewport,
)
{
return arc;
) {
return arc;
}
}
// Build once: full tessellation, no cull, no zoom LOD — the resident
// set is zoom-independent (GPU analytical circles/arcs/ellipses).
@@ -6996,6 +7000,48 @@ impl Scene {
Self::section_body(&body, &section.data, section.slice_depth, None)
}
/// Build a temporary entity whose wire data matches the live-section body.
/// The document entity stays unchanged so disabling the section restores
/// the complete source geometry and saving never persists the clipped body.
fn sectioned_wire_entity(
&self,
handle: Handle,
section: &LiveSection,
) -> Result<Option<EntityType>, ()> {
let Some(body) = self.sectioned_body(handle, section)? else {
return Ok(None);
};
let (_, wires, center) = self
.prepare_solid_model_display(handle, &body)
.ok_or(())?;
let mut entity = self.document.get_entity(handle).cloned().ok_or(())?;
let reference = acadrust::types::Vector3::new(center[0], center[1], center[2]);
match &mut entity {
EntityType::Solid3D(solid) => {
solid.point_of_reference = reference;
solid.wires = wires;
solid.silhouettes.clear();
}
EntityType::Surface(surface) => {
surface.point_of_reference = reference;
surface.wires = wires;
surface.silhouettes.clear();
}
EntityType::Region(region) => {
region.point_of_reference = reference;
region.wires = wires;
region.silhouettes.clear();
}
EntityType::Body(body) => {
body.point_of_reference = reference;
body.wires = wires;
body.silhouettes.clear();
}
_ => return Err(()),
}
Ok(Some(entity))
}
fn section_source_body(
&self,
handle: Handle,
@@ -9709,6 +9755,45 @@ impl Scene {
memo_misses = visible_count;
out
};
// Normal Wireframe renders the persisted entity wires, whereas shaded
// and 3D Wireframe modes render the temporary sectioned mesh. Replace
// only the displayed wire run with one tessellated from that same
// temporary body so every visual style shows the identical live cut.
if let Some(section) = self.active_live_section(block_handle) {
let handles: Vec<Handle> = self.meshes.keys().copied().collect();
for handle in handles {
let Some(source) = self.document.get_entity(handle) else {
continue;
};
if !visibility_ok(source) {
continue;
}
let replacement = match self.sectioned_wire_entity(handle, &section) {
Ok(Some(entity)) => Some(tessellate_entity(
doc,
sel,
avp,
bg,
anno,
annotation_scale_handle,
&entity,
Some(blk_ref),
view_aabb,
wpp,
paper,
)),
Ok(None) => Some(Vec::new()),
Err(()) => None,
};
let Some(replacement) = replacement else {
continue;
};
let name = handle.value().to_string();
wires.retain(|wire| wire.name != name);
wires.extend(replacement);
}
}
let build_ms = crate::perf::elapsed_ms(t_build);
// Resolve display colours for the live background. Memo hits were