Skip to content

Commit 095fd36

Browse files
perf(render): viewport culling, live POIs, external TraCI attach
Rendering - Spatially index lanes; cull lane/vehicle/POI buffers to visible world bounds with pan headroom. Rebuild only when scale crosses a 3% LOD step or the viewport leaves the cached region. - Coalesce pan deltas onto a 60 Hz timer so trackpad/scroll events don't thrash GPU buffers. - Cap zoom at a per-network maximum derived from lane widths so small networks can't blow past the lane-width cap. - Skip vehicle interpolation (and drop to 30 Hz) for dense fleets where animation isn't visible anyway. Selection & contrast - Draw selected lanes/junctions as alpha overlays on top of the base color instead of replacing it, so selection no longer masks state. - Add WCAG-aware stroke/detail colors for vehicle icons. Live POIs - Poll "slot_*" POIs each tick via new poiPosition/poiColor TraCI calls and surface them through SimulationState.pois alongside static POIs. External TraCI attach - Add --traci-port / --traci-order launch flags and a 60×500ms connect retry budget so an external runner can spawn SUMO and have SumoMacGUI attach. SumoLauncher - Extract SumoLauncher.arguments and switch to bare --no-step-log / --no-warnings; update CHECKLIST note. Tests - NetworkRenderLODTests, ViewportStateTests, new SumoLauncherTests cover the helpers above.
1 parent ed63cf1 commit 095fd36

13 files changed

Lines changed: 1057 additions & 200 deletions

Sources/SumoGUIMac/App/LaunchConfiguration.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,30 @@ import Foundation
22

33
struct LaunchConfiguration: Equatable {
44
let openURL: URL?
5+
let traciPort: Int?
6+
let traciClientOrder: Int32
57

68
static func from(arguments: [String], currentDirectoryURL: URL = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)) -> LaunchConfiguration {
79
let args = Array(arguments.dropFirst())
810
var iterator = args.makeIterator()
911
var openPath: String?
12+
var traciPort: Int?
13+
var traciClientOrder: Int32 = 2
1014

1115
while let arg = iterator.next() {
1216
switch arg {
1317
case "-c", "--config":
1418
if let next = iterator.next(), isSupportedInputPath(next) {
1519
openPath = next
1620
}
21+
case "--traci-port":
22+
if let next = iterator.next(), let port = Int(next), (1...65_535).contains(port) {
23+
traciPort = port
24+
}
25+
case "--traci-order":
26+
if let next = iterator.next(), let order = Int32(next) {
27+
traciClientOrder = order
28+
}
1729
case let path where !path.hasPrefix("-") && openPath == nil && isSupportedInputPath(path):
1830
openPath = path
1931
default:
@@ -22,11 +34,11 @@ struct LaunchConfiguration: Equatable {
2234
}
2335

2436
guard let openPath else {
25-
return LaunchConfiguration(openURL: nil)
37+
return LaunchConfiguration(openURL: nil, traciPort: traciPort, traciClientOrder: traciClientOrder)
2638
}
2739

2840
let url = URL(fileURLWithPath: openPath, relativeTo: currentDirectoryURL).standardizedFileURL
29-
return LaunchConfiguration(openURL: url)
41+
return LaunchConfiguration(openURL: url, traciPort: traciPort, traciClientOrder: traciClientOrder)
3042
}
3143

3244
private static func isSupportedInputPath(_ path: String) -> Bool {

Sources/SumoGUIMac/App/SumoGUIMacApp.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ struct SumoGUIMacApp: App {
77

88
init() {
99
let launchConfiguration = LaunchConfiguration.from(arguments: CommandLine.arguments)
10-
_simulation = StateObject(wrappedValue: SimulationViewModel(initialOpenURL: launchConfiguration.openURL))
10+
_simulation = StateObject(wrappedValue: SimulationViewModel(
11+
initialOpenURL: launchConfiguration.openURL,
12+
initialTraciPort: launchConfiguration.traciPort,
13+
initialTraciClientOrder: launchConfiguration.traciClientOrder
14+
))
1115
}
1216

1317
var body: some Scene {

0 commit comments

Comments
 (0)