From b413fe0efe21de69a77221d85a91ebdc8da97d99 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sat, 23 May 2026 23:16:57 +0300 Subject: [PATCH] =?UTF-8?q?refactor(tess):=20rename=20LegacyTess=20?= =?UTF-8?q?=E2=86=92=20FallbackTess?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The trait isn't deprecating anything — it carries the path entities take when they're not covered by the truck topology pipeline (Viewport, Insert, Hatch outline, Ole2Frame). "Fallback" names the purpose; "Legacy" implied retirement that isn't actually on the roadmap. Same rename for LegacyGeometry → FallbackGeometry, legacy_geometry() → fallback_geometry(). Co-Authored-By: Claude Opus 4.7 --- src/entities/hatch.rs | 8 ++++---- src/entities/insert.rs | 4 ++-- src/entities/ole2frame.rs | 4 ++-- src/entities/traits.rs | 12 ++++++------ src/entities/viewport.rs | 4 ++-- src/scene/mod.rs | 2 +- src/scene/tess_util.rs | 11 +++++------ src/scene/tessellate.rs | 26 +++++++++++++------------- 8 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/entities/hatch.rs b/src/entities/hatch.rs index e3893570f..59b5c03f7 100644 --- a/src/entities/hatch.rs +++ b/src/entities/hatch.rs @@ -3,9 +3,9 @@ use glam::Vec3; use crate::command::EntityTransform; use crate::entities::common::{diamond_grip, edit_prop as edit, parse_f64, ro_prop as ro}; -use crate::entities::traits::{Grippable, LegacyTess, PropertyEditable, Transformable}; +use crate::entities::traits::{Grippable, FallbackTess, PropertyEditable, Transformable}; use crate::scene::object::{GripApply, GripDef, PropSection, PropValue, Property}; -use crate::scene::tess_util::{arc_segments, arc_signed_span, wire_chord_tol, LegacyGeometry}; +use crate::scene::tess_util::{arc_segments, arc_signed_span, wire_chord_tol, FallbackGeometry}; use crate::scene::wire_model::SnapHint; fn properties(h: &Hatch) -> PropSection { @@ -350,8 +350,8 @@ impl Grippable for Hatch { } } -impl LegacyTess for Hatch { - fn legacy_geometry(&self, world_offset: [f64; 3]) -> LegacyGeometry { +impl FallbackTess for Hatch { + fn fallback_geometry(&self, world_offset: [f64; 3]) -> FallbackGeometry { let [ox, oy, oz] = world_offset; let normal = (self.normal.x, self.normal.y, self.normal.z); // Convert a 2D OCS hatch boundary point to WCS, then subtract world_offset. diff --git a/src/entities/insert.rs b/src/entities/insert.rs index 469861573..5ca7ac6db 100644 --- a/src/entities/insert.rs +++ b/src/entities/insert.rs @@ -119,8 +119,8 @@ impl Transformable for Insert { } } -impl crate::entities::traits::LegacyTess for Insert { - fn legacy_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::LegacyGeometry { +impl crate::entities::traits::FallbackTess for Insert { + fn fallback_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::FallbackGeometry { let [ox, oy, oz] = world_offset; let ip = Vec3::new( (self.insert_point.x - ox) as f32, diff --git a/src/entities/ole2frame.rs b/src/entities/ole2frame.rs index 90822c632..52a60966f 100644 --- a/src/entities/ole2frame.rs +++ b/src/entities/ole2frame.rs @@ -202,8 +202,8 @@ impl Transformable for Ole2Frame { } } -impl crate::entities::traits::LegacyTess for Ole2Frame { - fn legacy_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::LegacyGeometry { +impl crate::entities::traits::FallbackTess for Ole2Frame { + fn fallback_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::FallbackGeometry { // OLE objects carry a bounding rectangle in model space. // Render a simple X-through-rectangle placeholder. let [ox, oy, oz] = world_offset; diff --git a/src/entities/traits.rs b/src/entities/traits.rs index 7d2336725..5cfdcf454 100644 --- a/src/entities/traits.rs +++ b/src/entities/traits.rs @@ -3,18 +3,18 @@ use acadrust::{CadDocument, EntityType}; use crate::command::EntityTransform; use crate::scene::acad_to_truck::TruckEntity; use crate::scene::object::{GripApply, GripDef, PropSection}; -use crate::scene::tess_util::LegacyGeometry; +use crate::scene::tess_util::FallbackGeometry; pub trait TruckConvertible { fn to_truck(&self, document: &CadDocument) -> Option; } -/// Legacy fallback geometry for entities not covered by the truck -/// topology pipeline (Viewport, Insert, Hatch outline, Ole2Frame, …). -/// Returns world-offset-relative `f32` points + snap/key vertices the +/// Fallback geometry for entities not routed through the truck topology +/// pipeline (Viewport, Insert, Hatch outline, Ole2Frame). Returns +/// world-offset-relative `f32` points + snap/key vertices the /// dispatcher wraps into a `WireModel`. -pub trait LegacyTess { - fn legacy_geometry(&self, world_offset: [f64; 3]) -> LegacyGeometry; +pub trait FallbackTess { + fn fallback_geometry(&self, world_offset: [f64; 3]) -> FallbackGeometry; } pub trait Grippable { diff --git a/src/entities/viewport.rs b/src/entities/viewport.rs index aaa9c81a7..deca61c47 100644 --- a/src/entities/viewport.rs +++ b/src/entities/viewport.rs @@ -567,8 +567,8 @@ impl Transformable for Viewport { } } -impl crate::entities::traits::LegacyTess for Viewport { - fn legacy_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::LegacyGeometry { +impl crate::entities::traits::FallbackTess for Viewport { + fn fallback_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::FallbackGeometry { let [ox, oy, oz] = world_offset; let cx = (self.center.x - ox) as f32; let cy = (self.center.y - oy) as f32; diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 749b64135..9a85f6498 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -1275,7 +1275,7 @@ impl Scene { return false; } // Block/BlockEnd are block-defn sentinels, not drawable geometry. - // Without this skip they fall through to legacy_geometry's `_` + // Without this skip they fall through to fallback_geometry's `_` // arm and emit a 1-unit phantom segment at world_offset that // poisons fit_all and shows up in selection. if matches!(e, EntityType::Block(_) | EntityType::BlockEnd(_)) { diff --git a/src/scene/tess_util.rs b/src/scene/tess_util.rs index 728caf2e8..c4bd703e4 100644 --- a/src/scene/tess_util.rs +++ b/src/scene/tess_util.rs @@ -10,14 +10,13 @@ use glam::Vec3; use crate::scene::wire_model::{SnapHint, TangentGeom, WireModel}; -/// Output of the legacy per-entity geometry path used by entities not -/// (yet) covered by the truck topology pipeline (Viewport, Insert, -/// Hatch outline, Ole2Frame, …). Tuple form preserved to avoid -/// touching every callsite when the dispatcher wraps these into a -/// WireModel. +/// Output of the fallback per-entity geometry path used by entities not +/// covered by the truck topology pipeline (Viewport, Insert, Hatch +/// outline, Ole2Frame). Tuple form preserved to avoid touching every +/// callsite when the dispatcher wraps these into a WireModel. /// /// Layout: `(points, snap_pts, tangent_geoms, key_vertices)`. -pub type LegacyGeometry = ( +pub type FallbackGeometry = ( Vec<[f32; 3]>, Vec<(Vec3, SnapHint)>, Vec, diff --git a/src/scene/tessellate.rs b/src/scene/tessellate.rs index f989d8080..c68be7525 100644 --- a/src/scene/tessellate.rs +++ b/src/scene/tessellate.rs @@ -10,8 +10,8 @@ // TruckTessResult::Mesh → MeshModel // TruckObject::Text → one WireModel per glyph stroke (elevation from entity Z) // -// Entities not handled by acad_to_truck (Viewport, Hatch, …) are tessellated -// by the legacy geometry() path so nothing regresses. +// Entities not handled by acad_to_truck (Viewport, Insert, Hatch, Ole2Frame) +// are tessellated by the FallbackTess fallback_geometry() path. use crate::entities::leader::LeaderTess; use acadrust::types::Color as AcadColor; @@ -428,8 +428,8 @@ pub fn tessellate( } } - // ── Legacy fallback for Viewport and other unhandled types ──────────── - let (points, snap_pts, tangent_geoms, key_vertices) = legacy_geometry(entity, world_offset); + // ── Fallback for Viewport / Insert / Hatch / Ole2Frame ──────────────── + let (points, snap_pts, tangent_geoms, key_vertices) = fallback_geometry(entity, world_offset); vec![WireModel { name, points, @@ -603,21 +603,21 @@ pub(crate) fn entity_z(entity: &EntityType) -> f32 { } } -// ── Legacy geometry (Viewport, Hatch outline, unrecognised) ─────────────── +// ── Fallback geometry (Viewport, Insert, Hatch outline, Ole2Frame) ─────── // // Per-entity blocks have moved to their respective `entities/*.rs` files -// (Viewport, Insert, Hatch, Ole2Frame) via the `LegacyTess` trait. This +// (Viewport, Insert, Hatch, Ole2Frame) via the `FallbackTess` trait. This // function stays as the dispatcher used by the main `tessellate()` path. -use crate::entities::traits::LegacyTess; -use crate::scene::tess_util::LegacyGeometry as Geometry; +use crate::entities::traits::FallbackTess; +use crate::scene::tess_util::FallbackGeometry as Geometry; -fn legacy_geometry(entity: &EntityType, world_offset: [f64; 3]) -> Geometry { +fn fallback_geometry(entity: &EntityType, world_offset: [f64; 3]) -> Geometry { match entity { - EntityType::Viewport(vp) => vp.legacy_geometry(world_offset), - EntityType::Insert(ins) => ins.legacy_geometry(world_offset), - EntityType::Hatch(h) => h.legacy_geometry(world_offset), - EntityType::Ole2Frame(ole) => ole.legacy_geometry(world_offset), + EntityType::Viewport(vp) => vp.fallback_geometry(world_offset), + EntityType::Insert(ins) => ins.fallback_geometry(world_offset), + EntityType::Hatch(h) => h.fallback_geometry(world_offset), + EntityType::Ole2Frame(ole) => ole.fallback_geometry(world_offset), _ => { let s = 0.5_f32; (vec![[-s, 0.0, 0.0], [s, 0.0, 0.0]], vec![], vec![], vec![])