(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight

This commit is contained in:
rubidium
2011-11-04 10:20:24 +00:00
parent de980ef0f9
commit 5bc8a72377
7 changed files with 126 additions and 30 deletions

View File

@@ -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);