forked from 1b-agent/opencadstudio-upstream
feat(mline): GPU-dash multiline elements with shared A-type alignment
MLINE dashed elements were fully CPU-expanded (apply_along) — one wire per dash — to keep the parallel lines in phase. Move pure-dash elements onto the GPU dash shader and end-align every element to the multiline's centre-line so they share one interior phase. - wire_distances now accumulates arc-length from the double-single (high+low) points, so the dash phase stays precise at UTM coordinates. f32-high-only deltas quantised ~0.1 there and drifted the parallel lines apart — the original reason MLINE dashes were CPU-side. - New WireModel.dash_align_end carries a shared begin/end dash length. The shader uses it as align_end for every parallel element (the interior phase depends on align_end, not the wire's own length) while align_total stays the element's own length, so each still ends on a dash at its own endpoint. - MLINE tessellation derives that length once from the centre-line, routes pure dash/space/dot elements to the GPU pattern and text-bearing elements to apply_along. - apply_along gained an "A"-type mode (shared reference length): a solid begin/end dash and a phased interior, so its dashes — and embedded text — line up with the GPU-dashed sibling elements instead of tiling from start. Pure-dash MLINEs now cost one WireModel + pattern per element instead of N segments; single (non-MLINE) entities keep the from-start tiling unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
743dc1026d
commit
5bd683cf4e
41 files changed
+263
-14
No files matched your search
@@ -161,6 +161,7 @@ impl CadCommand for AttdefCommand {
|
||||
let d = 0.15_f32;
|
||||
Some(WireModel {
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: "attdef_preview".into(),
|
||||
points: vec![
|
||||
|
||||
@@ -137,6 +137,7 @@ impl CadCommand for MlineCommand {
|
||||
pts.push([pt.x, pt.y, pt.z]);
|
||||
Some(WireModel {
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: "mline_preview".into(),
|
||||
points: pts,
|
||||
|
||||
@@ -109,6 +109,7 @@ impl CadCommand for ImageCommand {
|
||||
|
||||
Some(WireModel {
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: "image_preview".into(),
|
||||
points: vec![p0, p1, p2, p3, p0],
|
||||
|
||||
@@ -85,6 +85,7 @@ impl CadCommand for RayCommand {
|
||||
let far = base + dir * DISPLAY_EXTENT;
|
||||
Some(WireModel {
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: "ray_preview".into(),
|
||||
points: vec![[base.x, base.y, base.z], [far.x, far.y, far.z]],
|
||||
@@ -177,6 +178,7 @@ impl CadCommand for XLineCommand {
|
||||
let far_neg = base - dir * DISPLAY_EXTENT;
|
||||
Some(WireModel {
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: "xline_preview".into(),
|
||||
points: vec![
|
||||
|
||||
@@ -90,6 +90,7 @@ impl CadCommand for RevCloudCommand {
|
||||
]);
|
||||
Some(WireModel {
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: "revcloud_preview".into(),
|
||||
points: preview_pts,
|
||||
|
||||
@@ -115,6 +115,7 @@ impl CadCommand for WipeoutCommand {
|
||||
let max = p1.max(pt);
|
||||
Some(WireModel {
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: "wipeout_preview".into(),
|
||||
points: vec![
|
||||
@@ -158,6 +159,7 @@ impl CadCommand for WipeoutCommand {
|
||||
]);
|
||||
Some(WireModel {
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: "wipeout_poly_preview".into(),
|
||||
points: pts,
|
||||
|
||||
@@ -70,6 +70,7 @@ impl CadCommand for AreaCommand {
|
||||
pts.push(f(self.points[0]));
|
||||
Some(WireModel {
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: "area_preview".into(),
|
||||
points: pts,
|
||||
|
||||
@@ -64,6 +64,7 @@ impl CadCommand for DistCommand {
|
||||
// The preview wire is purely visual, so f32 vertices are fine here.
|
||||
Some(WireModel {
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: "dist_preview".into(),
|
||||
points: vec![
|
||||
|
||||
@@ -68,6 +68,7 @@ impl MeasureGeomCommand {
|
||||
fn preview_wire(name: &str, pts: Vec<[f32; 3]>) -> WireModel {
|
||||
WireModel {
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: name.to_string(),
|
||||
points: pts,
|
||||
|
||||
@@ -3060,6 +3060,7 @@ fn collect_runs(pts: &[[f64; 2]], take: &dyn Fn([f64; 2]) -> bool, out: &mut Vec
|
||||
fn preview_wire(points: Vec<[f32; 3]>, color: [f32; 4], name: &str) -> WireModel {
|
||||
WireModel {
|
||||
dash_from_start: false,
|
||||
dash_align_end: None,
|
||||
text_verts: Vec::new(),
|
||||
name: name.into(),
|
||||
points,
|
||||
|
||||
Reference in new issue
Block a user