fix: solve concentric geometry in kernel

This commit is contained in:
Hakan Seven committed 2026-09-17 17:39:01 +03:00
1 parent 16c417f81d
commit 80f2d5fd72
11 files changed
+165 -39

No files matched your search

+19 -2
View File
@@ -204,14 +204,18 @@ fn apply_geom_prop(circle: &mut Circle, field: &str, value: &str) {
"area" if v > 0.0 => circle.radius = (v / PI).sqrt(),
"normal_x" | "normal_y" | "normal_z" => {
let center = circle.center_wcs();
let mut normal = glam::DVec3::new(circle.normal.x, circle.normal.y, circle.normal.z);
let mut normal = cadkernel::space::Vec3::new(
circle.normal.x,
circle.normal.y,
circle.normal.z,
);
match field {
"normal_x" => normal.x = v,
"normal_y" => normal.y = v,
"normal_z" => normal.z = v,
_ => {}
}
if let Some(normal) = normal.try_normalize() {
if let Some(normal) = normal.normalize() {
circle.normal = acadrust::types::Vector3::new(normal.x, normal.y, normal.z);
let (x, y, z) = crate::scene::view::transform::wcs_point_to_ocs(
(center.x, center.y, center.z),
@@ -376,6 +380,19 @@ impl crate::entities::traits::MassPropsCalc for Circle {
mod tests {
use super::*;
#[test]
fn editing_normal_preserves_world_center() {
let mut circle = Circle::from_coords(2.0, 3.0, 4.0, 5.0);
let center = circle.center_wcs();
apply_geom_prop(&mut circle, "normal_x", "1");
assert!((circle.center_wcs() - center).length() < 1.0e-9);
let normal_length =
(circle.normal.x.powi(2) + circle.normal.y.powi(2) + circle.normal.z.powi(2)).sqrt();
assert!((normal_length - 1.0).abs() < 1.0e-12);
}
#[test]
fn quadrant_grips_offer_interactive_radius() {
use crate::entities::traits::Grippable;