foundryvtt / foundryvtt

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.
https://foundryvtt.com/
216 stars 10 forks source link

Develop a consistent method to refer to coordinates with elevation #11262

Open caewok opened 2 weeks ago

caewok commented 2 weeks ago

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 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:

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.

aaclayton commented 2 weeks ago

This is something we can discuss and make a decision on as part of V13.