Public issue tracking and documentation for Foundry Virtual Tabletop - software connecting RPG gamers in a shared multiplayer environment with an intuitive interface and powerful API.
Now that placeables in v12 have elevation and regions uses elevation in the segments, it would be helpful to have a consistent way to refer to elevation when using coordinates. I don't love how region segments defines a RegionMovementWaypoint as {x, y, elevation} because the units are different. x and y refer to what I will call "pixel units" while elevation is a "grid" unit defined by the scene configuration. Using the same units for a given coordinate is preferable because then you can do vector math on the points. It is also less confusing if you don't have to worry about whether elevation is defined in the same units as the other coordinate values.
I recommend extending GridCoordinate to handle the third dimension, using consistent units:
{x, y, z}, where "z" represents elevation in pixel units. Multiply this point by 1 / canvas.dimensions.distancePixels to get distance in grid units.
{i, j, k}, where "k" represents elevation in grid squares. If {i, j} represents a grid square, the {i, j, k} represents the grid cube. Multiplying this point by canvas.dimensions.distance gets you the distance in grid units.
Using this method, you can have functions like calculateDistance take two grid coordinates and return the euclidean distance without messing around with units.
For regions, this would represent a breaking change from using {x, y, elevation} to represent segment coordinates. To avoid serious breakage, you could represent segments using {x, y, z, elevation}, which should work in most cases without a code change.
User Experience
Now that placeables in v12 have elevation and regions uses elevation in the segments, it would be helpful to have a consistent way to refer to elevation when using coordinates. I don't love how region segments defines a
RegionMovementWaypoint
as {x, y, elevation} because the units are different.x
andy
refer to what I will call "pixel units" whileelevation
is a "grid" unit defined by the scene configuration. Using the same units for a given coordinate is preferable because then you can do vector math on the points. It is also less confusing if you don't have to worry about whether elevation is defined in the same units as the other coordinate values.I recommend extending
GridCoordinate
to handle the third dimension, using consistent units:1 / canvas.dimensions.distancePixels
to get distance in grid units.canvas.dimensions.distance
gets you the distance in grid units.Using this method, you can have functions like
calculateDistance
take two grid coordinates and return the euclidean distance without messing around with units.For regions, this would represent a breaking change from using {x, y, elevation} to represent segment coordinates. To avoid serious breakage, you could represent segments using {x, y, z, elevation}, which should work in most cases without a code change.