forked from 1b-agent/opencadstudio-upstream
fix(hatch): render weighted pattern strokes
Show styled boundaries only while selected.\n\nRefs #821
This commit is contained in:
1 parent
81de94fdbb
commit
fd801fac1b
6 files changed
+55
-23
No files matched your search
@@ -295,9 +295,7 @@ impl StorageHatchBatch {
|
||||
// along-line phase.
|
||||
let perp_step = fam.dy;
|
||||
let along_step = fam.dx;
|
||||
// Screen-space derivative drives 1-px line width
|
||||
// in the shader; this stored field is unused.
|
||||
let line_width = 0.0_f32;
|
||||
let line_width = h.line_weight_px.max(1.0);
|
||||
let period: f32 = fam.dashes.iter().map(|d| d.abs()).sum();
|
||||
families.push(LineFamilyGpu {
|
||||
cos_a: fam.angle_deg.to_radians().cos(),
|
||||
|
||||
@@ -286,7 +286,12 @@ impl TextureHatch {
|
||||
texels.push([angle_r.cos(), angle_r.sin(), fam.x0, fam.y0]);
|
||||
texels.push([fam.dx, fam.dy, fam.dy, fam.dx]);
|
||||
// Counts as exact f32 (small integers → no denormal/bitcast risk).
|
||||
texels.push([0.0, period, n_dashes as f32, dash_rel as f32]);
|
||||
texels.push([
|
||||
model.line_weight_px.max(1.0),
|
||||
period,
|
||||
n_dashes as f32,
|
||||
dash_rel as f32,
|
||||
]);
|
||||
n_families += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,10 +351,8 @@ impl Scene {
|
||||
(plain, texts)
|
||||
}
|
||||
|
||||
/// Boundary outline wire for a hatch, reconstructed from its cached
|
||||
/// `HatchModel` (offsets from `world_origin`). Used only for edit previews —
|
||||
/// the normal render shows the fill, not this outline.
|
||||
fn hatch_outline_wire(&self, handle: Handle) -> Option<WireModel> {
|
||||
/// Boundary wire for edit previews and selected hatches.
|
||||
pub(super) fn hatch_outline_wire(&self, handle: Handle) -> Option<WireModel> {
|
||||
let m = self.hatches.get(&handle)?;
|
||||
Self::hatch_model_outline_wire(handle, m)
|
||||
}
|
||||
@@ -375,12 +373,15 @@ impl Scene {
|
||||
if pts.len() < 2 {
|
||||
return None;
|
||||
}
|
||||
Some(WireModel::solid_f64(
|
||||
let mut wire = WireModel::solid_f64(
|
||||
handle.value().to_string(),
|
||||
pts,
|
||||
m.color,
|
||||
false,
|
||||
))
|
||||
);
|
||||
wire.aci = m.aci;
|
||||
wire.line_weight_px = m.line_weight_px;
|
||||
Some(wire)
|
||||
}
|
||||
|
||||
/// Fill-only geometry has no resident wire for the normal rollover xray.
|
||||
|
||||
@@ -3076,15 +3076,38 @@ impl Scene {
|
||||
let Some(entity) = self.document.get_entity(handle) else {
|
||||
continue;
|
||||
};
|
||||
if !crate::scene::annotative::is_annotative(&self.document, entity)
|
||||
|| !self.resident_entity_visible(
|
||||
if !self.resident_entity_visible(
|
||||
entity,
|
||||
target_block,
|
||||
Some(&frozen),
|
||||
annotation_scale_handle,
|
||||
true,
|
||||
)
|
||||
{
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if matches!(entity, EntityType::Hatch(_)) {
|
||||
if selected {
|
||||
if let Some(mut wire) = self.hatch_outline_wire(handle) {
|
||||
let (_, pattern_length, pattern, line_weight_px, aci) =
|
||||
render_style_for_viewport(
|
||||
&self.document,
|
||||
entity,
|
||||
content_viewport.then_some(inst.handle),
|
||||
);
|
||||
wire.color = WireModel::SELECTED;
|
||||
wire.selected = true;
|
||||
wire.pattern_length = pattern_length;
|
||||
wire.pattern = pattern;
|
||||
wire.line_weight_px = line_weight_px;
|
||||
wire.aci = aci;
|
||||
wires.push(wire);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if !crate::scene::annotative::is_annotative(&self.document, entity) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user