forked from 1b-agent/opencadstudio-upstream
refactor(text): per-entity SDF text — all text kinds, selection/hover highlight
Rearchitect SDF text from a document-wide collector to per-entity production during tessellation, so each entity owns its glyph quads and composite/nested text is covered for free (no re-explosion, no per-frame document walk). - WireModel gains `text_verts`: glyph quads ride on the wire, so they are cached by the tess memo, cloned on hit, and transformed by the block expand loop exactly like `points`. - Text arm (tessellate.rs) builds the quads when SDF is on and suppresses the strokes; render gathers text_verts from the viewport wire set (`gather_text_verts`, cached on wire content id) — the old collector is removed. Covers model, dimension, table, block-internal and paper-sheet text uniformly. - MLEADER text (lays out via layout_mtext, not the Text arm) gets its own SDF branch driven by the per-run GlyphRun. - Pick box comes from the rendered glyph quads (true text extent), not entity_aabb which mis-places the box for MTEXT; composite paths no longer clobber the empty text wire's tight AABB (dim pick box hugs the text). - Selection / hover highlight via a text-highlight overlay (upload_text_ highlight, keyed on selection_generation) mirroring the selected-wire xray overlay; base glyphs stay neutral so a deselect leaves no stale tint. - Debug: env OCS_TEXT_BOX draws each run's glyph-bounds rectangle. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
fd0b8fc1d4
commit
110683f419
47 files changed
+529
-143
No files matched your search
@@ -183,6 +183,7 @@ impl CadCommand for AlignedDimensionCommand {
|
||||
}
|
||||
};
|
||||
Some(WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "dimaligned_preview".into(),
|
||||
points: vec![[p1.x, p1.y, p1.z], [p2.x, p2.y, p2.z]],
|
||||
points_low: Vec::new(),
|
||||
@@ -224,6 +225,7 @@ fn preview_aligned(p1: Vec3, p2: Vec3, dim_pt: Vec3) -> WireModel {
|
||||
// Show ext lines + dim line.
|
||||
let (d1, d2) = dim_line_endpoints(p1, p2, dim_pt);
|
||||
WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "dimaligned_preview".into(),
|
||||
points: vec![
|
||||
[p1.x, p1.y, p1.z],
|
||||
|
||||
@@ -124,6 +124,7 @@ fn v3(pt: Vec3) -> Vector3 {
|
||||
|
||||
fn preview_wire(points: Vec<Vec3>) -> WireModel {
|
||||
WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "dimangular_preview".to_string(),
|
||||
points: points.into_iter().map(|p| [p.x, p.y, p.z]).collect(),
|
||||
points_low: Vec::new(),
|
||||
|
||||
@@ -179,6 +179,7 @@ fn v3(p: Vec3) -> Vector3 {
|
||||
|
||||
fn preview_line(a: Vec3, b: Vec3) -> WireModel {
|
||||
WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "dimdia_preview".into(),
|
||||
points: vec![[a.x, a.y, a.z], [b.x, b.y, b.z]],
|
||||
points_low: Vec::new(),
|
||||
|
||||
@@ -169,6 +169,7 @@ impl CadCommand for DimBaselineCommand {
|
||||
let p1 = self.base_p1;
|
||||
let (dim_line_pt, dim_line_pt2) = self.dim_line_pts(pt);
|
||||
Some(WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "dimbase_preview".into(),
|
||||
points: vec![
|
||||
[p1.x, p1.y, p1.z],
|
||||
|
||||
@@ -149,6 +149,7 @@ impl CadCommand for DimContinueCommand {
|
||||
let dim_line_pt = p1 + self.perp * (self.dim_line_perp - p1.dot(self.perp));
|
||||
let dim_line_pt2 = pt + self.perp * (self.dim_line_perp - pt.dot(self.perp));
|
||||
Some(WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "dimcont_preview".into(),
|
||||
points: vec![
|
||||
[p1.x, p1.y, p1.z],
|
||||
|
||||
@@ -85,6 +85,7 @@ impl CadCommand for DimJogLineCommand {
|
||||
}
|
||||
let d = 0.3_f32;
|
||||
Some(WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "dimjog_preview".into(),
|
||||
// Jog zigzag in the XY drawing plane (Z is elevation, ~0). The old
|
||||
// marker varied Z, so in the top-down view it collapsed to a flat
|
||||
|
||||
@@ -101,6 +101,7 @@ impl CadCommand for DimTeditCommand {
|
||||
}
|
||||
let d = 0.2_f32;
|
||||
Some(WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "dimtedit_preview".into(),
|
||||
// Marker box in the XY drawing plane (Z is elevation, ~0). The old
|
||||
// box varied Z, so in the top-down view it collapsed to a flat line
|
||||
|
||||
@@ -163,6 +163,7 @@ fn preview_wire(pts: &[Vec3]) -> WireModel {
|
||||
points.push([w2.x, w2.y, w2.z]);
|
||||
}
|
||||
WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "leader_preview".into(),
|
||||
points,
|
||||
points_low: Vec::new(),
|
||||
|
||||
@@ -218,6 +218,7 @@ fn v3(pt: Vec3) -> Vector3 {
|
||||
|
||||
fn preview_wire(points: Vec<Vec3>) -> WireModel {
|
||||
WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "dimlinear_preview".to_string(),
|
||||
points: points.into_iter().map(|p| [p.x, p.y, p.z]).collect(),
|
||||
points_low: Vec::new(),
|
||||
|
||||
@@ -149,6 +149,7 @@ fn preview_wire(pts: &[Vec3]) -> WireModel {
|
||||
points.push([w2.x, w2.y, w2.z]);
|
||||
}
|
||||
WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "mleader_preview".into(),
|
||||
points,
|
||||
points_low: Vec::new(),
|
||||
|
||||
@@ -456,6 +456,7 @@ impl CadCommand for MLeaderCollectCommand {
|
||||
|
||||
fn preview_wire(pts: &[Vec3]) -> WireModel {
|
||||
WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "mleader_edit_preview".into(),
|
||||
points: pts.iter().map(|p| [p.x, p.y, p.z]).collect(),
|
||||
points_low: Vec::new(),
|
||||
|
||||
@@ -116,6 +116,7 @@ fn ordinate_elbow(feature: Vec3, leader: Vec3, is_x: bool) -> Vec3 {
|
||||
|
||||
fn preview_wire(points: Vec<Vec3>) -> WireModel {
|
||||
WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "dimordinate_preview".into(),
|
||||
points: points.into_iter().map(|p| [p.x, p.y, p.z]).collect(),
|
||||
points_low: Vec::new(),
|
||||
|
||||
@@ -88,6 +88,7 @@ impl CadCommand for QdimCommand {
|
||||
}
|
||||
let d = 0.5_f32;
|
||||
Some(WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "qdim_preview".into(),
|
||||
points: vec![[pt.x - d * 3.0, pt.y, pt.z], [pt.x + d * 3.0, pt.y, pt.z]],
|
||||
points_low: Vec::new(),
|
||||
|
||||
@@ -184,6 +184,7 @@ fn v3(pt: Vec3) -> Vector3 {
|
||||
|
||||
fn preview_wire(points: Vec<Vec3>) -> WireModel {
|
||||
WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "dimradius_preview".to_string(),
|
||||
points: points.into_iter().map(|p| [p.x, p.y, p.z]).collect(),
|
||||
points_low: Vec::new(),
|
||||
|
||||
@@ -139,6 +139,7 @@ impl CadCommand for TableCommand {
|
||||
let y = pt.y;
|
||||
let z = pt.z;
|
||||
Some(WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "table_preview".into(),
|
||||
points: vec![
|
||||
[x, y, z],
|
||||
|
||||
@@ -84,6 +84,7 @@ impl CadCommand for ToleranceCommand {
|
||||
}
|
||||
let d = 0.15_f32;
|
||||
Some(WireModel {
|
||||
text_verts: Vec::new(),
|
||||
name: "tolerance_preview".into(),
|
||||
points: vec![
|
||||
[pt.x - d, pt.y, pt.z],
|
||||
|
||||
Reference in new issue
Block a user