refactor(tess): rename LegacyTess → FallbackTess

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 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-05-23 23:16:57 +03:00
commit b413fe0efe
8 changed files with 35 additions and 36 deletions

View file

@ -3,9 +3,9 @@ use glam::Vec3;
use crate::command::EntityTransform; use crate::command::EntityTransform;
use crate::entities::common::{diamond_grip, edit_prop as edit, parse_f64, ro_prop as ro}; 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::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; use crate::scene::wire_model::SnapHint;
fn properties(h: &Hatch) -> PropSection { fn properties(h: &Hatch) -> PropSection {
@ -350,8 +350,8 @@ impl Grippable for Hatch {
} }
} }
impl LegacyTess for Hatch { impl FallbackTess for Hatch {
fn legacy_geometry(&self, world_offset: [f64; 3]) -> LegacyGeometry { fn fallback_geometry(&self, world_offset: [f64; 3]) -> FallbackGeometry {
let [ox, oy, oz] = world_offset; let [ox, oy, oz] = world_offset;
let normal = (self.normal.x, self.normal.y, self.normal.z); let normal = (self.normal.x, self.normal.y, self.normal.z);
// Convert a 2D OCS hatch boundary point to WCS, then subtract world_offset. // Convert a 2D OCS hatch boundary point to WCS, then subtract world_offset.

View file

@ -119,8 +119,8 @@ impl Transformable for Insert {
} }
} }
impl crate::entities::traits::LegacyTess for Insert { impl crate::entities::traits::FallbackTess for Insert {
fn legacy_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::LegacyGeometry { fn fallback_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::FallbackGeometry {
let [ox, oy, oz] = world_offset; let [ox, oy, oz] = world_offset;
let ip = Vec3::new( let ip = Vec3::new(
(self.insert_point.x - ox) as f32, (self.insert_point.x - ox) as f32,

View file

@ -202,8 +202,8 @@ impl Transformable for Ole2Frame {
} }
} }
impl crate::entities::traits::LegacyTess for Ole2Frame { impl crate::entities::traits::FallbackTess for Ole2Frame {
fn legacy_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::LegacyGeometry { fn fallback_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::FallbackGeometry {
// OLE objects carry a bounding rectangle in model space. // OLE objects carry a bounding rectangle in model space.
// Render a simple X-through-rectangle placeholder. // Render a simple X-through-rectangle placeholder.
let [ox, oy, oz] = world_offset; let [ox, oy, oz] = world_offset;

View file

@ -3,18 +3,18 @@ use acadrust::{CadDocument, EntityType};
use crate::command::EntityTransform; use crate::command::EntityTransform;
use crate::scene::acad_to_truck::TruckEntity; use crate::scene::acad_to_truck::TruckEntity;
use crate::scene::object::{GripApply, GripDef, PropSection}; use crate::scene::object::{GripApply, GripDef, PropSection};
use crate::scene::tess_util::LegacyGeometry; use crate::scene::tess_util::FallbackGeometry;
pub trait TruckConvertible { pub trait TruckConvertible {
fn to_truck(&self, document: &CadDocument) -> Option<TruckEntity>; fn to_truck(&self, document: &CadDocument) -> Option<TruckEntity>;
} }
/// Legacy fallback geometry for entities not covered by the truck /// Fallback geometry for entities not routed through the truck topology
/// topology pipeline (Viewport, Insert, Hatch outline, Ole2Frame, …). /// pipeline (Viewport, Insert, Hatch outline, Ole2Frame). Returns
/// Returns world-offset-relative `f32` points + snap/key vertices the /// world-offset-relative `f32` points + snap/key vertices the
/// dispatcher wraps into a `WireModel`. /// dispatcher wraps into a `WireModel`.
pub trait LegacyTess { pub trait FallbackTess {
fn legacy_geometry(&self, world_offset: [f64; 3]) -> LegacyGeometry; fn fallback_geometry(&self, world_offset: [f64; 3]) -> FallbackGeometry;
} }
pub trait Grippable { pub trait Grippable {

View file

@ -567,8 +567,8 @@ impl Transformable for Viewport {
} }
} }
impl crate::entities::traits::LegacyTess for Viewport { impl crate::entities::traits::FallbackTess for Viewport {
fn legacy_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::LegacyGeometry { fn fallback_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::FallbackGeometry {
let [ox, oy, oz] = world_offset; let [ox, oy, oz] = world_offset;
let cx = (self.center.x - ox) as f32; let cx = (self.center.x - ox) as f32;
let cy = (self.center.y - oy) as f32; let cy = (self.center.y - oy) as f32;

View file

@ -1275,7 +1275,7 @@ impl Scene {
return false; return false;
} }
// Block/BlockEnd are block-defn sentinels, not drawable geometry. // 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 // arm and emit a 1-unit phantom segment at world_offset that
// poisons fit_all and shows up in selection. // poisons fit_all and shows up in selection.
if matches!(e, EntityType::Block(_) | EntityType::BlockEnd(_)) { if matches!(e, EntityType::Block(_) | EntityType::BlockEnd(_)) {

View file

@ -10,14 +10,13 @@ use glam::Vec3;
use crate::scene::wire_model::{SnapHint, TangentGeom, WireModel}; use crate::scene::wire_model::{SnapHint, TangentGeom, WireModel};
/// Output of the legacy per-entity geometry path used by entities not /// Output of the fallback per-entity geometry path used by entities not
/// (yet) covered by the truck topology pipeline (Viewport, Insert, /// covered by the truck topology pipeline (Viewport, Insert, Hatch
/// Hatch outline, Ole2Frame, …). Tuple form preserved to avoid /// outline, Ole2Frame). Tuple form preserved to avoid touching every
/// touching every callsite when the dispatcher wraps these into a /// callsite when the dispatcher wraps these into a WireModel.
/// WireModel.
/// ///
/// Layout: `(points, snap_pts, tangent_geoms, key_vertices)`. /// Layout: `(points, snap_pts, tangent_geoms, key_vertices)`.
pub type LegacyGeometry = ( pub type FallbackGeometry = (
Vec<[f32; 3]>, Vec<[f32; 3]>,
Vec<(Vec3, SnapHint)>, Vec<(Vec3, SnapHint)>,
Vec<TangentGeom>, Vec<TangentGeom>,

View file

@ -10,8 +10,8 @@
// TruckTessResult::Mesh → MeshModel // TruckTessResult::Mesh → MeshModel
// TruckObject::Text → one WireModel per glyph stroke (elevation from entity Z) // TruckObject::Text → one WireModel per glyph stroke (elevation from entity Z)
// //
// Entities not handled by acad_to_truck (Viewport, Hatch, …) are tessellated // Entities not handled by acad_to_truck (Viewport, Insert, Hatch, Ole2Frame)
// by the legacy geometry() path so nothing regresses. // are tessellated by the FallbackTess fallback_geometry() path.
use crate::entities::leader::LeaderTess; use crate::entities::leader::LeaderTess;
use acadrust::types::Color as AcadColor; use acadrust::types::Color as AcadColor;
@ -428,8 +428,8 @@ pub fn tessellate(
} }
} }
// ── Legacy fallback for Viewport and other unhandled types ──────────── // ── Fallback for Viewport / Insert / Hatch / Ole2Frame ────────────────
let (points, snap_pts, tangent_geoms, key_vertices) = legacy_geometry(entity, world_offset); let (points, snap_pts, tangent_geoms, key_vertices) = fallback_geometry(entity, world_offset);
vec![WireModel { vec![WireModel {
name, name,
points, 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 // 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. // function stays as the dispatcher used by the main `tessellate()` path.
use crate::entities::traits::LegacyTess; use crate::entities::traits::FallbackTess;
use crate::scene::tess_util::LegacyGeometry as Geometry; 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 { match entity {
EntityType::Viewport(vp) => vp.legacy_geometry(world_offset), EntityType::Viewport(vp) => vp.fallback_geometry(world_offset),
EntityType::Insert(ins) => ins.legacy_geometry(world_offset), EntityType::Insert(ins) => ins.fallback_geometry(world_offset),
EntityType::Hatch(h) => h.legacy_geometry(world_offset), EntityType::Hatch(h) => h.fallback_geometry(world_offset),
EntityType::Ole2Frame(ole) => ole.legacy_geometry(world_offset), EntityType::Ole2Frame(ole) => ole.fallback_geometry(world_offset),
_ => { _ => {
let s = 0.5_f32; let s = 0.5_f32;
(vec![[-s, 0.0, 0.0], [s, 0.0, 0.0]], vec![], vec![], vec![]) (vec![[-s, 0.0, 0.0], [s, 0.0, 0.0]], vec![], vec![], vec![])