feat(draworder): cross-type draw order + context menu

DRAWORDER now affects rendering immediately (bump geometry epoch so the
sort cache rebuilds) and front/back anchor to the block's full effective
sort range instead of only existing table entries, so bring-to-front
actually lands on top. The render fallback sorts table-absent entities by
their own handle.

Draw order now applies across entity types, not just within a type. A
per-entity draw-order rank (SortEntitiesTable override or own handle,
ranked per block) is encoded as a small signed clip-z bias in the wire,
hatch, image, and 3DFACE pipelines. The shared LessEqual depth buffer then
orders fills, lines, rasters and 2D solids against each other regardless of
pass order — without touching model coordinates. 3D meshes keep real
geometric depth; wipeouts stay always-on-top.

Adds a Draw Order submenu to the viewport context menu (Bring to Front,
Send to Back, Bring Above/Send Under Object). The above/under items run an
interactive reference-object pick, then reorder the captured selection.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-05-30 21:29:01 +03:00
1 parent 14a981dc87
commit 09e7e90aae
19 files changed
+469 -36

No files matched your search

+8 -1
View File
@@ -35,6 +35,11 @@ pub struct ViewportData {
/// 3DFACE entity wires — separated so they are uploaded to the dedicated
/// face3d pipeline (fill + batched edges) instead of N individual WireGpu.
pub(super) face3d_wires: Arc<Vec<WireModel>>,
/// Per-entity normalized draw-order depth (handle.value() → (0,1)), used
/// by the wire / face3d pipelines as a clip-z bias. WireModels carry no
/// depth field (84 construction sites); the bias is looked up by handle
/// at GPU-upload time from this map instead.
pub(super) draw_depths: Arc<std::collections::HashMap<u64, f32>>,
pub(super) hatches: Arc<Vec<HatchModel>>,
/// Wipeout fills — rendered in a separate pass AFTER wires.
pub(super) wipeout_hatches: Arc<Vec<HatchModel>>,
@@ -224,12 +229,13 @@ impl shader::Primitive for Primitive {
}
// Wires re-upload on every camera change because the visible
// subset shifts under frustum culling.
inner.upload_wires(device, &vp.wires[..]);
inner.upload_wires(device, &vp.wires[..], &vp.draw_depths);
inner.upload_face3d(
device,
&vp.face3d_wires[..],
&vp.wires[..],
!face3d_fill_active,
&vp.draw_depths,
);
inner.cached_epoch = cur_key;
}
@@ -645,6 +651,7 @@ impl Scene {
Some(ViewportData {
wires: all_wires,
face3d_wires: Arc::new(face3d_wires),
draw_depths: self.draw_depth_map(),
hatches: self.hatch_models_arc(),
wipeout_hatches: self.wipeout_models_arc(),
images: self.images_arc(),