forked from 1b-agent/opencadstudio-upstream
refactor(snap): take an entity's snap points from its curve
Each entity built its own, and what they offered had drifted apart from what the geometry actually has: - An arc offered no quadrants at all. It now offers the ones its sweep covers, and no more. - A spline offered its control points as endpoints. For a control-point spline those are not on the curve, so the cursor landed in empty space beside the geometry. It now offers its two real ends and its midpoint, with the fit points — which are on the curve — still on offer. - An elliptical arc had no midpoint and no ends. A new SnapHint::Endpoint carries an end that cannot go in key_vertices. Consecutive entries there are taken to be joined by a straight segment and their midpoint offered, which is right for a line or a polyline and wrong for anything curved: an arc's two ends would also produce a snap out on the chord. Splines lose their key_vertices for the same reason — the chord between two fit points of a curvy spline does not run along it. A polyline's midpoints and arc-segment centres stay out of snap_pts deliberately. The engine already derives a chain's midpoints from its vertices, and a wire carrying a centre is treated as round elsewhere, which a polyline with one bulge in it is not. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
57661c5754
commit
b36e85e46e
6 files changed
+66
-51
No files matched your search
+7
-8
@@ -10,7 +10,7 @@ use crate::entities::common::{
|
||||
use crate::entities::traits::TruckConvertible;
|
||||
use crate::scene::convert::acad_to_truck::{extrusion_wall_tris, TruckEntity, TruckObject};
|
||||
use crate::scene::model::object::{GripApply, GripDef, PropSection};
|
||||
use crate::scene::model::wire_model::{SnapHint, TangentGeom};
|
||||
use crate::scene::model::wire_model::TangentGeom;
|
||||
|
||||
const TAU: f64 = std::f64::consts::TAU;
|
||||
|
||||
@@ -42,11 +42,10 @@ fn to_truck(arc: &Arc) -> TruckEntity {
|
||||
)
|
||||
};
|
||||
|
||||
let cv = glam::DVec3::new(cwx, cwy, cwz);
|
||||
// Arc-length centre — one well-defined midpoint snap. Circles and
|
||||
// ellipses (closed curves) deliberately don't emit this; see #34.
|
||||
let mid_pt_3 = arc_pt(mid_a);
|
||||
let mv = glam::DVec3::new(mid_pt_3.x, mid_pt_3.y, mid_pt_3.z);
|
||||
// Centre, ends, arc-length midpoint and the quadrants the sweep actually
|
||||
// covers, all from the entity's own curve. Circles and ellipses (closed
|
||||
// curves) deliberately emit no midpoint; see #34.
|
||||
let snap = crate::entities::curve::snap_from(&crate::entities::curve::arc_curve(arc));
|
||||
let tangent = TangentGeom::Circle {
|
||||
center: [cwx as f32, cwy as f32, cwz as f32],
|
||||
radius: r as f32,
|
||||
@@ -81,7 +80,7 @@ fn to_truck(arc: &Arc) -> TruckEntity {
|
||||
return TruckEntity {
|
||||
pick_tris: extrusion_wall_tris(&base, [t * nx, t * ny, t * nz]),
|
||||
object: TruckObject::Lines(pts),
|
||||
snap_pts: vec![(cv, SnapHint::Center), (mv, SnapHint::Midpoint)],
|
||||
snap_pts: snap.snap_pts.clone(),
|
||||
tangent_geoms: vec![tangent],
|
||||
key_vertices: vec![],
|
||||
fill_tris: vec![],
|
||||
@@ -97,7 +96,7 @@ fn to_truck(arc: &Arc) -> TruckEntity {
|
||||
TruckEntity {
|
||||
pick_tris: Vec::new(),
|
||||
object: TruckObject::Curve(edge),
|
||||
snap_pts: vec![(cv, SnapHint::Center), (mv, SnapHint::Midpoint)],
|
||||
snap_pts: snap.snap_pts.clone(),
|
||||
tangent_geoms: vec![tangent],
|
||||
key_vertices: vec![],
|
||||
fill_tris: vec![],
|
||||
|
||||
Reference in new issue
Block a user