Optimize mover rendering and segment plan pipeline

This commit is contained in:
scamiv
2026-02-27 15:06:48 +01:00
parent 7689215996
commit f0e8c67387
17 changed files with 924 additions and 354 deletions
@@ -0,0 +1,43 @@
import FastPriorityQueue from "fastpriorityqueue";
export type UnitMotionRenderQueueEntry = {
unitId: number;
version: number;
priority: number;
onScreenHint: boolean;
};
export class UnitMotionRenderQueue {
private queue = new FastPriorityQueue<UnitMotionRenderQueueEntry>(
(a, b) => a.priority > b.priority,
);
enqueue(entry: UnitMotionRenderQueueEntry): void {
this.queue.add(entry);
}
pollValid(
isValid: (entry: UnitMotionRenderQueueEntry) => boolean,
): UnitMotionRenderQueueEntry | null {
while (!this.queue.isEmpty()) {
const entry = this.queue.poll();
if (!entry) {
break;
}
if (isValid(entry)) {
return entry;
}
}
return null;
}
size(): number {
return this.queue.size;
}
clear(): void {
this.queue = new FastPriorityQueue<UnitMotionRenderQueueEntry>(
(a, b) => a.priority > b.priority,
);
}
}