Skip to content

Commit

Permalink
Old coordinate bug fixed itself (Fix #109)
Browse files Browse the repository at this point in the history
I thought there was a bug where overlay/layer computations were being
mixed in such a way that we needed to match the named and unnamed
coordinate stringification functions. I can't find any evidence that
this is still the case.
  • Loading branch information
jcreedcmu committed Mar 19, 2024
1 parent 5dd7f89 commit 0baa7f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/core/layer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { DEBUG } from "../util/debug";
import { Point } from "../util/types";

// Implements a lazily-evaluated, cached, immutable sparse map from coordinates to T

// This is global
const cache: Record<string, any> = {};
if (DEBUG.stateExporter) {
(window as any).layerCache = cache;
}

export type Layer<T> = {
name: string,
Expand All @@ -24,7 +28,7 @@ function unparseNamedCoord(name: string, p: Point): string {
}

function unparseCoord(p: Point): string {
return `,${p.x},${p.y}`;
return `${p.x},${p.y}`;
}

export function mkLayer<T>(name: string, func: (p: Point) => T): Layer<T> {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/gl-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export function glInitialize(ci: CanvasGlInfo, dispatch: Dispatch): GlEnv {
};

if (DEBUG.stateExporter)
(window as any).cache = () => _cache;
(window as any).renderCache = () => _cache;

return {
gl,
Expand Down

0 comments on commit 0baa7f3

Please sign in to comment.