Construction toggle on every curve type: the selection switches as a whole (slots, polygons; to construction unless all already are), projected curves too; construction curves are drawn dashed and centerlines dash-dot; profiles update at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
1 parent
00ddaa25f5
commit
7757e6d9c7
3 files changed
+109
-9
No files matched your search
@@ -254,15 +254,55 @@ fn build_scene(app: &SolveApp) -> GpuScene {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Construction curves are dashed, centerlines dash-dot (lengths follow the grid).
|
||||
let unit = grid_step(app.cam.half_height()).0;
|
||||
for (pts, col, cons) in sketch_lines(&ss.sketch, &ss.plane, active, &ss.report.curve_determined) {
|
||||
for w in pts.windows(2) {
|
||||
sc.line(w[0].to_f32(), w[1].to_f32(), sketch_color(&tk, col), if cons { 1.2 } else { 2.0 }, active);
|
||||
let segs = if !cons {
|
||||
pts.windows(2).map(|w| (w[0], w[1])).collect()
|
||||
} else if col == colors::SKETCH_CENTERLINE {
|
||||
dashes(&pts, &[0.6 * unit, 0.15 * unit, 0.05 * unit, 0.15 * unit])
|
||||
} else {
|
||||
dashes(&pts, &[0.3 * unit, 0.2 * unit])
|
||||
};
|
||||
for (a, b) in segs {
|
||||
sc.line(a.to_f32(), b.to_f32(), sketch_color(&tk, col), if cons { 1.2 } else { 2.0 }, active);
|
||||
}
|
||||
}
|
||||
}
|
||||
sc
|
||||
}
|
||||
|
||||
/// The drawn pieces of a polyline in a dash pattern (on, off, on, off… lengths).
|
||||
pub(crate) fn dashes(pts: &[Vec3], pattern: &[f64]) -> Vec<(Vec3, Vec3)> {
|
||||
let mut out = Vec::new();
|
||||
if pattern.is_empty() || pattern.iter().any(|l| !(l.is_finite() && *l > 0.0)) {
|
||||
return pts.windows(2).map(|w| (w[0], w[1])).collect();
|
||||
}
|
||||
let (mut k, mut left) = (0usize, pattern[0]);
|
||||
for w in pts.windows(2) {
|
||||
let (mut a, b) = (w[0], w[1]);
|
||||
let mut len = (b - a).len();
|
||||
// Cap the pieces per segment so a huge zoom-out can't explode the scene.
|
||||
let mut guard = 0;
|
||||
while len > 1e-12 && guard < 10_000 {
|
||||
guard += 1;
|
||||
let step = left.min(len);
|
||||
let q = a + (b - a) * (step / len);
|
||||
if k % 2 == 0 {
|
||||
out.push((a, q));
|
||||
}
|
||||
left -= step;
|
||||
len -= step;
|
||||
a = q;
|
||||
if left <= 1e-12 {
|
||||
k = (k + 1) % pattern.len();
|
||||
left = pattern.get(k).copied().unwrap_or(1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Colour as straight (unpremultiplied) sRGBA bytes for the GPU.
|
||||
fn c4(c: Color32) -> [u8; 4] {
|
||||
c.to_srgba_unmultiplied()
|
||||
|
||||
Reference in new issue
Block a user