forked from 1b-agent/opencadstudio-upstream
fix(thickness): edit persists + wide polyline extrudes as a solid tube
Entering a thickness (DXF 39 extrusion) on a wide polyline now works end to end: - The properties Thickness field is a General-group common prop, so it is routed to apply_common_prop (set_entity_thickness) instead of the geometry setter, which ignored it — the value was silently dropped and reverted to 0. - A wide polyline extrudes its whole band into a 3-D tube (outer + inner walls with top and bottom caps), not just its centreline. - The tube is real 3-D geometry, not a flat draw-order hatch: it renders solid in every view mode with true depth, so nothing shows through the walls. The flat 2-D band fill is skipped for a thickened polyline. - A fill whose triangles span depth keeps its real depth (no draw-order bias), so the extrusion's own edge wires stay in front of the surface and remain visible instead of only the silhouette. - The corner and cap edge lines read black, framing the coloured tube. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
626e8091f7
commit
3d37e1f8d8
5 files changed
+124
-3
No files matched your search
@@ -1116,6 +1116,18 @@ pub fn tessellate(
|
||||
let mut out = Vec::new();
|
||||
let mut is_first = true;
|
||||
|
||||
// A thickened wide polyline's extrusion — its corner / cap edges
|
||||
// frame the solid tube and read black (like solid-with-edges
|
||||
// outlines), while the tube fill keeps the entity colour.
|
||||
let edge_color = if matches!(
|
||||
entity,
|
||||
EntityType::LwPolyline(p) if p.thickness.abs() > 1e-10
|
||||
) {
|
||||
[0.0, 0.0, 0.0, 1.0]
|
||||
} else {
|
||||
color
|
||||
};
|
||||
|
||||
if !local_pts.is_empty() {
|
||||
let (snap, keys, tangents) = if is_first {
|
||||
is_first = false;
|
||||
@@ -1137,7 +1149,7 @@ pub fn tessellate(
|
||||
name: name.clone(),
|
||||
points: local_pts,
|
||||
points_low: local_pts_low,
|
||||
color,
|
||||
color: edge_color,
|
||||
selected,
|
||||
pattern_length: 0.0,
|
||||
pattern: [0.0; 8],
|
||||
|
||||
@@ -691,6 +691,11 @@ impl Scene {
|
||||
// Wide LWPolyline and Polyline2D fills
|
||||
for entity in self.document.entities() {
|
||||
let (common, fill_origin, fills) = match entity {
|
||||
// A thickened wide LwPolyline becomes a 3-D tube: its bottom cap
|
||||
// is drawn as a real depth-tested surface by the tessellator, not
|
||||
// as this flat 2-D band (which, having only draw-order depth,
|
||||
// would show through the tube walls in a 3-D view).
|
||||
EntityType::LwPolyline(pl) if pl.thickness.abs() > 1e-10 => continue,
|
||||
EntityType::LwPolyline(pl) => {
|
||||
let (o, f) = crate::entities::lwpolyline::wide_fills(pl);
|
||||
(&pl.common, o, f)
|
||||
|
||||
@@ -211,7 +211,18 @@ impl Face3DGpu {
|
||||
}
|
||||
} else {
|
||||
let fill_color = [r, g, b, a];
|
||||
let depth = depth_of(wire);
|
||||
// A fill whose triangles span depth is a genuine 3-D surface (an
|
||||
// extruded polyline tube), not a flat coplanar overlay (2-D SOLID,
|
||||
// greek text, dimension background). Keep its real depth so the
|
||||
// fill occludes correctly and its own edge wires — coincident with
|
||||
// the surface — win the depth test and stay visible. A flat overlay
|
||||
// keeps the draw-order bias that layers it in screen order.
|
||||
let (mut zmin, mut zmax) = (f32::INFINITY, f32::NEG_INFINITY);
|
||||
for p in &wire.fill_tris {
|
||||
zmin = zmin.min(p[2]);
|
||||
zmax = zmax.max(p[2]);
|
||||
}
|
||||
let depth = if zmax - zmin > 1e-4 { 0.0 } else { depth_of(wire) };
|
||||
for (i, &position) in wire.fill_tris.iter().enumerate() {
|
||||
verts_2d.push(Face3DVertex {
|
||||
position,
|
||||
|
||||
Reference in new issue
Block a user