diff options
Diffstat (limited to 'src/landscape.h')
-rw-r--r-- | src/landscape.h | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/src/landscape.h b/src/landscape.h index b70b0a39a..f3071868f 100644 --- a/src/landscape.h +++ b/src/landscape.h @@ -35,11 +35,41 @@ byte HighestSnowLine(); byte LowestSnowLine(); void ClearSnowLine(); +int GetSlopeZInCorner(Slope tileh, Corner corner); +Slope GetFoundationSlope(TileIndex tile, uint *z); + uint GetPartialPixelZ(int x, int y, Slope corners); uint GetSlopePixelZ(int x, int y); void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2); -int GetSlopePixelZInCorner(Slope tileh, Corner corner); -Slope GetFoundationPixelSlope(TileIndex tile, uint *z); + +/** + * Determine the Z height of a corner relative to TileZ. + * + * @pre The slope must not be a halftile slope. + * + * @param tileh The slope. + * @param corner The corner. + * @return Z position of corner relative to TileZ. + */ +static inline int GetSlopePixelZInCorner(Slope tileh, Corner corner) +{ + return GetSlopeZInCorner(tileh, corner) * TILE_HEIGHT; +} + +/** + * Get slope of a tile on top of a (possible) foundation + * If a tile does not have a foundation, the function returns the same as GetTilePixelSlope. + * + * @param tile The tile of interest. + * @param z returns the z of the foundation slope. (Can be NULL, if not needed) + * @return The slope on top of the foundation. + */ +static inline Slope GetFoundationPixelSlope(TileIndex tile, uint *z) +{ + Slope s = GetFoundationSlope(tile, z); + if (z != NULL) *z *= TILE_HEIGHT; + return s; +} /** * Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap. @@ -84,7 +114,20 @@ static inline Point InverseRemapCoords(int x, int y) return pt; } -uint ApplyPixelFoundationToSlope(Foundation f, Slope *s); +uint ApplyFoundationToSlope(Foundation f, Slope *s); +/** + * Applies a foundation to a slope. + * + * @pre Foundation and slope must be valid combined. + * @param f The #Foundation. + * @param s The #Slope to modify. + * @return Increment to the tile Z coordinate. + */ +static inline uint ApplyPixelFoundationToSlope(Foundation f, Slope *s) +{ + return ApplyFoundationToSlope(f, s) * TILE_HEIGHT; +} + void DrawFoundation(TileInfo *ti, Foundation f); bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here); bool HasFoundationNE(TileIndex tile, Slope slope_here, uint z_here); |