Merge remote-tracking branch 'origin/main' into codex/pointcloud-attach

# Conflicts:
#	Cargo.lock
This commit is contained in:
ramox81 committed 2026-09-30 09:15:26 +03:00
commit 3afd547e28
37 files changed
+4603 -302

No files matched your search

+71 -13
View File
@@ -30,13 +30,28 @@ fn to_render(ell: &Ellipse) -> RenderEntity {
.map(crate::entities::curve::snap_from)
.unwrap_or_default();
let is_full = ell.is_full()
|| (ell.end_parameter - ell.start_parameter).abs() >= std::f64::consts::TAU - 1e-9;
let (start_param, end_param) = if is_full {
(0.0, std::f64::consts::TAU)
} else {
let s = ell.start_parameter.rem_euclid(std::f64::consts::TAU);
let raw = ell.end_parameter - ell.start_parameter;
let sweep = if raw <= 0.0 {
raw.rem_euclid(std::f64::consts::TAU)
} else {
raw
};
(s, s + sweep)
};
let tangent = TangentGeom::PlanarEllipse {
center: [ell.center.x, ell.center.y, ell.center.z],
major_axis: [ell.major_axis.x, ell.major_axis.y, ell.major_axis.z],
normal: [ell.normal.x, ell.normal.y, ell.normal.z],
minor_axis_ratio: ell.minor_axis_ratio,
start_param: ell.start_parameter,
end_param: ell.end_parameter,
start_param,
end_param,
};
// The points come from the entity's own kernel curve and angular policy.
@@ -339,18 +354,12 @@ fn apply_grip(ell: &mut Ellipse, grip_id: usize, apply: GripApply) {
}
fn apply_transform(ell: &mut Ellipse, t: &EntityTransform) {
// The codec maps the whole ellipse — ratio, principal axes and arc
// parameters — under rotate, scale, affine and mirror alike.
crate::scene::view::transform::apply_standard_entity_transform(ell, t, |entity, p1, p2| {
crate::scene::view::transform::reflect_xy_point(
&mut entity.center.x,
&mut entity.center.y,
p1,
p2,
);
crate::scene::view::transform::reflect_xy_point(
&mut entity.major_axis.x,
&mut entity.major_axis.y,
p1,
p2,
codec::Entity::apply_mirror(
entity,
&crate::scene::view::transform::reflection_about_xy_line(p1, p2),
);
});
}
@@ -487,4 +496,53 @@ mod grip_tests {
"minor still 10 — no ballooning"
);
}
#[test]
fn test_apply_transform_negative_scale_and_rotation() {
let mut e = ell(10.0, 0.5);
e.start_parameter = 0.0;
e.end_parameter = std::f64::consts::FRAC_PI_2;
let rot = EntityTransform::Rotate {
center: DVec3::ZERO,
axis: DVec3::Z,
angle_rad: -std::f64::consts::FRAC_PI_4,
};
apply_transform(&mut e, &rot);
let scale = EntityTransform::Scale {
center: DVec3::ZERO,
factor: -1.0,
};
apply_transform(&mut e, &scale);
assert!((xy_len(&e) - 10.0).abs() < 1e-9);
assert!((e.minor_axis_ratio - 0.5).abs() < 1e-9);
assert!((e.normal.z - 1.0).abs() < 1e-9);
// Start parameter was 0, rotated by -45 then scaled by -1 (180 rotation) -> net effect
assert!(e.start_parameter >= 0.0 && e.start_parameter < std::f64::consts::TAU);
}
#[test]
fn test_apply_transform_mirror() {
let mut e = ell(10.0, 0.5);
e.start_parameter = 0.1;
e.end_parameter = 1.5;
// Mirror across Y axis (p1=(0,0,0), p2=(0,1,0))
let mirror = EntityTransform::Mirror {
p1: DVec3::ZERO,
p2: DVec3::Y,
working_normal: DVec3::Z,
};
apply_transform(&mut e, &mirror);
// Major axis reflected to (-10, 0, 0); MIRROR keeps the normal facing
// the mirrored plane and negates the parameters instead.
assert!((e.major_axis.x - (-10.0)).abs() < 1e-9);
assert!((e.normal.z - 1.0).abs() < 1e-9);
let (s, end) = (e.start_parameter, e.end_parameter);
assert!((s - (std::f64::consts::TAU - 1.5)).abs() < 1e-9, "{s}");
assert!((end - s - 1.4).abs() < 1e-9, "{end}");
}
}