refactor(tess): move per-entity tessellation into entities/
Each entity's tessellation now lives alongside its definition in
entities/*.rs, attached to the entity type via a local trait:
LegacyTess — Viewport / Insert / Hatch / Ole2Frame
(fallback path for entities not on the truck pipeline)
LeaderTess — Leader
MultiLeaderTess — MultiLeader
DimensionTess — Dimension (carries its dim-only helpers too:
~1700 lines of dim_geometry, dim_text_*, format_*,
tolerance, suppression, etc.)
scene/tessellate.rs keeps only the cross-entity dispatcher plus the
shared dim machinery reused by leader/multileader/dimension
(ArrowKind, DimGeom, append_arrow, arrow_from_block, add_segment,
add_polyline, normalized_or, push_tri, color_or_inherit, entity_z,
offset_snap_pts). Cross-entity arc helpers + aci_to_rgba moved to
scene/tess_util.rs.
scene/tessellate.rs shrinks from ~3300 to 809 lines. Compile clean,
all 9 tests pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
163725ca22
commit
aadb64860d
12 changed files with 3046 additions and 2862 deletions
|
|
@ -201,3 +201,44 @@ impl Transformable for Ole2Frame {
|
|||
apply_transform(self, t);
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::entities::traits::LegacyTess for Ole2Frame {
|
||||
fn legacy_geometry(&self, world_offset: [f64; 3]) -> crate::scene::tess_util::LegacyGeometry {
|
||||
// OLE objects carry a bounding rectangle in model space.
|
||||
// Render a simple X-through-rectangle placeholder.
|
||||
let [ox, oy, oz] = world_offset;
|
||||
let x0 = (self.upper_left_corner.x - ox) as f32;
|
||||
let y0 = (self.lower_right_corner.y - oy) as f32;
|
||||
let x1 = (self.lower_right_corner.x - ox) as f32;
|
||||
let y1 = (self.upper_left_corner.y - oy) as f32;
|
||||
let z = (self.upper_left_corner.z - oz) as f32;
|
||||
if (x1 - x0).abs() < 1e-6 && (y1 - y0).abs() < 1e-6 {
|
||||
// Degenerate / unknown size — show a small cross.
|
||||
let s = 0.5_f32;
|
||||
return (
|
||||
vec![[-s, 0.0, 0.0], [s, 0.0, 0.0]],
|
||||
vec![],
|
||||
vec![],
|
||||
vec![],
|
||||
);
|
||||
}
|
||||
let pts = vec![
|
||||
// Outer rectangle
|
||||
[x0, y0, z],
|
||||
[x1, y0, z],
|
||||
[x1, y0, z],
|
||||
[x1, y1, z],
|
||||
[x1, y1, z],
|
||||
[x0, y1, z],
|
||||
[x0, y1, z],
|
||||
[x0, y0, z],
|
||||
// Diagonal X
|
||||
[x0, y0, z],
|
||||
[x1, y1, z],
|
||||
[f32::NAN, f32::NAN, f32::NAN],
|
||||
[x1, y0, z],
|
||||
[x0, y1, z],
|
||||
];
|
||||
(pts, vec![], vec![], vec![[x0, y0, z], [x1, y1, z]])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue