ReadonlyidReadonlynameReadonlypointsReturns the closest point to (u, v) that actually lies on this zone's polygon -- itself if
already inside, otherwise the nearest point on its perimeter. Used to pin a character to a
zone's drawn boundary instead of letting it linger at a coordinate just outside every zone
(which containsPoint's edge tolerance alone would otherwise allow).
Point-in-polygon test using Ray-Casting (Even-Odd rule) with optional edge tolerance. Works for both convex and concave polygons of any vertex count.
Normalized image-space X (0..1).
Normalized image-space Y (0..1).
Optional distance buffer (in the same 0..1 units) for seamless transitions between adjoining zones.
Derives this zone's local movement basis at a given (u, v) position: forward is the
direction in which the interpolated scale (see getScaleAt) decreases fastest -- i.e.
"deeper into the painted background" -- and right is a 90-degree rotation of it. A zone
traced onto a perspective background is rarely axis-aligned, so character input (WASD) must
be mapped through this basis instead of fixed screen axes.
Every zone shipped today has exactly 4 points, so this keeps the original corner-pair basis
(forward from edge P0-P1 toward P3-P2, right from edge P0-P3 toward P1-P2) byte-identical for
that case -- it predates and is independent of scale, so switching quads to a
gradient-based basis would silently change the movement feel of every existing scene. Polygons
with a different vertex count use the new scale-gradient basis, computed from the same fan
triangulation getScaleAt uses; a degenerate or near-zero gradient (e.g. a uniformly-scaled
zone) falls back to a fixed basis -- no current content exercises this path since only 4-point
zones exist in production today.
Interpolates the character scale factor at given (u, v) coordinates using barycentric interpolation across a fan of triangles radiating from the first point (points[0], points[i], points[i+1] for i = 1..length-2) -- a quad's classic two-triangle split generalized to any polygon vertex count. Byte-identical to the pre-generalization two-triangle version for quads, since that was already exactly this fan with n=4.
A walkable region of a 2.5D stage, traced directly on top of a painted background image in that image's own normalized (u, v) space -- no camera, no world coordinates, no perspective reconstruction. This intentionally mirrors how classic 2.5D adventures (Grim Fandango, Monkey Island) author walk masks: an artist draws a shape directly on the picture, and a small per-corner
scalefakes the size falloff a real camera would produce. There is no rectangle or vanishing-point constraint on the shape -- it's exactly what you see, not a projection of an assumed real-world form.