forked from 1b-agent/opencadstudio-upstream
Feat: Phase 6.4 — Draw order render pipeline via SortEntitiesTable
wires_for_block() now looks up the SortEntitiesTable for the current block. When found, wires are sorted by sort_handle.value() so DRAWORDER F/B results are immediately visible in the viewport (not just written to DXF). Entities not in the sort table default to u64::MAX/2 (middle of draw order). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
b27b612b5d
commit
9a1eeab53d
1 file changed
+27
-2
+27
-2
@@ -319,7 +319,18 @@ impl Scene {
|
||||
|
||||
/// Tessellate all non-invisible entities owned by `block_handle`.
|
||||
fn wires_for_block(&self, block_handle: Handle) -> Vec<WireModel> {
|
||||
self.document
|
||||
use acadrust::objects::ObjectType;
|
||||
|
||||
// Find the SortEntitiesTable for this block (if any).
|
||||
let sort_table = self.document.objects.values().find_map(|obj| {
|
||||
if let ObjectType::SortEntitiesTable(t) = obj {
|
||||
if t.block_owner_handle == block_handle { Some(t) } else { None }
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
|
||||
let mut wires: Vec<WireModel> = self.document
|
||||
.entities()
|
||||
.filter(|e| {
|
||||
let c = e.common();
|
||||
@@ -338,7 +349,21 @@ impl Scene {
|
||||
self.belongs_to_visible_block(e.common().handle, c.owner_handle, block_handle)
|
||||
})
|
||||
.flat_map(|e| self.tessellate_one(e))
|
||||
.collect()
|
||||
.collect();
|
||||
|
||||
// Apply draw order if a SortEntitiesTable exists and has entries.
|
||||
if let Some(table) = sort_table {
|
||||
if !table.is_empty() {
|
||||
wires.sort_by_key(|w| {
|
||||
let handle = Self::handle_from_wire_name(&w.name)
|
||||
.unwrap_or(Handle::NULL);
|
||||
table.get_sort_handle(handle)
|
||||
.map(|sh| sh.value())
|
||||
.unwrap_or(u64::MAX / 2) // unsorted entities draw in the middle
|
||||
});
|
||||
}
|
||||
}
|
||||
wires
|
||||
}
|
||||
|
||||
/// Decide whether an entity should be drawn as direct content of `block_handle`.
|
||||
|
||||
Reference in new issue
Block a user