2026-03-22 14:56:27 +03:00
|
|
|
use acadrust::entities::Insert;
|
2026-06-21 01:52:53 +03:00
|
|
|
use acadrust::types::{Matrix3, Transform, Vector3};
|
2026-05-23 23:26:14 +03:00
|
|
|
use acadrust::{EntityType, Handle};
|
2026-03-22 14:56:27 +03:00
|
|
|
use glam::Vec3;
|
|
|
|
|
|
|
|
|
|
use crate::command::EntityTransform;
|
|
|
|
|
use crate::entities::common::{edit_prop as edit, parse_f64, ro_prop as ro, square_grip};
|
refactor(entities): collapse trait wrapper boilerplate via macro
Every entity file ended with the same three-trait wrapper block:
impl Grippable for T {
fn grips(&self) -> Vec<GripDef> { grips(self) }
fn apply_grip(&mut self, ...) { apply_grip(self, ...) }
}
impl PropertyEditable for T { ... }
impl Transformable for T { ... }
— 23 lines of pure delegation around five same-named free functions.
Replace with `crate::impl_entity_basics!(T);` (a macro in
entities/traits.rs that expands to the three trait impls).
Applied where the file already follows the free-fn delegation
convention (Arc, Circle, Ellipse, Insert, Leader, Line, LwPolyline,
MultiLeader, Ole2Frame, Point, Spline, Viewport). Files that inlined
the trait method bodies directly (Ray, XLine, Shape, Solid, Tolerance,
MLine, Mesh, Solid3D/Region/Body, Table, RasterImage, Wipeout,
Underlay, Hatch, Polyline, Polyline2D, Polyline3D, Dimension) left
alone — they already skip the indirection. Text/MText/Attribute use
the with-text-style flavour and will move once that variant is needed
beyond the existing two manual impls.
A second macro `impl_entity_basics_with_text_styles!` is included for
the text-like flavour but no entity uses it yet.
Net: -204 lines.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 17:16:06 +03:00
|
|
|
|
feat(properties): conform entity property groups to PROPERTIES.md
Rewrite each entity's property builder to the per-entity group/row spec:
the correct sections (Geometry, Misc, Text, Pattern, Lines & Arrows, Leaders,
Block, …) with the spec's rows and real computed values — Diameter,
Circumference, Area, Delta X/Y/Z, Angle, Total angle, Arc length, Radius ratio,
etc. — plus apply routing for the editable rows.
Covers ~26 entities (Line, Circle, Arc, Point, Ellipse, Spline, polylines,
Ray/XLine, Insert, Text, MText, Hatch, Leader, MultiLeader, Tolerance, Solid,
Solid3D/Region/Body, meshes, MLine, Raster/Wipeout, Underlay, Table, Viewport,
Attribute, OLE). The 3D Visualization/Material group and the full Dimension
spec are deferred (they need document access for material/dimstyle name
resolution). Rows whose data is not in the pinned acadrust revision are shown
as empty placeholders, to be filled when the dependency is bumped.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 23:03:18 +03:00
|
|
|
use crate::scene::model::object::{GripApply, GripDef, PropSection, PropValue, Property};
|
2026-06-16 11:33:46 +03:00
|
|
|
use crate::scene::model::wire_model::WireModel;
|
|
|
|
|
use crate::scene::cache::block_cache;
|
|
|
|
|
use crate::scene::convert::tessellate;
|
|
|
|
|
use crate::scene::view::render;
|
2026-03-22 14:56:27 +03:00
|
|
|
|
|
|
|
|
fn grips(ins: &Insert) -> Vec<GripDef> {
|
2026-06-21 01:52:53 +03:00
|
|
|
// `insert_point` is in the OCS defined by `normal`; the grip must sit at
|
|
|
|
|
// the world placement, so map it through the OCS. Identity for +Z.
|
|
|
|
|
let w = Matrix3::arbitrary_axis(ins.normal) * ins.insert_point;
|
|
|
|
|
vec![square_grip(0, glam::DVec3::new(w.x, w.y, w.z))]
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
|
2026-07-02 22:46:19 +03:00
|
|
|
fn properties(ins: &Insert) -> Vec<PropSection> {
|
feat(properties): conform entity property groups to PROPERTIES.md
Rewrite each entity's property builder to the per-entity group/row spec:
the correct sections (Geometry, Misc, Text, Pattern, Lines & Arrows, Leaders,
Block, …) with the spec's rows and real computed values — Diameter,
Circumference, Area, Delta X/Y/Z, Angle, Total angle, Arc length, Radius ratio,
etc. — plus apply routing for the editable rows.
Covers ~26 entities (Line, Circle, Arc, Point, Ellipse, Spline, polylines,
Ray/XLine, Insert, Text, MText, Hatch, Leader, MultiLeader, Tolerance, Solid,
Solid3D/Region/Body, meshes, MLine, Raster/Wipeout, Underlay, Table, Viewport,
Attribute, OLE). The 3D Visualization/Material group and the full Dimension
spec are deferred (they need document access for material/dimstyle name
resolution). Rows whose data is not in the pinned acadrust revision are shown
as empty placeholders, to be filled when the dependency is bumped.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 23:03:18 +03:00
|
|
|
let annotative = ins
|
|
|
|
|
.common
|
|
|
|
|
.extended_data
|
|
|
|
|
.get_record("AcAnnotativeData")
|
|
|
|
|
.is_some();
|
|
|
|
|
let attrs: Vec<Property> = ins
|
|
|
|
|
.attributes
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|a| Property {
|
|
|
|
|
label: a.tag.clone(),
|
|
|
|
|
field: "attr",
|
|
|
|
|
value: PropValue::AttrText {
|
|
|
|
|
tag: a.tag.clone(),
|
|
|
|
|
value: a.value.clone(),
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.collect();
|
2026-07-12 23:16:26 +03:00
|
|
|
let mut sections = vec![
|
feat(properties): conform entity property groups to PROPERTIES.md
Rewrite each entity's property builder to the per-entity group/row spec:
the correct sections (Geometry, Misc, Text, Pattern, Lines & Arrows, Leaders,
Block, …) with the spec's rows and real computed values — Diameter,
Circumference, Area, Delta X/Y/Z, Angle, Total angle, Arc length, Radius ratio,
etc. — plus apply routing for the editable rows.
Covers ~26 entities (Line, Circle, Arc, Point, Ellipse, Spline, polylines,
Ray/XLine, Insert, Text, MText, Hatch, Leader, MultiLeader, Tolerance, Solid,
Solid3D/Region/Body, meshes, MLine, Raster/Wipeout, Underlay, Table, Viewport,
Attribute, OLE). The 3D Visualization/Material group and the full Dimension
spec are deferred (they need document access for material/dimstyle name
resolution). Rows whose data is not in the pinned acadrust revision are shown
as empty placeholders, to be filled when the dependency is bumped.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 23:03:18 +03:00
|
|
|
PropSection {
|
|
|
|
|
title: "Geometry".into(),
|
|
|
|
|
props: vec![
|
|
|
|
|
edit("Position X", "ins_x", ins.insert_point.x),
|
|
|
|
|
edit("Position Y", "ins_y", ins.insert_point.y),
|
|
|
|
|
edit("Position Z", "ins_z", ins.insert_point.z),
|
|
|
|
|
edit("Scale X", "x_scale", ins.x_scale()),
|
|
|
|
|
edit("Scale Y", "y_scale", ins.y_scale()),
|
|
|
|
|
edit("Scale Z", "z_scale", ins.z_scale()),
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
PropSection {
|
|
|
|
|
title: "Misc".into(),
|
|
|
|
|
props: vec![
|
|
|
|
|
ro("Name", "block", ins.block_name.clone()),
|
|
|
|
|
edit("Rotation", "rotation", ins.rotation.to_degrees()),
|
|
|
|
|
ro(
|
|
|
|
|
"Annotative",
|
|
|
|
|
"annotative",
|
|
|
|
|
if annotative { "Yes" } else { "No" },
|
|
|
|
|
),
|
2026-07-12 23:16:26 +03:00
|
|
|
ro("Block Unit", "block_unit", String::new()),
|
|
|
|
|
ro("Unit factor", "unit_factor", String::new()),
|
feat(properties): conform entity property groups to PROPERTIES.md
Rewrite each entity's property builder to the per-entity group/row spec:
the correct sections (Geometry, Misc, Text, Pattern, Lines & Arrows, Leaders,
Block, …) with the spec's rows and real computed values — Diameter,
Circumference, Area, Delta X/Y/Z, Angle, Total angle, Arc length, Radius ratio,
etc. — plus apply routing for the editable rows.
Covers ~26 entities (Line, Circle, Arc, Point, Ellipse, Spline, polylines,
Ray/XLine, Insert, Text, MText, Hatch, Leader, MultiLeader, Tolerance, Solid,
Solid3D/Region/Body, meshes, MLine, Raster/Wipeout, Underlay, Table, Viewport,
Attribute, OLE). The 3D Visualization/Material group and the full Dimension
spec are deferred (they need document access for material/dimstyle name
resolution). Rows whose data is not in the pinned acadrust revision are shown
as empty placeholders, to be filled when the dependency is bumped.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 23:03:18 +03:00
|
|
|
],
|
|
|
|
|
},
|
2026-07-12 23:16:26 +03:00
|
|
|
];
|
|
|
|
|
// The Attributes group appears only when the block actually has attributes.
|
|
|
|
|
if !attrs.is_empty() {
|
|
|
|
|
sections.push(PropSection {
|
feat(properties): conform entity property groups to PROPERTIES.md
Rewrite each entity's property builder to the per-entity group/row spec:
the correct sections (Geometry, Misc, Text, Pattern, Lines & Arrows, Leaders,
Block, …) with the spec's rows and real computed values — Diameter,
Circumference, Area, Delta X/Y/Z, Angle, Total angle, Arc length, Radius ratio,
etc. — plus apply routing for the editable rows.
Covers ~26 entities (Line, Circle, Arc, Point, Ellipse, Spline, polylines,
Ray/XLine, Insert, Text, MText, Hatch, Leader, MultiLeader, Tolerance, Solid,
Solid3D/Region/Body, meshes, MLine, Raster/Wipeout, Underlay, Table, Viewport,
Attribute, OLE). The 3D Visualization/Material group and the full Dimension
spec are deferred (they need document access for material/dimstyle name
resolution). Rows whose data is not in the pinned acadrust revision are shown
as empty placeholders, to be filled when the dependency is bumped.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 23:03:18 +03:00
|
|
|
title: "Attributes".into(),
|
|
|
|
|
props: attrs,
|
2026-07-12 23:16:26 +03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
sections
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_geom_prop(ins: &mut Insert, field: &str, value: &str) {
|
|
|
|
|
let Some(v) = parse_f64(value) else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
match field {
|
2026-07-03 16:47:39 +03:00
|
|
|
"ins_x" | "ins_y" | "ins_z" => {
|
|
|
|
|
// Move the attributes by the same world delta as the insertion
|
|
|
|
|
// point so they follow the block instead of staying put (#255).
|
|
|
|
|
let ocs = Matrix3::arbitrary_axis(ins.normal);
|
|
|
|
|
let old_world = ocs * ins.insert_point;
|
|
|
|
|
match field {
|
|
|
|
|
"ins_x" => ins.insert_point.x = v,
|
|
|
|
|
"ins_y" => ins.insert_point.y = v,
|
|
|
|
|
_ => ins.insert_point.z = v,
|
|
|
|
|
}
|
|
|
|
|
let delta = ocs * ins.insert_point - old_world;
|
|
|
|
|
for att in &mut ins.attributes {
|
|
|
|
|
acadrust::Entity::translate(att, delta);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-22 14:56:27 +03:00
|
|
|
"x_scale" => ins.set_x_scale(v),
|
|
|
|
|
"y_scale" => ins.set_y_scale(v),
|
|
|
|
|
"z_scale" => ins.set_z_scale(v),
|
|
|
|
|
"rotation" => ins.rotation = v.to_radians(),
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_grip(ins: &mut Insert, _grip_id: usize, apply: GripApply) {
|
2026-06-21 01:52:53 +03:00
|
|
|
// The grip works in world space, but `insert_point` is stored in the OCS
|
|
|
|
|
// defined by `normal`. Round-trip through the OCS so dragging a block
|
|
|
|
|
// whose extrusion direction isn't +Z moves along world axes. Identity OCS
|
|
|
|
|
// for a +Z normal, so this matches the old direct assignment there.
|
|
|
|
|
let ocs = Matrix3::arbitrary_axis(ins.normal);
|
2026-07-03 16:47:39 +03:00
|
|
|
let old_world = ocs * ins.insert_point;
|
2026-06-21 01:52:53 +03:00
|
|
|
let world = match apply {
|
|
|
|
|
GripApply::Absolute(p) => Vector3::new(p.x as f64, p.y as f64, p.z as f64),
|
2026-07-03 16:47:39 +03:00
|
|
|
GripApply::Translate(d) => old_world + Vector3::new(d.x as f64, d.y as f64, d.z as f64),
|
2026-06-21 01:52:53 +03:00
|
|
|
};
|
|
|
|
|
ins.insert_point = ocs.transpose() * world;
|
2026-07-03 16:47:39 +03:00
|
|
|
// Attributes sit in world space beside the block, so move them by the same
|
|
|
|
|
// world delta — otherwise a grip-drag leaves the attribute text behind (#255).
|
|
|
|
|
let delta = world - old_world;
|
|
|
|
|
for att in &mut ins.attributes {
|
|
|
|
|
acadrust::Entity::translate(att, delta);
|
|
|
|
|
}
|
2026-03-22 14:56:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_transform(ins: &mut Insert, t: &EntityTransform) {
|
2026-06-16 11:33:46 +03:00
|
|
|
crate::scene::view::transform::apply_standard_entity_transform(ins, t, |entity, p1, p2| {
|
2026-03-22 14:56:27 +03:00
|
|
|
let dx = (p2.x - p1.x) as f64;
|
|
|
|
|
let dy = (p2.y - p1.y) as f64;
|
|
|
|
|
let len = (dx * dx + dy * dy).sqrt();
|
|
|
|
|
if len < 1e-12 {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let ux = dx / len;
|
|
|
|
|
let uy = dy / len;
|
|
|
|
|
let mirror = acadrust::types::Matrix4 {
|
|
|
|
|
m: [
|
|
|
|
|
[2.0 * ux * ux - 1.0, 2.0 * ux * uy, 0.0, 0.0],
|
|
|
|
|
[2.0 * ux * uy, 2.0 * uy * uy - 1.0, 0.0, 0.0],
|
|
|
|
|
[0.0, 0.0, 1.0, 0.0],
|
|
|
|
|
[0.0, 0.0, 0.0, 1.0],
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
let t = Transform::from_translation(Vector3::new(-(p1.x as f64), -(p1.y as f64), 0.0))
|
|
|
|
|
.then(&Transform::from_matrix(mirror))
|
2026-05-12 10:36:15 +03:00
|
|
|
.then(&Transform::from_translation(Vector3::new(
|
|
|
|
|
p1.x as f64,
|
|
|
|
|
p1.y as f64,
|
|
|
|
|
0.0,
|
|
|
|
|
)));
|
2026-03-22 14:56:27 +03:00
|
|
|
acadrust::Entity::apply_transform(entity, &t);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
refactor(entities): collapse trait wrapper boilerplate via macro
Every entity file ended with the same three-trait wrapper block:
impl Grippable for T {
fn grips(&self) -> Vec<GripDef> { grips(self) }
fn apply_grip(&mut self, ...) { apply_grip(self, ...) }
}
impl PropertyEditable for T { ... }
impl Transformable for T { ... }
— 23 lines of pure delegation around five same-named free functions.
Replace with `crate::impl_entity_basics!(T);` (a macro in
entities/traits.rs that expands to the three trait impls).
Applied where the file already follows the free-fn delegation
convention (Arc, Circle, Ellipse, Insert, Leader, Line, LwPolyline,
MultiLeader, Ole2Frame, Point, Spline, Viewport). Files that inlined
the trait method bodies directly (Ray, XLine, Shape, Solid, Tolerance,
MLine, Mesh, Solid3D/Region/Body, Table, RasterImage, Wipeout,
Underlay, Hatch, Polyline, Polyline2D, Polyline3D, Dimension) left
alone — they already skip the indirection. Text/MText/Attribute use
the with-text-style flavour and will move once that variant is needed
beyond the existing two manual impls.
A second macro `impl_entity_basics_with_text_styles!` is included for
the text-like flavour but no entity uses it yet.
Net: -204 lines.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 17:16:06 +03:00
|
|
|
crate::impl_entity_basics!(Insert);
|
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>
2026-05-23 23:12:27 +03:00
|
|
|
|
2026-05-23 23:16:57 +03:00
|
|
|
impl crate::entities::traits::FallbackTess for Insert {
|
2026-06-11 00:04:37 +03:00
|
|
|
fn fallback_geometry(
|
|
|
|
|
&self,
|
2026-06-16 11:33:46 +03:00
|
|
|
) -> crate::scene::convert::tess_util::FallbackGeometry {
|
2026-06-24 10:09:19 +03:00
|
|
|
let (ipx, ipy, ipz) = (
|
refactor: remove dead world_offset plumbing (RTE migration is complete)
Now that geometry reaches the GPU/CPU as absolute coordinates via the
double-single relative-to-eye path, world_offset is always [0,0,0]. Strip
the parameter that was threaded through the whole tessellation / block-
expansion / fallback / camera-decode chain and the ExpandCtx field that
carried it — ~340 references across 20 files, all subtracting zero.
- truck_tess: to_local / to_local_low / tessellate_* drop the offset arg;
to_local is now a pure double-single split.
- tessellate: offset_to_ds → points_to_ds (pure DS split); tessellate(),
tessellate_entity(), fallback_geometry(), solid_wire_fallback(),
entity_aabb(), expand_insert(), expand_block_meshes(), the dimension
helpers (vec3_local, dimension_snap_pts, …), text_support, leader,
multileader, image_model, xclip and camera_from_view all lose the param.
- block_cache: ExpandCtx loses its world_offset field.
- Remove the now-dead offset_snap_pts and the unused set_grid_snap.
Behaviour is unchanged (the offset was zero everywhere); the compiler
verifies every call site.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 18:35:02 +03:00
|
|
|
self.insert_point.x,
|
|
|
|
|
self.insert_point.y,
|
|
|
|
|
self.insert_point.z,
|
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>
2026-05-23 23:12:27 +03:00
|
|
|
);
|
2026-06-24 10:09:19 +03:00
|
|
|
let ip = Vec3::new(ipx as f32, ipy as f32, ipz as f32);
|
|
|
|
|
let s = 0.1_f64;
|
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>
2026-05-23 23:12:27 +03:00
|
|
|
let pts = vec![
|
2026-06-24 10:09:19 +03:00
|
|
|
[ipx - s, ipy, ipz],
|
|
|
|
|
[ipx + s, ipy, ipz],
|
|
|
|
|
[ipx, ipy - s, ipz],
|
|
|
|
|
[ipx, ipy + s, ipz],
|
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>
2026-05-23 23:12:27 +03:00
|
|
|
];
|
|
|
|
|
(
|
|
|
|
|
pts,
|
2026-06-16 11:33:46 +03:00
|
|
|
vec![(ip, crate::scene::model::wire_model::SnapHint::Insertion)],
|
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>
2026-05-23 23:12:27 +03:00
|
|
|
vec![],
|
|
|
|
|
vec![],
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-23 23:26:14 +03:00
|
|
|
pub(crate) fn append_insert_attribute_wires(
|
|
|
|
|
wires: &mut Vec<WireModel>,
|
|
|
|
|
document: &acadrust::CadDocument,
|
|
|
|
|
ins: &acadrust::entities::Insert,
|
|
|
|
|
insert_handle: Handle,
|
|
|
|
|
sel: bool,
|
|
|
|
|
ins_color: [f32; 4],
|
|
|
|
|
ins_pat_len: f32,
|
|
|
|
|
ins_pat: [f32; 8],
|
|
|
|
|
ins_lw_px: f32,
|
fix(blocks): layer-0 children inherit the block instance layer (#221)
Entities inside a block definition that sit on layer "0" must take on the
properties of the layer the block reference is inserted on; every other
layer is "sticky" and keeps its own identity. OpenCADStudio resolved a
block child's ByLayer color/linetype/lineweight against the child's own
layer in all cases, so layer-0 content stayed layer-0 (white) instead of
inheriting the instance layer.
Resolution now follows the standard rule for block children — explicit
wins, then ByBlock → the insert's own style, then layer-0 + ByLayer →
the insert's *layer* style, else the child's own layer. The insert's
layer style threads through the whole block-expansion chain (and chains
correctly through nested inserts), with the child's own transparency
preserved.
Covered across every block-render path:
- wires (line/arc/circle/polyline/text) via the block cache + the
explode fallback + insert attributes
- hatch / solid fills (also fixes the PDF/print export path)
- 3D solid block children (per-instance mesh recolor)
- Dimension / Table baked-block sub-entities
New shared helpers in scene::view::render: InheritStyle, layer_render_style,
lineweight_to_px; render_style_for_block_sub gained the layer-0 branch.
Adds unit tests covering the layer-0, sticky-layer, ByBlock, explicit and
transparency cases.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 17:24:04 +03:00
|
|
|
ins_layer: render::InheritStyle,
|
2026-05-23 23:26:14 +03:00
|
|
|
bg_color: [f32; 4],
|
|
|
|
|
is_xref: bool,
|
|
|
|
|
pslt_factor: f32,
|
|
|
|
|
anno_scale: f32,
|
|
|
|
|
) {
|
|
|
|
|
if ins.attributes.is_empty() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// ATTMODE (header.attribute_visibility):
|
|
|
|
|
// 0 = Off — every attribute hidden
|
|
|
|
|
// 1 = Normal — honour per-attribute `invisible` flag (default)
|
|
|
|
|
// 2 = On — every attribute forced visible, ignoring its flag
|
|
|
|
|
let attmode = document.header.attribute_visibility;
|
|
|
|
|
if attmode == 0 {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-07-12 23:16:26 +03:00
|
|
|
// An annotative block scales as ONE uniform unit about its insertion point;
|
|
|
|
|
// its attributes are carried by that scale (AutoCAD even forbids annotative
|
|
|
|
|
// attributes inside annotative blocks, to avoid double-scaling). So pre-scale
|
|
|
|
|
// the annotative attribute about the insertion point and tessellate it at a
|
|
|
|
|
// neutral 1.0 — the text path must never scale it a second time.
|
|
|
|
|
let annotative = ins
|
|
|
|
|
.common
|
|
|
|
|
.extended_data
|
|
|
|
|
.get_record("AcAnnotativeData")
|
|
|
|
|
.is_some();
|
|
|
|
|
let block_scale = if annotative { anno_scale as f64 } else { 1.0 };
|
|
|
|
|
let ip = ins.insert_point;
|
|
|
|
|
let scale_about = |q: acadrust::types::Vector3| {
|
|
|
|
|
acadrust::types::Vector3::new(
|
|
|
|
|
ip.x + (q.x - ip.x) * block_scale,
|
|
|
|
|
ip.y + (q.y - ip.y) * block_scale,
|
|
|
|
|
ip.z + (q.z - ip.z) * block_scale,
|
|
|
|
|
)
|
|
|
|
|
};
|
2026-05-23 23:26:14 +03:00
|
|
|
for attr in &ins.attributes {
|
|
|
|
|
let per_attr_hidden = attr.common.invisible || attr.flags.invisible;
|
|
|
|
|
if attmode == 1 && per_attr_hidden {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2026-07-12 23:16:26 +03:00
|
|
|
let attr_entity = EntityType::AttributeEntity({
|
|
|
|
|
let mut a = attr.clone();
|
|
|
|
|
if (block_scale - 1.0).abs() > 1e-6 {
|
|
|
|
|
a.height *= block_scale;
|
|
|
|
|
a.insertion_point = scale_about(a.insertion_point);
|
|
|
|
|
a.alignment_point = scale_about(a.alignment_point);
|
|
|
|
|
}
|
|
|
|
|
a
|
|
|
|
|
});
|
2026-06-11 00:04:37 +03:00
|
|
|
let (sub_color, sub_plen, sub_pat, sub_lw_px, sub_aci) = render::render_style_for_block_sub(
|
|
|
|
|
document,
|
|
|
|
|
&attr_entity,
|
|
|
|
|
ins_color,
|
|
|
|
|
ins_pat_len,
|
|
|
|
|
ins_pat,
|
|
|
|
|
ins_lw_px,
|
fix(blocks): layer-0 children inherit the block instance layer (#221)
Entities inside a block definition that sit on layer "0" must take on the
properties of the layer the block reference is inserted on; every other
layer is "sticky" and keeps its own identity. OpenCADStudio resolved a
block child's ByLayer color/linetype/lineweight against the child's own
layer in all cases, so layer-0 content stayed layer-0 (white) instead of
inheriting the instance layer.
Resolution now follows the standard rule for block children — explicit
wins, then ByBlock → the insert's own style, then layer-0 + ByLayer →
the insert's *layer* style, else the child's own layer. The insert's
layer style threads through the whole block-expansion chain (and chains
correctly through nested inserts), with the child's own transparency
preserved.
Covered across every block-render path:
- wires (line/arc/circle/polyline/text) via the block cache + the
explode fallback + insert attributes
- hatch / solid fills (also fixes the PDF/print export path)
- 3D solid block children (per-instance mesh recolor)
- Dimension / Table baked-block sub-entities
New shared helpers in scene::view::render: InheritStyle, layer_render_style,
lineweight_to_px; render_style_for_block_sub gained the layer-0 branch.
Adds unit tests covering the layer-0, sticky-layer, ByBlock, explicit and
transparency cases.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 17:24:04 +03:00
|
|
|
ins_layer,
|
2026-06-11 00:04:37 +03:00
|
|
|
);
|
2026-05-23 23:26:14 +03:00
|
|
|
let sub_color = render::adapt_to_bg(sub_color, bg_color);
|
|
|
|
|
let sub_color = if is_xref && !sel {
|
|
|
|
|
block_cache::fade_toward_bg(sub_color, bg_color)
|
|
|
|
|
} else {
|
|
|
|
|
sub_color
|
|
|
|
|
};
|
refactor: remove dead world_offset plumbing (RTE migration is complete)
Now that geometry reaches the GPU/CPU as absolute coordinates via the
double-single relative-to-eye path, world_offset is always [0,0,0]. Strip
the parameter that was threaded through the whole tessellation / block-
expansion / fallback / camera-decode chain and the ExpandCtx field that
carried it — ~340 references across 20 files, all subtracting zero.
- truck_tess: to_local / to_local_low / tessellate_* drop the offset arg;
to_local is now a pure double-single split.
- tessellate: offset_to_ds → points_to_ds (pure DS split); tessellate(),
tessellate_entity(), fallback_geometry(), solid_wire_fallback(),
entity_aabb(), expand_insert(), expand_block_meshes(), the dimension
helpers (vec3_local, dimension_snap_pts, …), text_support, leader,
multileader, image_model, xclip and camera_from_view all lose the param.
- block_cache: ExpandCtx loses its world_offset field.
- Remove the now-dead offset_snap_pts and the unused set_grid_snap.
Behaviour is unchanged (the offset was zero everywhere); the compiler
verifies every call site.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 18:35:02 +03:00
|
|
|
let sub_aabb = crate::scene::entity_aabb(&attr_entity);
|
2026-05-23 23:26:14 +03:00
|
|
|
let mut attr_wires = tessellate::tessellate(
|
|
|
|
|
document,
|
|
|
|
|
insert_handle,
|
|
|
|
|
&attr_entity,
|
|
|
|
|
sel,
|
|
|
|
|
sub_color,
|
|
|
|
|
sub_plen * pslt_factor,
|
|
|
|
|
sub_pat.map(|v| v * pslt_factor),
|
|
|
|
|
sub_lw_px,
|
2026-07-12 23:16:26 +03:00
|
|
|
// Neutral: the attribute is already scaled as part of the block unit
|
|
|
|
|
// above, so the text path must not scale it a second time.
|
|
|
|
|
1.0,
|
2026-06-17 11:13:12 +03:00
|
|
|
None,
|
2026-07-07 17:41:16 +03:00
|
|
|
bg_color,
|
2026-07-11 10:38:41 +03:00
|
|
|
false,
|
2026-05-23 23:26:14 +03:00
|
|
|
);
|
|
|
|
|
// Use the INSERT's handle so selection / picking groups attribute
|
|
|
|
|
// text with the parent insert instead of treating it as a stray text.
|
|
|
|
|
for w in &mut attr_wires {
|
|
|
|
|
w.name = insert_handle.value().to_string();
|
|
|
|
|
w.aci = sub_aci;
|
|
|
|
|
w.aabb = sub_aabb;
|
|
|
|
|
}
|
|
|
|
|
wires.extend(attr_wires);
|
|
|
|
|
}
|
|
|
|
|
}
|