fix(precision): keep BLOCK base and TEXT/MTEXT insertion points in f64 (#311)

Three commit helpers narrowed a typed/picked point back to f32 before it
reached the persisted entity, so the coordinate was quantized to the f32
grid (worse at large/UTM extents):

- Scene::create_block_from_entities took the base point as glam::Vec3, so
  the block's local-space translation and the replacement INSERT's
  insert point were f32. Param is now DVec3 (matching the sibling
  define_block_from_owned_entities); the command_driver handler no longer
  downcasts with as_vec3().
- The MTEXT and TEXT in-place editors stored `pos` as Vec3 and built the
  committed insertion_point from it, quantizing a new label's position
  and re-quantizing an existing one on edit. Both `pos` fields are now
  DVec3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-12 00:34:26 +03:00
1 parent 1f89b78a7e
commit 553b91015f
5 files changed
+20 -20

No files matched your search

+7 -7
View File
@@ -10,7 +10,7 @@
use acadrust::types::Vector3;
use acadrust::{EntityType, Handle, Text};
use glam::Vec3;
use glam::DVec3;
/// Which text slot of which entity an editor session reads from and writes to.
/// `Text`/`AttDef`/`AttEnt`/`Dim`/`Tolerance` are plain (single-line box);
@@ -78,15 +78,15 @@ pub fn write_text_field(entity: &mut EntityType, field: TextEntityField, value:
true
}
fn vec3(v: Vector3) -> Vec3 {
Vec3::new(v.x as f32, v.y as f32, v.z as f32)
fn vec3(v: Vector3) -> DVec3 {
DVec3::new(v.x, v.y, v.z)
}
/// Live state of the open in-place TEXT editor. Absent (`None`) when no editor
/// is up.
pub struct TextInlineState {
/// World insertion point (WCS, same convention the committed entity uses).
pub pos: Vec3,
pub pos: DVec3,
/// The plain text being entered.
pub value: String,
/// Text height (drawing units), used when creating a new TEXT entity.
@@ -156,7 +156,7 @@ impl super::OpenCADStudio {
EntityType::MultiLeader(ml) => {
(vec3(ml.context.text_location), ml.context.text_height)
}
_ => (Vec3::ZERO, 0.25),
_ => (DVec3::ZERO, 0.25),
};
if field.is_rich() {
@@ -172,7 +172,7 @@ impl super::OpenCADStudio {
/// commit. `handle` is `Some` when editing an existing entity.
pub(super) fn open_text_inline(
&mut self,
pos: Vec3,
pos: DVec3,
handle: Option<Handle>,
initial: &str,
height: f64,
@@ -211,7 +211,7 @@ impl super::OpenCADStudio {
} else {
let mut t = Text::with_value(
&ed.value,
Vector3::new(ed.pos.x as f64, ed.pos.y as f64, ed.pos.z as f64),
Vector3::new(ed.pos.x, ed.pos.y, ed.pos.z),
)
.with_height(ed.height);
// New text inherits the document's current text style (STYLE), not