fix(blocks): complete block-backed instance rendering

This commit is contained in:
Hakan Seven committed 2026-09-01 22:41:12 +03:00
1 parent 6cc4e0f63d
commit 6606da5029
11 files changed
+554 -253

No files matched your search

+7 -8
View File
@@ -144,8 +144,8 @@ pub fn symbol_radius(doc: &CadDocument, block: Handle, scale: f64) -> f64 {
) else {
return 0.0;
};
graph.walk_insert(
&block_use.insert,
graph.walk_block_use(
&block_use,
block,
|_, _| true,
|entity, context| {
@@ -322,16 +322,15 @@ pub fn place_block_wires(
) else {
return Vec::new();
};
let insert = &mut block_use.insert;
insert.set_x_scale(s);
insert.set_y_scale(s);
insert.set_z_scale(s);
block_use.insert.set_x_scale(s);
block_use.insert.set_y_scale(s);
block_use.insert.set_z_scale(s);
let depths = rustc_hash::FxHashMap::default();
let graph = crate::scene::render_graph::RenderSceneGraph::new(doc, None, None, true, &depths)
.with_annotation_scale(anno_scale);
let mut out = Vec::new();
graph.walk_insert(
insert,
graph.walk_block_use(
&block_use,
block,
|_, _| true,
|entity, context| {
+31 -16
View File
@@ -39,6 +39,7 @@ pub(crate) struct ExpandedBlockObject {
pub(crate) struct BlockObjectOptions {
pub(crate) suppress_root_points: bool,
pub(crate) apply_xclip: bool,
pub(crate) scale_policy: crate::scene::BlockScalePolicy,
}
fn block_object_style(
@@ -141,16 +142,18 @@ pub(crate) fn expand_block_object(
is_xref,
bg_color,
anno_scale,
options.scale_policy,
options.suppress_root_points,
)
.unwrap_or_default();
if options.apply_xclip {
if let Some(filter) = pick::xclip::insert_spatial_filter(document, insert) {
let transform = crate::scene::render_graph::insert_transform_at_scale(
let transform = crate::scene::render_graph::insert_transform_with_policy(
document,
insert,
anno_scale,
options.scale_policy,
);
let polygon = pick::xclip::world_clip_polygon_for_transform(filter, &transform);
pick::xclip::clip_wires(&mut wires, &polygon);
@@ -568,7 +571,7 @@ fn tessellate_entity_inner(
// True only when tessellating content shown inside a paper-space viewport.
// Retained through recursive INSERT expansion; PSLTSCALE itself is applied
// by the viewport's GPU uniform so it never changes resident wire content.
paper_space: bool,
_paper_space: bool,
) -> Vec<WireModel> {
let contextual = crate::scene::annotative::entity_for_annotation_context(
document,
@@ -980,6 +983,7 @@ fn tessellate_entity_inner(
pslt_factor,
BlockObjectOptions {
suppress_root_points: block_use.suppress_root_points,
scale_policy: block_use.scale_policy,
..BlockObjectOptions::default()
},
)
@@ -1087,7 +1091,10 @@ fn tessellate_entity_inner(
view_aabb,
world_per_pixel,
pslt_factor,
BlockObjectOptions::default(),
BlockObjectOptions {
scale_policy: block_use.scale_policy,
..BlockObjectOptions::default()
},
)
.wires;
if !wires.is_empty() {
@@ -1119,19 +1126,27 @@ fn tessellate_entity_inner(
.filter(|block_use| {
block_use.role == crate::scene::render_graph::BlockRole::TableCell
}) {
wires.extend(tessellate_entity(
document,
selected,
active_viewport,
bg_color,
1.0,
None,
&EntityType::Insert(block_use.insert),
block_cache,
view_aabb,
world_per_pixel,
paper_space,
));
wires.extend(
expand_block_object(
document,
&block_use.insert,
h,
sel,
active_viewport,
bg_color,
table_anno,
None,
block_cache,
view_aabb,
world_per_pixel,
pslt_factor,
BlockObjectOptions {
scale_policy: block_use.scale_policy,
..BlockObjectOptions::default()
},
)
.wires,
);
}
if !wires.is_empty() {
let aabb = entity_aabb(e);
+2 -2
View File
@@ -2100,8 +2100,8 @@ fn custom_arrow_from_block(
let mut lines = Vec::new();
let mut fill = Vec::new();
let mut deferred_hatch = false;
graph.walk_insert(
&block_use.insert,
graph.walk_block_use(
&block_use,
record.handle,
|_, _| true,
|entity, context| {