Fix branchedResetPropagation #57

Merged
thepaperpilot merged 3 commits from nif/Profectus-Niffix:main into main 2024-02-14 17:39:07 +00:00
Showing only changes of commit 263c951cf8 - Show all commits

View file

@ -339,19 +339,19 @@ export const branchedResetPropagation = function (
resettingNode: GenericTreeNode resettingNode: GenericTreeNode
): void { ): void {
const links = unref(tree.branches); const links = unref(tree.branches);
if (links === undefined) return; if (links == null) return;
let reset: GenericTreeNode[] = []; const reset: GenericTreeNode[] = [];
let current = [resettingNode]; let current = [resettingNode];
while (current.length != 0) { while (current.length != 0) {
let next: GenericTreeNode[] = []; const next: GenericTreeNode[] = [];
for (let node of current) { for (const node of current) {
for (let link of links.filter(link => link.startNode === node)) { for (const link of links.filter(link => link.startNode === node)) {
if ([...reset, ...current].includes(link.endNode)) continue if ([...reset, ...current].includes(link.endNode)) continue
next.push(link.endNode); next.push(link.endNode);
link.endNode.reset?.reset(); link.endNode.reset?.reset();
} }
}; };
reset = reset.concat(current); reset.push(...current);
current = next; current = next;
} }
}; };