refactor(scene): remove the world_offset field (P7)
Delete the world_offset field from Scene and DerivedCaches and the load-time assignment; every reader now uses a zero origin. Geometry is absolute and the double-single relative-to-eye pipeline keeps it precise, so the coarse origin is gone. world_offset_from_centers still derives local_extent_max (camera/cull span) but returns no offset. The remaining `world_offset: [f64;3]` function parameters are now always zero — dead plumbing left for a later mechanical sweep; behaviour is unchanged. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
b473f6a8cb
commit
ccc933e7b0
8 changed files with 61 additions and 68 deletions
|
|
@ -610,7 +610,7 @@ impl OpenCADStudio {
|
|||
// paste lands at the cursor instead of drifting by the
|
||||
// offset gap. Zero for a same-drawing paste. (#135)
|
||||
let src_wo = self.clipboard_world_offset;
|
||||
let tgt_wo = self.tabs[i].scene.world_offset;
|
||||
let tgt_wo = [0.0_f64; 3];
|
||||
let wo_corr = glam::Vec3::new(
|
||||
(tgt_wo[0] - src_wo[0]) as f32,
|
||||
(tgt_wo[1] - src_wo[1]) as f32,
|
||||
|
|
@ -1262,7 +1262,7 @@ impl OpenCADStudio {
|
|||
let entity_opt = self.tabs[i].scene.document.get_entity(handle).cloned();
|
||||
if let Some(entity) = entity_opt {
|
||||
let truck_entity = entity.to_truck_entity(&self.tabs[i].scene.document);
|
||||
let woff = self.tabs[i].scene.world_offset;
|
||||
let woff = [0.0_f64; 3];
|
||||
let result = truck_entity.and_then(|te| {
|
||||
match te.object {
|
||||
TruckObject::Contour(wire) => {
|
||||
|
|
@ -1330,7 +1330,7 @@ impl OpenCADStudio {
|
|||
let entity_opt = self.tabs[i].scene.document.get_entity(handle).cloned();
|
||||
if let Some(entity) = entity_opt {
|
||||
let truck_entity = entity.to_truck_entity(&self.tabs[i].scene.document);
|
||||
let woff = self.tabs[i].scene.world_offset;
|
||||
let woff = [0.0_f64; 3];
|
||||
let result = truck_entity.and_then(|te| {
|
||||
let wire: Option<truck_modeling::Wire> = match te.object {
|
||||
TruckObject::Contour(w) => Some(w),
|
||||
|
|
@ -1410,7 +1410,7 @@ impl OpenCADStudio {
|
|||
.get_entity(profile_handle)
|
||||
.cloned();
|
||||
let path_ent = self.tabs[i].scene.document.get_entity(path_handle).cloned();
|
||||
let woff = self.tabs[i].scene.world_offset;
|
||||
let woff = [0.0_f64; 3];
|
||||
|
||||
let result = profile_ent.zip(path_ent).and_then(|(prof_e, path_e)| {
|
||||
let prof_truck = prof_e.to_truck_entity(&self.tabs[i].scene.document)?;
|
||||
|
|
@ -1577,7 +1577,7 @@ impl OpenCADStudio {
|
|||
}
|
||||
}
|
||||
|
||||
let woff = self.tabs[i].scene.world_offset;
|
||||
let woff = [0.0_f64; 3];
|
||||
let result: Option<crate::scene::model::mesh_model::MeshModel> = (|| {
|
||||
if wires.len() < 2 {
|
||||
return None;
|
||||
|
|
|
|||
|
|
@ -540,7 +540,7 @@ impl OpenCADStudio {
|
|||
self.clipboard_centroid = super::helpers::entities_centroid(
|
||||
&self.tabs[i].scene.wire_models_for(&handles),
|
||||
);
|
||||
self.clipboard_world_offset = self.tabs[i].scene.world_offset;
|
||||
self.clipboard_world_offset = [0.0_f64; 3];
|
||||
self.clipboard = entities;
|
||||
self.clipboard_deps = super::ClipboardDeps::capture(
|
||||
&self.tabs[i].scene.document,
|
||||
|
|
@ -573,7 +573,7 @@ impl OpenCADStudio {
|
|||
self.clipboard_centroid = super::helpers::entities_centroid(
|
||||
&self.tabs[i].scene.wire_models_for(&handles),
|
||||
);
|
||||
self.clipboard_world_offset = self.tabs[i].scene.world_offset;
|
||||
self.clipboard_world_offset = [0.0_f64; 3];
|
||||
let count = entities.len();
|
||||
self.clipboard = entities;
|
||||
self.clipboard_deps = super::ClipboardDeps::capture(
|
||||
|
|
@ -601,7 +601,7 @@ impl OpenCADStudio {
|
|||
// so the ghost tracks the cursor instead of drifting by the
|
||||
// offset gap. Zero within one drawing. (#135)
|
||||
let src_wo = self.clipboard_world_offset;
|
||||
let tgt_wo = self.tabs[i].scene.world_offset;
|
||||
let tgt_wo = [0.0_f64; 3];
|
||||
let centroid = self.clipboard_centroid
|
||||
+ glam::Vec3::new(
|
||||
(src_wo[0] - tgt_wo[0]) as f32,
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ impl DocumentTab {
|
|||
return glam::Mat4::IDENTITY;
|
||||
}
|
||||
let (o, x, y, z) = self.ucs_xform().axes();
|
||||
let wo = self.scene.world_offset;
|
||||
let wo = [0.0_f64; 3];
|
||||
let origin = glam::Vec3::new(
|
||||
o.x - wo[0] as f32,
|
||||
o.y - wo[1] as f32,
|
||||
|
|
@ -236,7 +236,7 @@ impl DocumentTab {
|
|||
}
|
||||
let xf = self.ucs_xform();
|
||||
let (o, ..) = xf.axes();
|
||||
let wo = self.scene.world_offset;
|
||||
let wo = [0.0_f64; 3];
|
||||
let origin = glam::Vec3::new(
|
||||
o.x - wo[0] as f32,
|
||||
o.y - wo[1] as f32,
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ impl super::OpenCADStudio {
|
|||
let Some(ed) = self.mtext_editor.as_ref() else { return };
|
||||
let mt = ed.build_mtext();
|
||||
let entity = EntityType::MText(mt.clone());
|
||||
let woff = self.tabs[i].scene.world_offset;
|
||||
let woff = [0.0_f64; 3];
|
||||
let anno = self.tabs[i].scene.annotation_scale;
|
||||
let wires: Vec<WireModel> = tessellate::tessellate(
|
||||
&self.tabs[i].scene.document,
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ impl OpenCADStudio {
|
|||
let wo = if is_paper {
|
||||
[0.0f64; 3]
|
||||
} else {
|
||||
self.tabs[i].scene.world_offset
|
||||
[0.0_f64; 3]
|
||||
};
|
||||
let (new_handle, new_grips) = {
|
||||
let selected = self.tabs[i].scene.selected_entities();
|
||||
|
|
@ -657,7 +657,7 @@ impl OpenCADStudio {
|
|||
// DXF coordinate. Skip for paper-space entities (they use sheet mm coords).
|
||||
let is_paper = self.tabs[i].scene.current_layout != "Model";
|
||||
if !is_paper {
|
||||
let wo = self.tabs[i].scene.world_offset;
|
||||
let wo = [0.0_f64; 3];
|
||||
if wo[0] != 0.0 || wo[1] != 0.0 || wo[2] != 0.0 {
|
||||
let delta = acadrust::types::Vector3::new(wo[0], wo[1], wo[2]);
|
||||
let t = acadrust::types::Transform::from_translation(delta);
|
||||
|
|
|
|||
|
|
@ -633,7 +633,6 @@ impl OpenCADStudio {
|
|||
));
|
||||
|
||||
// Caches were built on the background thread inside open_path().
|
||||
self.tabs[i].scene.world_offset = caches.world_offset;
|
||||
self.tabs[i].scene.local_extent_max = caches.local_extent_max;
|
||||
self.tabs[i].scene.hatches = caches.hatches;
|
||||
self.tabs[i].scene.images = caches.images;
|
||||
|
|
@ -2678,7 +2677,7 @@ impl OpenCADStudio {
|
|||
// Paper-space entities use sheet coordinates (no world_offset).
|
||||
// Only add world_offset when converting local → DXF space in model space.
|
||||
let wo_vec = if self.tabs[i].scene.current_layout == "Model" {
|
||||
let wo = self.tabs[i].scene.world_offset;
|
||||
let wo = [0.0_f64; 3];
|
||||
glam::Vec3::new(wo[0] as f32, wo[1] as f32, wo[2] as f32)
|
||||
} else {
|
||||
glam::Vec3::ZERO
|
||||
|
|
@ -2930,7 +2929,7 @@ impl OpenCADStudio {
|
|||
// offset-relative frame the renderer expects (model space
|
||||
// only; paper-space entities use sheet coordinates).
|
||||
let wo_local = if self.tabs[i].scene.current_layout == "Model" {
|
||||
self.tabs[i].scene.world_offset
|
||||
[0.0_f64; 3]
|
||||
} else {
|
||||
[0.0; 3]
|
||||
};
|
||||
|
|
@ -3526,7 +3525,7 @@ impl OpenCADStudio {
|
|||
// TRIM/EXTEND/FILLET pick the wrong side on UTM-scale files.
|
||||
let pick_wcs = {
|
||||
let wo = if self.tabs[i].scene.current_layout == "Model" {
|
||||
self.tabs[i].scene.world_offset
|
||||
[0.0_f64; 3]
|
||||
} else {
|
||||
[0.0; 3]
|
||||
};
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ impl OpenCADStudio {
|
|||
(glam::Vec3::ZERO, (glam::Vec3::X, glam::Vec3::Y, glam::Vec3::Z))
|
||||
} else {
|
||||
let (o, ux, uy, uz) = tab.ucs_xform().axes();
|
||||
let wo = tab.scene.world_offset;
|
||||
let wo = [0.0_f64; 3];
|
||||
let o_wire = glam::Vec3::new(
|
||||
o.x - wo[0] as f32,
|
||||
o.y - wo[1] as f32,
|
||||
|
|
@ -901,7 +901,7 @@ impl OpenCADStudio {
|
|||
let cursor_coord = {
|
||||
let lc = tab.last_cursor_world;
|
||||
if is_model {
|
||||
let wo = tab.scene.world_offset;
|
||||
let wo = [0.0_f64; 3];
|
||||
let wcs = glam::Vec3::new(
|
||||
lc.x + wo[0] as f32,
|
||||
lc.y + wo[1] as f32,
|
||||
|
|
|
|||
Loading…
Reference in a new issue