Fix: arc hovering
This commit is contained in:
parent
39ae993b48
commit
6e92ef9a6f
1 changed files with 64 additions and 44 deletions
|
|
@ -140,8 +140,8 @@ fn section_symbol_wires(
|
||||||
[vx0 / vlen, vy0 / vlen]
|
[vx0 / vlen, vy0 / vlen]
|
||||||
});
|
});
|
||||||
|
|
||||||
let (show_arrows, show_plane_line, show_end_lines, arrow_size, arrow_ext, label_h) =
|
let (show_arrows, show_plane_line, show_end_lines, arrow_size, arrow_ext, label_h) = match style
|
||||||
match style {
|
{
|
||||||
Some(st) => (
|
Some(st) => (
|
||||||
st.show_arrows,
|
st.show_arrows,
|
||||||
st.show_plane_line,
|
st.show_plane_line,
|
||||||
|
|
@ -152,7 +152,14 @@ fn section_symbol_wires(
|
||||||
),
|
),
|
||||||
None => {
|
None => {
|
||||||
let t = s.tick_a.abs().max(s.tick_b.abs());
|
let t = s.tick_a.abs().max(s.tick_b.abs());
|
||||||
(true, false, true, (t * 0.66).max(2.5), t.max(5.0), t.max(2.5))
|
(
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
(t * 0.66).max(2.5),
|
||||||
|
t.max(5.0),
|
||||||
|
t.max(2.5),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Arrowhead via the shared dimension/leader arrow table: the style's arrow
|
// Arrowhead via the shared dimension/leader arrow table: the style's arrow
|
||||||
|
|
@ -180,7 +187,10 @@ fn section_symbol_wires(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Each end: (endpoint, tick length, outward sign along the cut).
|
// Each end: (endpoint, tick length, outward sign along the cut).
|
||||||
for (ex, ey, tick, osign) in [(ax, ay, s.tick_a.abs(), 1.0), (bx, by, s.tick_b.abs(), -1.0)] {
|
for (ex, ey, tick, osign) in [
|
||||||
|
(ax, ay, s.tick_a.abs(), 1.0),
|
||||||
|
(bx, by, s.tick_b.abs(), -1.0),
|
||||||
|
] {
|
||||||
let (ox, oy) = (ux * osign, uy * osign); // outward along the cut
|
let (ox, oy) = (ux * osign, uy * osign); // outward along the cut
|
||||||
let tip = [ex + ox * tick, ey + oy * tick, 0.0]; // outer tick tip
|
let tip = [ex + ox * tick, ey + oy * tick, 0.0]; // outer tick tip
|
||||||
// End segment: the short drawn extension past the end (the "broken"
|
// End segment: the short drawn extension past the end (the "broken"
|
||||||
|
|
@ -563,7 +573,11 @@ pub(crate) fn tessellate_entity(
|
||||||
// Text labels: draw the glyph strokes (simplex.shx etc. are
|
// Text labels: draw the glyph strokes (simplex.shx etc. are
|
||||||
// single-stroke fonts, so the outline is the character).
|
// single-stroke fonts, so the outline is the character).
|
||||||
for t in &dec.texts {
|
for t in &dec.texts {
|
||||||
let font = t.font.trim().trim_end_matches(".shx").trim_end_matches(".SHX");
|
let font = t
|
||||||
|
.font
|
||||||
|
.trim()
|
||||||
|
.trim_end_matches(".shx")
|
||||||
|
.trim_end_matches(".SHX");
|
||||||
let font = if font.is_empty() { "standard" } else { font };
|
let font = if font.is_empty() { "standard" } else { font };
|
||||||
let (strokes, _) = crate::scene::text::lff::tessellate_text_ex(
|
let (strokes, _) = crate::scene::text::lff::tessellate_text_ex(
|
||||||
[0.0, 0.0],
|
[0.0, 0.0],
|
||||||
|
|
@ -674,10 +688,7 @@ pub(crate) fn tessellate_entity(
|
||||||
line_weight_px: 1.0,
|
line_weight_px: 1.0,
|
||||||
snap_pts: vec![],
|
snap_pts: vec![],
|
||||||
tangent_geoms: vec![],
|
tangent_geoms: vec![],
|
||||||
key_vertices: vec![
|
key_vertices: vec![[x0, y0, 0.0], [x1, y1, 0.0]],
|
||||||
[x0, y0, 0.0],
|
|
||||||
[x1, y1, 0.0],
|
|
||||||
],
|
|
||||||
aabb: [x0 as f32, y0 as f32, x1 as f32, y1 as f32],
|
aabb: [x0 as f32, y0 as f32, x1 as f32, y1 as f32],
|
||||||
plinegen: true,
|
plinegen: true,
|
||||||
fill_tris: vec![],
|
fill_tris: vec![],
|
||||||
|
|
@ -1547,34 +1558,43 @@ pub(crate) fn wire_points_aabb(w: &WireModel) -> [f32; 4] {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Assign `entity_box` as `w`'s cullable box, widened to cover the wire's
|
/// Assign `entity_box` as `w`'s cullable box, widened to cover the wire's
|
||||||
/// pick-only geometry.
|
/// actual tessellated geometry and pick-only geometry.
|
||||||
///
|
///
|
||||||
/// `entity_aabb`'s box comes from acadrust's `bounding_box()`, which for a
|
/// `entity_aabb`'s box comes from acadrust's `bounding_box()`, which for a
|
||||||
/// polyline is the box of its stored vertices — it knows nothing about the band
|
/// polyline is often the box of its stored vertices — it may know nothing about
|
||||||
/// a width paints around them, nor the wall a thickness extrudes. Hit-testing
|
/// bulge arcs between them, the band a width paints around them, or the wall a
|
||||||
/// rejects on this box before it looks at `pick_tris`, so a box that stops short
|
/// thickness extrudes. Hit-testing rejects on this box before it looks at the
|
||||||
/// of them makes them silently unpickable: a donut's vertices are two points on
|
/// wire segments or `pick_tris`, so a box that stops short of the drawn geometry
|
||||||
/// one horizontal line, giving a zero-height box that rejects every click on the
|
/// makes that geometry silently unpickable.
|
||||||
/// disc it draws.
|
|
||||||
///
|
|
||||||
/// A no-op for the entities that have no `pick_tris`, which is nearly all.
|
|
||||||
pub(crate) fn set_wire_aabb(w: &mut WireModel, entity_box: [f32; 4]) {
|
pub(crate) fn set_wire_aabb(w: &mut WireModel, entity_box: [f32; 4]) {
|
||||||
if w.pick_tris.is_empty() || entity_box == WireModel::UNBOUNDED_AABB {
|
let mut out = if entity_box == WireModel::UNBOUNDED_AABB {
|
||||||
w.aabb = entity_box;
|
wire_points_aabb(w)
|
||||||
return;
|
} else {
|
||||||
}
|
entity_box
|
||||||
let [mut x0, mut y0, mut x1, mut y1] = entity_box;
|
};
|
||||||
for (i, p) in w.pick_tris.iter().enumerate() {
|
|
||||||
let lo = w.pick_tris_low.get(i).copied().unwrap_or([0.0; 3]);
|
let mut extend = |p: [f32; 3], lo: [f32; 3]| {
|
||||||
let (x, y) = (p[0] + lo[0], p[1] + lo[1]);
|
let (x, y) = (p[0] + lo[0], p[1] + lo[1]);
|
||||||
if x.is_finite() && y.is_finite() {
|
if x.is_finite() && y.is_finite() {
|
||||||
x0 = x0.min(x);
|
if out == WireModel::UNBOUNDED_AABB {
|
||||||
y0 = y0.min(y);
|
out = [x, y, x, y];
|
||||||
x1 = x1.max(x);
|
} else {
|
||||||
y1 = y1.max(y);
|
out[0] = out[0].min(x);
|
||||||
|
out[1] = out[1].min(y);
|
||||||
|
out[2] = out[2].max(x);
|
||||||
|
out[3] = out[3].max(y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.aabb = [x0, y0, x1, y1];
|
};
|
||||||
|
|
||||||
|
for (i, &p) in w.points.iter().enumerate() {
|
||||||
|
extend(p, w.points_low.get(i).copied().unwrap_or([0.0; 3]));
|
||||||
|
}
|
||||||
|
for (i, &p) in w.pick_tris.iter().enumerate() {
|
||||||
|
extend(p, w.pick_tris_low.get(i).copied().unwrap_or([0.0; 3]));
|
||||||
|
}
|
||||||
|
|
||||||
|
w.aabb = out;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn entity_aabb(e: &acadrust::EntityType) -> [f32; 4] {
|
pub(crate) fn entity_aabb(e: &acadrust::EntityType) -> [f32; 4] {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue