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 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-24 18:35:02 +03:00
1 parent 02d40bd2ec
commit 56d507fd88
20 files changed
+190 -343

No files matched your search

+17 -31
View File
@@ -849,7 +849,6 @@ pub trait DimensionTess {
selected: bool,
entity_color: [f32; 4],
line_weight_px: f32,
world_offset: [f64; 3],
anno_scale: f32,
selected_set: &rustc_hash::FxHashSet<acadrust::Handle>,
active_viewport: Option<acadrust::Handle>,
@@ -867,7 +866,6 @@ impl DimensionTess for Dimension {
selected: bool,
entity_color: [f32; 4],
line_weight_px: f32,
world_offset: [f64; 3],
anno_scale: f32,
selected_set: &rustc_hash::FxHashSet<acadrust::Handle>,
active_viewport: Option<acadrust::Handle>,
@@ -882,7 +880,6 @@ impl DimensionTess for Dimension {
selected,
entity_color,
line_weight_px,
world_offset,
anno_scale,
selected_set,
active_viewport,
@@ -900,7 +897,6 @@ fn tessellate_dimension_inner(
selected: bool,
entity_color: [f32; 4],
line_weight_px: f32,
world_offset: [f64; 3],
anno_scale: f32,
// LOD hints — when present, synthesised dim text routes through the
// top-level LOD ladder (baseline / greek / full) instead of the truck
@@ -1012,7 +1008,6 @@ fn tessellate_dimension_inner(
let text_break = {
let tp = vec3_local(
dimension_text_pos_f64(dim, style, dim_txt, dim_scale),
world_offset,
);
let tw = dimension_text_value(dim, style)
.map(|t| t.chars().count() as f32 * dim_txt as f32 * 0.6)
@@ -1054,7 +1049,6 @@ fn tessellate_dimension_inner(
dim1: dimsd1,
dim2: dimsd2,
},
world_offset,
);
// DIMTMOVE = 1: when the saved text_middle_point sits far from the
@@ -1062,7 +1056,7 @@ fn tessellate_dimension_inner(
// to the dim line — no leader; =2 frees text without a leader.)
if let Some(s) = style {
if s.dimtmove == 1 {
if let Some((anchor, txt)) = dimtmove_leader_endpoints(dim, world_offset) {
if let Some((anchor, txt)) = dimtmove_leader_endpoints(dim) {
let gap = dim_txt as f32 * 0.5;
if (txt - anchor).length() > gap * 2.0 {
add_segment(&mut geom.dim_lines, anchor, txt);
@@ -1120,7 +1114,7 @@ fn tessellate_dimension_inner(
resolve_dim_color(style.map(|s| s.dimclrt).unwrap_or(0), entity_color)
};
let snap_pts = dimension_snap_pts(dim, world_offset);
let snap_pts = dimension_snap_pts(dim);
let key_vertices: Vec<[f64; 3]> = geom
.dim_lines
.iter()
@@ -1244,7 +1238,7 @@ fn tessellate_dimension_inner(
// DIMTFILL: 0=none, 1=drawing background (mask), 2=DIMTFILLCLR.
if let Some(s) = style {
if s.dimtfill == 1 || s.dimtfill == 2 {
if let Some(rect) = text_fill_rect(dim, style, dim_txt, world_offset, dim_scale) {
if let Some(rect) = text_fill_rect(dim, style, dim_txt, dim_scale) {
let fill_color = if selected {
WireModel::SELECTED
} else if s.dimtfill == 1 {
@@ -1290,7 +1284,6 @@ fn tessellate_dimension_inner(
document,
selected_set,
active_viewport,
world_offset,
bg_color,
1.0,
&synth_text_entity,
@@ -1308,7 +1301,6 @@ fn tessellate_dimension_inner(
document,
selected_set,
active_viewport,
world_offset,
bg_color,
1.0,
&tol_entity_e,
@@ -1395,13 +1387,13 @@ fn split_ext_lines(points: &[[f32; 3]]) -> (Vec<[f32; 3]>, Vec<[f32; 3]>) {
/// text_middle_point). Returns None when the dim has no saved text position
/// or has no well-defined dim-line midpoint (radius/diameter handled by
/// their own leg).
fn dimtmove_leader_endpoints(dim: &Dimension, world_offset: [f64; 3]) -> Option<(Vec3, Vec3)> {
fn dimtmove_leader_endpoints(dim: &Dimension) -> Option<(Vec3, Vec3)> {
let base = dim.base();
let txt = base.text_middle_point;
if txt.x * txt.x + txt.y * txt.y + txt.z * txt.z <= 1e-16 {
return None;
}
let lv = |v| vec3_local(v, world_offset);
let lv = |v| vec3_local(v);
let anchor = match dim {
Dimension::Linear(d) => {
let perp = Vec3::new(-(d.rotation.sin() as f32), d.rotation.cos() as f32, 0.0);
@@ -1437,7 +1429,6 @@ fn text_fill_rect(
dim: &Dimension,
style: Option<&DimStyle>,
text_height: f64,
world_offset: [f64; 3],
dim_scale: f64,
) -> Option<Vec<[f32; 3]>> {
let value = dimension_text_value(dim, style)?;
@@ -1458,7 +1449,7 @@ fn text_fill_rect(
let (sr, cr) = rot.sin_cos();
let hx = approx_w * 0.5;
let hy = approx_h * 0.5;
let [ox, oy, oz] = world_offset;
let [ox, oy, oz] = [0.0_f64; 3];
let cx = (pos.x - ox) as f32;
let cy = (pos.y - oy) as f32;
let cz = (pos.z - oz) as f32;
@@ -1503,9 +1494,8 @@ fn dimension_geometry(
arrow2: &ArrowKind,
params: DimLineParams,
suppress: SuppressFlags,
world_offset: [f64; 3],
) -> DimGeom {
let lv = |v| vec3_local(v, world_offset);
let lv = |v| vec3_local(v);
let mut g = DimGeom::new();
match dim {
Dimension::Aligned(d) => {
@@ -1547,7 +1537,7 @@ fn dimension_geometry(
Dimension::Radius(d) => {
let center = lv(d.angle_vertex);
let point = lv(d.definition_point);
let text = dimension_text_position(dim, world_offset);
let text = dimension_text_position(dim);
add_segment(&mut g.dim_lines, center, point);
// Honour leader_length: extend from the arrow tip past it
// toward the text by that distance along (text - point).
@@ -1575,7 +1565,7 @@ fn dimension_geometry(
append_arrow(&mut g, p2, normalized_or(p1 - p2, Vec3::X), arrow2);
// DIMETER leader: continue past p2 toward the text.
if d.leader_length.abs() > 1e-9 {
let text = dimension_text_position(dim, world_offset);
let text = dimension_text_position(dim);
let leader_dir = normalized_or(text - p2, p2 - p1);
add_segment(
&mut g.dim_lines,
@@ -1839,12 +1829,12 @@ fn append_angular_dimension(
}
}
fn dimension_snap_pts(dim: &Dimension, world_offset: [f64; 3]) -> Vec<(glam::DVec3, SnapHint)> {
fn dimension_snap_pts(dim: &Dimension) -> Vec<(glam::DVec3, SnapHint)> {
let lv = |v: acadrust::types::Vector3| {
glam::DVec3::new(
v.x - world_offset[0],
v.y - world_offset[1],
v.z - world_offset[2],
v.x,
v.y,
v.z,
)
};
let node = |v: acadrust::types::Vector3| (lv(v), SnapHint::Node);
@@ -2568,8 +2558,8 @@ fn swap_decimal_sep(s: &str, dsep_code: i16) -> String {
s.replace('.', &ch.to_string())
}
fn dimension_text_position(dim: &Dimension, world_offset: [f64; 3]) -> Vec3 {
let lv = |v| vec3_local(v, world_offset);
fn dimension_text_position(dim: &Dimension) -> Vec3 {
let lv = |v| vec3_local(v);
let base = dim.base();
let pos = lv(base.text_middle_point);
if pos.length_squared() > 1e-8 {
@@ -2586,12 +2576,8 @@ fn dimension_text_position(dim: &Dimension, world_offset: [f64; 3]) -> Vec3 {
}
}
fn vec3_local(v: Vector3, off: [f64; 3]) -> Vec3 {
Vec3::new(
(v.x - off[0]) as f32,
(v.y - off[1]) as f32,
(v.z - off[2]) as f32,
)
fn vec3_local(v: Vector3) -> Vec3 {
Vec3::new(v.x as f32, v.y as f32, v.z as f32)
}
/// Style-driven text anchor on the dimension line: a point on the line through
+3 -4
View File
@@ -344,14 +344,13 @@ impl Grippable for Hatch {
}
impl FallbackTess for Hatch {
fn fallback_geometry(&self, world_offset: [f64; 3]) -> FallbackGeometry {
let [ox, oy, oz] = world_offset;
fn fallback_geometry(&self) -> FallbackGeometry {
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 absolute WCS.
let to_wcs = |x: f64, y: f64| -> [f64; 3] {
let (wx, wy, wz) =
crate::scene::view::transform::ocs_point_to_wcs((x, y, self.elevation), normal);
[wx - ox, wy - oy, wz - oz]
[wx, wy, wz]
};
// Snap point at a world (f64) location, cast to the f32 snap buffer.
let snap_at = |w: [f64; 3]| Vec3::new(w[0] as f32, w[1] as f32, w[2] as f32);
+4 -8
View File
@@ -101,13 +101,11 @@ crate::impl_entity_basics!(Insert);
impl crate::entities::traits::FallbackTess for Insert {
fn fallback_geometry(
&self,
world_offset: [f64; 3],
) -> crate::scene::convert::tess_util::FallbackGeometry {
let [ox, oy, oz] = world_offset;
let (ipx, ipy, ipz) = (
self.insert_point.x - ox,
self.insert_point.y - oy,
self.insert_point.z - oz,
self.insert_point.x,
self.insert_point.y,
self.insert_point.z,
);
let ip = Vec3::new(ipx as f32, ipy as f32, ipz as f32);
let s = 0.1_f64;
@@ -139,7 +137,6 @@ pub(crate) fn append_insert_attribute_wires(
is_xref: bool,
pslt_factor: f32,
anno_scale: f32,
world_offset: [f64; 3],
) {
if ins.attributes.is_empty() {
return;
@@ -172,7 +169,7 @@ pub(crate) fn append_insert_attribute_wires(
} else {
sub_color
};
let sub_aabb = crate::scene::entity_aabb(&attr_entity, world_offset);
let sub_aabb = crate::scene::entity_aabb(&attr_entity);
let mut attr_wires = tessellate::tessellate(
document,
insert_handle,
@@ -182,7 +179,6 @@ pub(crate) fn append_insert_attribute_wires(
sub_plen * pslt_factor,
sub_pat.map(|v| v * pslt_factor),
sub_lw_px,
world_offset,
anno_scale,
None,
);
+1 -3
View File
@@ -567,7 +567,6 @@ pub trait LeaderTess {
selected: bool,
entity_color: [f32; 4],
line_weight_px: f32,
world_offset: [f64; 3],
anno_scale: f32,
) -> crate::scene::model::wire_model::WireModel;
}
@@ -580,7 +579,6 @@ impl LeaderTess for Leader {
selected: bool,
entity_color: [f32; 4],
line_weight_px: f32,
world_offset: [f64; 3],
anno_scale: f32,
) -> crate::scene::model::wire_model::WireModel {
use crate::scene::convert::tessellate::{append_arrow, arrow_from_block, ArrowKind, DimGeom};
@@ -591,7 +589,7 @@ impl LeaderTess for Leader {
entity_color
};
let name = handle.value().to_string();
let [ox, oy, oz] = world_offset;
let [ox, oy, oz] = [0.0_f64; 3];
let p3 = |v: &acadrust::types::Vector3| -> [f32; 3] {
[(v.x - ox) as f32, (v.y - oy) as f32, (v.z - oz) as f32]
};
+1 -4
View File
@@ -1069,7 +1069,6 @@ pub trait MultiLeaderTess {
selected: bool,
entity_color: [f32; 4],
line_weight_px: f32,
world_offset: [f64; 3],
anno_scale: f32,
world_per_pixel: Option<f32>,
) -> Vec<crate::scene::model::wire_model::WireModel>;
@@ -1083,7 +1082,6 @@ impl MultiLeaderTess for MultiLeader {
selected: bool,
entity_color: [f32; 4],
line_weight_px: f32,
world_offset: [f64; 3],
anno_scale: f32,
world_per_pixel: Option<f32>,
) -> Vec<crate::scene::model::wire_model::WireModel> {
@@ -1129,7 +1127,7 @@ impl MultiLeaderTess for MultiLeader {
let name = handle.value().to_string();
let nan = [f32::NAN; 3];
let [ox, oy, oz] = world_offset;
let [ox, oy, oz] = [0.0_f64; 3];
let p3 = |v: &acadrust::types::Vector3| -> [f32; 3] {
[(v.x - ox) as f32, (v.y - oy) as f32, (v.z - oz) as f32]
};
@@ -1349,7 +1347,6 @@ impl MultiLeaderTess for MultiLeader {
leader_pat_len,
leader_pat,
leader_lw_px,
world_offset,
1.0,
None,
);
+5 -7
View File
@@ -182,16 +182,14 @@ crate::impl_entity_basics!(Ole2Frame);
impl crate::entities::traits::FallbackTess for Ole2Frame {
fn fallback_geometry(
&self,
world_offset: [f64; 3],
) -> crate::scene::convert::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;
let x0 = self.upper_left_corner.x - ox;
let y0 = self.lower_right_corner.y - oy;
let x1 = self.lower_right_corner.x - ox;
let y1 = self.upper_left_corner.y - oy;
let z = self.upper_left_corner.z - oz;
let x0 = self.upper_left_corner.x;
let y0 = self.lower_right_corner.y;
let x1 = self.lower_right_corner.x;
let y1 = self.upper_left_corner.y;
let z = self.upper_left_corner.z;
if (x1 - x0).abs() < 1e-6 && (y1 - y0).abs() < 1e-6 {
// Degenerate / unknown size — show a small cross.
let s = 0.5_f64;
+1 -2
View File
@@ -344,7 +344,6 @@ pub fn tessellate_table(
selected: bool,
entity_color: [f32; 4],
line_weight_px: f32,
world_offset: [f64; 3],
) -> Vec<crate::scene::model::wire_model::WireModel> {
use crate::scene::convert::tess_util::aci_to_rgba;
use crate::scene::model::wire_model::WireModel;
@@ -355,7 +354,7 @@ pub fn tessellate_table(
return Vec::new();
}
let [ox, oy, oz] = world_offset;
let [ox, oy, oz] = [0.0_f64; 3];
let rel = |p: Vec3| -> [f32; 3] {
[
(p.x as f64 - ox) as f32,
+2 -4
View File
@@ -1702,7 +1702,6 @@ pub(crate) fn text_obb_corners_native(
pub(crate) fn text_baseline_points(
e: &EntityType,
anno_scale: f32,
world_offset: [f64; 3],
n_lines: usize,
) -> Vec<[f32; 3]> {
let Some(corners) = text_obb_corners_native(e, anno_scale, Some(n_lines)) else {
@@ -1723,7 +1722,7 @@ pub(crate) fn text_baseline_points(
return vec![];
}
let n_lines = n_lines.max(1);
let [ox, oy, oz] = world_offset;
let [ox, oy, oz] = [0.0_f64; 3];
let cast = |p: [f64; 3]| -> [f32; 3] {
[(p[0] - ox) as f32, (p[1] - oy) as f32, (p[2] - oz) as f32]
};
@@ -1763,7 +1762,6 @@ pub(crate) fn text_baseline_points(
pub(crate) fn text_greek_obb_tris(
e: &EntityType,
anno_scale: f32,
world_offset: [f64; 3],
n_lines: usize,
) -> Vec<[f32; 3]> {
let Some(corners) = text_obb_corners_native(e, anno_scale, Some(n_lines)) else {
@@ -1784,7 +1782,7 @@ pub(crate) fn text_greek_obb_tris(
return vec![];
}
let n_lines = n_lines.max(1);
let [ox, oy, oz] = world_offset;
let [ox, oy, oz] = [0.0_f64; 3];
let cast = |p: [f64; 3]| -> [f32; 3] {
[(p[0] - ox) as f32, (p[1] - oy) as f32, (p[2] - oz) as f32]
};
+4 -4
View File
@@ -12,11 +12,11 @@ pub trait TruckConvertible {
}
/// 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`.
/// pipeline (Viewport, Insert, Hatch outline, Ole2Frame). Returns absolute
/// WCS `f32` points + snap/key vertices the dispatcher wraps into a
/// `WireModel`.
pub trait FallbackTess {
fn fallback_geometry(&self, world_offset: [f64; 3]) -> FallbackGeometry;
fn fallback_geometry(&self) -> FallbackGeometry;
}
pub trait Grippable {
+3 -5
View File
@@ -548,12 +548,10 @@ crate::impl_entity_basics!(Viewport);
impl crate::entities::traits::FallbackTess for Viewport {
fn fallback_geometry(
&self,
world_offset: [f64; 3],
) -> crate::scene::convert::tess_util::FallbackGeometry {
let [ox, oy, oz] = world_offset;
let cx = self.center.x - ox;
let cy = self.center.y - oy;
let cz = self.center.z - oz;
let cx = self.center.x;
let cy = self.center.y;
let cz = self.center.z;
let hw = self.width / 2.0;
let hh = self.height / 2.0;
let pts = vec![