Three asks landing together. ## History view — now identical controls to Log Stream - Oldest-first order with auto-scroll-to-bottom on append (was newest- first, no auto-scroll). ScrollViewReader + onChange pattern lifted from LogStreamView for behavioral parity. - Toolbar now matches the Log Stream layout exactly: Category filter, Auto-scroll toggle, Pause toggle, filtered/total count, Clear button. - Poll rate bumped 1 Hz → 0.10 s so new events appear instantly. Pause toggle freezes refresh without dropping the running event collection. ## Proper line shader (much better hand + body rendering) - New `line_vertex` / `line_fragment` in Boxes.metal alongside the existing box shader. `LineUniforms` carries endpoints + thickness + soft-edge falloff + a dot-mode flag. - Line mode: emits a rotated thin quad oriented along (end - start) with width = thickness. Soft-edge antialiasing via smoothstep on the signed perpendicular UV makes diagonal skeleton segments read as actual strokes instead of axis-aligned bounding boxes. - Dot mode: emits a square around `start` and the fragment discards outside the unit-circle — produces filled disks for joint markers with sub-pixel-clean soft edges. - Pipelines gains a `lines` blended pipeline. - Renderer.drawPoses() rewritten to use the line pipeline — one draw per segment, one draw per joint, all visually consistent regardless of segment angle. Theme.Palette.bodyPose (mint) for body, handPose (amber) for hand. ## Status panel (⌘I) - New `CurrentStateStore` singleton subscribes to the event bus and retains the most recent value per concept: expression (smile / frown / neutral_face), activity (standing / sitting / etc.), per-chirality finger counts, plus a small ring of recent non-finger non-expression gestures. - New StatusView (SwiftUI) reads three sources at 4 Hz: the live ObjectDetector for FPS + DET timing + objects + faces, the CurrentStateStore for hands/expression/activity/recent-gestures, and the HistoryStore for an 8-entry tail of recent events. - New StatusWindowController hosts the SwiftUI view as a dark-aqua floating window with frame persistence (VPOC.StatusWindowFrame). - AppDelegate `openStatus(_:)` builds a DetectorSnapshot from the live windowController + detector each tick, partitioning detections into face entries (anything labeled FACE or matching an enrolled name) vs object entries. Object entries carry the same per-track color the JARVIS pane uses (via ColorHash.colorFor) so the panel's dots match the on-screen box colors. - Renderer exposes `smoothedFPSForReadout` so the panel can show the same FPS the footer does without reaching into private state. - FingerCounter now records its count per chirality via CurrentStateStore.recordFingers (in addition to the existing bus emit), using VNHumanHandPoseObservation.chirality. The panel displays "Left: 3 fingers / Right: 5 fingers" correctly. Menu structure now: - App menu: Settings (⌘,) · Log Stream (⌘L) · Status (⌘I) · Save Snapshot (⌘S) · Start/Stop Recording (⇧⌘R) · Quit - Faces menu: Enroll (⌘E) · Forget (⇧⌘E) · History (⌘H) - Camera menu: Devices ▶ · Refresh · Privacy Mode (⇧⌘P) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
98 lines
3.5 KiB
Swift
98 lines
3.5 KiB
Swift
import Metal
|
|
|
|
final class Pipelines {
|
|
let device: MTLDevice
|
|
let live: MTLRenderPipelineState
|
|
let jarvis: MTLRenderPipelineState
|
|
let edges: MTLRenderPipelineState
|
|
let boxes: MTLRenderPipelineState
|
|
let hudText: MTLRenderPipelineState
|
|
let ascii: MTLRenderPipelineState
|
|
let lines: MTLRenderPipelineState
|
|
|
|
init(device: MTLDevice, library: MTLLibrary) throws {
|
|
self.device = device
|
|
|
|
self.live = try Pipelines.makeImagePipeline(
|
|
device: device, library: library,
|
|
vertex: "quad_vertex", fragment: "live_fragment",
|
|
label: "LivePipeline"
|
|
)
|
|
|
|
self.jarvis = try Pipelines.makeImagePipeline(
|
|
device: device, library: library,
|
|
vertex: "quad_vertex", fragment: "jarvis_fragment",
|
|
label: "JarvisPipeline"
|
|
)
|
|
|
|
self.edges = try Pipelines.makeImagePipeline(
|
|
device: device, library: library,
|
|
vertex: "quad_vertex", fragment: "edges_fragment",
|
|
label: "EdgesPipeline"
|
|
)
|
|
|
|
self.boxes = try Pipelines.makeBlendedPipeline(
|
|
device: device, library: library,
|
|
vertex: "box_vertex", fragment: "box_fragment",
|
|
label: "BoxesPipeline"
|
|
)
|
|
|
|
self.hudText = try Pipelines.makeBlendedPipeline(
|
|
device: device, library: library,
|
|
vertex: "quad_vertex", fragment: "text_fragment",
|
|
label: "HUDTextPipeline"
|
|
)
|
|
|
|
self.ascii = try Pipelines.makeImagePipeline(
|
|
device: device, library: library,
|
|
vertex: "quad_vertex", fragment: "ascii_fragment",
|
|
label: "AsciiPipeline"
|
|
)
|
|
|
|
self.lines = try Pipelines.makeBlendedPipeline(
|
|
device: device, library: library,
|
|
vertex: "line_vertex", fragment: "line_fragment",
|
|
label: "LinesPipeline"
|
|
)
|
|
}
|
|
|
|
private static func makeImagePipeline(
|
|
device: MTLDevice,
|
|
library: MTLLibrary,
|
|
vertex: String,
|
|
fragment: String,
|
|
label: String
|
|
) throws -> MTLRenderPipelineState {
|
|
let descriptor = MTLRenderPipelineDescriptor()
|
|
descriptor.label = label
|
|
descriptor.vertexFunction = library.makeFunction(name: vertex)
|
|
descriptor.fragmentFunction = library.makeFunction(name: fragment)
|
|
descriptor.colorAttachments[0].pixelFormat = .bgra8Unorm
|
|
descriptor.colorAttachments[0].isBlendingEnabled = false
|
|
return try device.makeRenderPipelineState(descriptor: descriptor)
|
|
}
|
|
|
|
private static func makeBlendedPipeline(
|
|
device: MTLDevice,
|
|
library: MTLLibrary,
|
|
vertex: String,
|
|
fragment: String,
|
|
label: String
|
|
) throws -> MTLRenderPipelineState {
|
|
let descriptor = MTLRenderPipelineDescriptor()
|
|
descriptor.label = label
|
|
descriptor.vertexFunction = library.makeFunction(name: vertex)
|
|
descriptor.fragmentFunction = library.makeFunction(name: fragment)
|
|
let attachment = descriptor.colorAttachments[0]!
|
|
attachment.pixelFormat = .bgra8Unorm
|
|
attachment.isBlendingEnabled = true
|
|
attachment.rgbBlendOperation = .add
|
|
attachment.alphaBlendOperation = .add
|
|
attachment.sourceRGBBlendFactor = .sourceAlpha
|
|
attachment.destinationRGBBlendFactor = .oneMinusSourceAlpha
|
|
attachment.sourceAlphaBlendFactor = .sourceAlpha
|
|
attachment.destinationAlphaBlendFactor = .oneMinusSourceAlpha
|
|
return try device.makeRenderPipelineState(descriptor: descriptor)
|
|
}
|
|
}
|