feat(ucs): integrate coordinate systems

Route coordinate input, geometry creation, transforms, properties,\nviews, and viewport persistence through a shared working plane.\n\nRefs #484
This commit is contained in:
Hakan Seven 2026-08-04 23:17:54 +03:00
commit 657d023fb7
61 changed files with 2218 additions and 747 deletions

View file

@ -628,14 +628,34 @@ fn apply_transform(dim: &mut Dimension, t: &EntityTransform) {
EntityTransform::Translate(d) => dim.translate(acadrust::types::Vector3::new(
d.x as f64, d.y as f64, d.z as f64,
)),
EntityTransform::Rotate { center, angle_rad } => {
transform_dimension_points(dim, |pt| rotate_point(pt, *center, *angle_rad))
EntityTransform::Rotate { center, axis, angle_rad } => {
if axis.normalize_or(DVec3::Z).abs_diff_eq(DVec3::Z, 1e-10) {
transform_dimension_points(dim, |pt| rotate_point(pt, *center, *angle_rad))
} else {
crate::scene::view::transform::apply_standard_transform(
dim,
*center,
*axis,
*angle_rad,
);
}
}
EntityTransform::Scale { center, factor } => {
transform_dimension_points(dim, |pt| scale_point(pt, *center, *factor))
}
EntityTransform::Mirror { p1, p2 } => {
transform_dimension_points(dim, |pt| mirror_point(pt, *p1, *p2))
EntityTransform::Mirror { p1, p2, working_normal } => {
if working_normal.normalize_or(DVec3::Z).abs_diff_eq(DVec3::Z, 1e-10) {
transform_dimension_points(dim, |pt| mirror_point(pt, *p1, *p2))
} else {
acadrust::Entity::apply_transform(
dim,
&crate::scene::view::transform::reflection_about_working_line(
*p1,
*p2,
*working_normal,
),
);
}
}
EntityTransform::Affine(transform) => {
let old_normal = dim.base().normal;

View file

@ -1305,9 +1305,12 @@ fn entity_transform(transform: &EntityTransform) -> Transform {
EntityTransform::Translate(delta) => {
Transform::from_translation(Vector3::new(delta.x, delta.y, delta.z))
}
EntityTransform::Rotate { center, angle_rad } => {
EntityTransform::Rotate { center, axis, angle_rad } => {
Transform::from_translation(Vector3::new(-center.x, -center.y, -center.z))
.then(&Transform::from_rotation(Vector3::UNIT_Z, *angle_rad))
.then(&Transform::from_rotation(
Vector3::new(axis.x, axis.y, axis.z),
*angle_rad,
))
.then(&Transform::from_translation(Vector3::new(
center.x, center.y, center.z,
)))
@ -1316,8 +1319,12 @@ fn entity_transform(transform: &EntityTransform) -> Transform {
Vector3::new(*factor, *factor, *factor),
Vector3::new(center.x, center.y, center.z),
),
EntityTransform::Mirror { p1, p2 } => {
crate::scene::view::transform::reflection_about_xy_line(*p1, *p2)
EntityTransform::Mirror { p1, p2, working_normal } => {
crate::scene::view::transform::reflection_about_working_line(
*p1,
*p2,
*working_normal,
)
}
EntityTransform::Affine(transform) => *transform,
}

View file

@ -145,14 +145,21 @@ fn apply_transform(line: &mut Line, t: &EntityTransform) {
d.x as f64, d.y as f64, d.z as f64,
));
}
EntityTransform::Rotate { center, angle_rad } => {
crate::scene::view::transform::apply_standard_transform(line, *center, *angle_rad);
EntityTransform::Rotate { center, axis, angle_rad } => {
crate::scene::view::transform::apply_standard_transform(line, *center, *axis, *angle_rad);
}
EntityTransform::Scale { center, factor } => {
crate::scene::view::transform::apply_standard_scale(line, *center, *factor);
}
EntityTransform::Mirror { p1, p2 } => {
crate::scene::view::transform::mirror_xy_line(line, *p1, *p2);
EntityTransform::Mirror { p1, p2, working_normal } => {
acadrust::Entity::apply_transform(
line,
&crate::scene::view::transform::reflection_about_working_line(
*p1,
*p2,
*working_normal,
),
);
}
EntityTransform::Affine(transform) => {
acadrust::Entity::apply_transform(line, transform);

View file

@ -6,6 +6,7 @@
use acadrust::entities::{Underlay, UnderlayDisplayFlags};
use crate::t;
use glam::DVec3;
use crate::command::EntityTransform;
use crate::entities::common::{center_grip, edit_angle_prop as edit_angle, edit_prop as edit, ro_prop as ro, square_grip};
@ -383,7 +384,18 @@ impl Transformable for Underlay {
self.insertion_point.y += d.y as f64;
self.insertion_point.z += d.z as f64;
}
EntityTransform::Mirror { p1, p2 } => {
EntityTransform::Mirror { p1, p2, working_normal } => {
if !working_normal.normalize_or(DVec3::Z).abs_diff_eq(DVec3::Z, 1e-10) {
acadrust::Entity::apply_transform(
self,
&crate::scene::view::transform::reflection_about_working_line(
*p1,
*p2,
*working_normal,
),
);
return;
}
reflect_xy_point(
&mut self.insertion_point.x,
&mut self.insertion_point.y,
@ -408,7 +420,16 @@ impl Transformable for Underlay {
self.y_scale *= f;
self.z_scale *= f;
}
EntityTransform::Rotate { center, angle_rad } => {
EntityTransform::Rotate { center, axis, angle_rad } => {
if !axis.normalize_or(DVec3::Z).abs_diff_eq(DVec3::Z, 1e-10) {
crate::scene::view::transform::apply_standard_transform(
self,
*center,
*axis,
*angle_rad,
);
return;
}
let bx = center.x as f64;
let by = center.y as f64;
let a = *angle_rad as f64;