fix: resolve ByBlock color, linetype, and lineweight through INSERT chain

Block sub-entities with ByBlock color now inherit their INSERT's resolved
color instead of rendering as the default white. ByBlock linetype inherits
the INSERT's linetype pattern, and ByBlock lineweight inherits the INSERT's
effective line weight.

Implemented via render_style_for_block_sub(), called in tessellate_entity()
when expanding INSERT exploded entities.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Sonnet 4.6 committed 2026-04-26 22:07:24 +03:00
1 parent 464bb8905f
commit 045ab96eab
2 files changed
+43 -2

No files matched your search

+7 -1
View File
@@ -2630,6 +2630,9 @@ fn tessellate_entity(
if let EntityType::Insert(ins) = e {
let is_mirrored = ins.x_scale() * ins.y_scale() < 0.0;
// Resolve the INSERT's own style so ByBlock sub-entities can inherit it.
let (ins_color, ins_pat_len, ins_pat, ins_lw_px, _) =
render::render_style_for(document, e);
return ins
.explode_from_document(document)
.iter()
@@ -2638,7 +2641,10 @@ fn tessellate_entity(
.map(|sub| crate::modules::home::modify::explode::fix_mirrored_arc(sub, is_mirrored))
.flat_map(|sub| {
let (sub_color, sub_pattern_length, sub_pattern, sub_line_weight_px, sub_aci) =
render::render_style_for(document, &sub);
render::render_style_for_block_sub(
document, &sub,
ins_color, ins_pat_len, ins_pat, ins_lw_px,
);
let sub_aabb = entity_aabb(&sub);
let mut wire = tessellate::tessellate(
document,
+36 -1
View File
@@ -180,7 +180,7 @@ pub(super) fn linetype_name_for<'a>(document: &'a CadDocument, e: &'a EntityType
}
/// Returns `(entity_color, pattern_length, pattern, line_weight_px, aci)` for
/// an entity, resolving ByLayer/ByBlock colour and linetype from the document.
/// an entity, resolving ByLayer color and linetype from the document.
pub(super) fn render_style_for(
document: &CadDocument,
e: &EntityType,
@@ -230,6 +230,41 @@ pub(super) fn render_style_for(
(entity_color, pattern_length, pattern, line_weight_px, aci)
}
/// Like `render_style_for` but resolves ByBlock properties by inheriting from
/// the INSERT entity's already-resolved style. Call this for exploded block
/// sub-entities so that ByBlock color/linetype/lineweight propagate correctly.
pub(super) fn render_style_for_block_sub(
document: &CadDocument,
e: &EntityType,
insert_color: [f32; 4],
insert_pat_len: f32,
insert_pat: [f32; 8],
insert_lw_px: f32,
) -> ([f32; 4], f32, [f32; 8], f32, u8) {
let (color, pat_len, pat, lw_px, aci) = render_style_for(document, e);
let common = e.common();
let final_color = if common.color == AcadColor::ByBlock {
insert_color
} else {
color
};
let (final_pat_len, final_pat) = if common.linetype.eq_ignore_ascii_case("byblock") {
(insert_pat_len, insert_pat)
} else {
(pat_len, pat)
};
let final_lw = if matches!(common.line_weight, LineWeight::ByBlock) {
insert_lw_px
} else {
lw_px
};
(final_color, final_pat_len, final_pat, final_lw, aci)
}
// ── Primitive builder helpers (called by ViewportPane's shader::Program impl) ──
impl Scene {