fix: apply world_offset when committing interactively created entities
Commands receive click coordinates in local space (DXF coords minus world_offset) for camera precision. Without correction, entities were placed world_offset away from the clicked position in existing drawings that have a non-zero centroid (e.g. UTM-coordinate drawings). Re-add world_offset via acadrust::Transform::from_translation (f64 precision) in commit_entity before the entity is inserted into the DXF document. Paper-space entities are exempt as they use sheet coords. Fixes #11 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
428a115acf
commit
7b7622910c
1 changed files with 13 additions and 0 deletions
|
|
@ -295,6 +295,19 @@ impl H7CAD {
|
|||
);
|
||||
crate::scene::dispatch::apply_line_weight(&mut entity, self.ribbon.active_lineweight);
|
||||
|
||||
// Commands pick points in local space (camera coordinates with world_offset
|
||||
// already subtracted). Re-add world_offset so the entity lands at the correct
|
||||
// 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;
|
||||
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);
|
||||
entity.apply_transform(&t);
|
||||
}
|
||||
}
|
||||
|
||||
if matches!(&entity, acadrust::EntityType::Viewport(_))
|
||||
&& self.tabs[i].scene.current_layout != "Model"
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue