File diff r10232:40f71efe145b → r10233:f4b6f7cfa2ac
src/viewport.cpp
Show inline comments
 
@@ -80,12 +80,13 @@ struct ChildScreenSpriteToDraw {
 
	const SubSprite *sub;           ///< only draw a rectangular part of the sprite
 
	int32 x;
 
	int32 y;
 
	int next;                       ///< next child to draw (-1 at the end)
 
};
 

	
 
/** Parent sprite that should be drawn */
 
struct ParentSpriteToDraw {
 
	SpriteID image;                 ///< sprite to draw
 
	SpriteID pal;                   ///< palette to use
 
	const SubSprite *sub;           ///< only draw a rectangular part of the sprite
 

	
 
	int32 x;                        ///< screen X coordinate of sprite
 
@@ -102,13 +103,13 @@ struct ParentSpriteToDraw {
 
	int zmax;                       ///< maximal world Z coordinate of bounding box
 

	
 
	int first_child;                ///< the first child to draw.
 
	bool comparison_done;           ///< Used during sprite sorting: true if sprite has been compared with all other sprites
 
};
 

	
 
/* Enumeration of multi-part foundations */
 
/** Enumeration of multi-part foundations */
 
enum FoundationPart {
 
	FOUNDATION_PART_NONE     = 0xFF,  ///< Neither foundation nor groundsprite drawn yet.
 
	FOUNDATION_PART_NORMAL   = 0,     ///< First part (normal foundation or no foundation)
 
	FOUNDATION_PART_HALFTILE = 1,     ///< Second part (halftile foundation)
 
	FOUNDATION_PART_END
 
};
 
@@ -116,19 +117,20 @@ enum FoundationPart {
 
typedef SmallVector<TileSpriteToDraw, 64> TileSpriteToDrawVector;
 
typedef SmallVector<StringSpriteToDraw, 4> StringSpriteToDrawVector;
 
typedef SmallVector<ParentSpriteToDraw, 64> ParentSpriteToDrawVector;
 
typedef SmallVector<ParentSpriteToDraw*, 64> ParentSpriteToSortVector;
 
typedef SmallVector<ChildScreenSpriteToDraw, 16> ChildScreenSpriteToDrawVector;
 

	
 
/** Data structure storing rendering information */
 
struct ViewportDrawer {
 
	DrawPixelInfo dpi;
 

	
 
	StringSpriteToDrawVector string_sprites_to_draw;
 
	TileSpriteToDrawVector tile_sprites_to_draw;
 
	ParentSpriteToDrawVector parent_sprites_to_draw;
 
	ParentSpriteToSortVector parent_sprites_to_sort;
 
	ParentSpriteToSortVector parent_sprites_to_sort; ///< Parent sprite pointer array used for sorting
 
	ChildScreenSpriteToDrawVector child_screen_sprites_to_draw;
 

	
 
	int *last_child;
 

	
 
	byte combine_sprites;
 

	
 
@@ -353,12 +355,18 @@ ViewPort *IsPtInWindowViewport(const Win
 
			IsInsideMM(y, vp->top, vp->top + vp->height))
 
		return vp;
 

	
 
	return NULL;
 
}
 

	
 
/**
 
 * Translate screen coordinate in a viewport to a tile coordinate
 
 * @param vp  Viewport that contains the (\a x, \a y) screen coordinate
 
 * @param x   Screen x coordinate
 
 * @param y   Screen y coordinate
 
 * @return Tile coordinate */
 
static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
 
{
 
	Point pt;
 
	int a,b;
 
	uint z;
 

	
 
@@ -1283,12 +1291,13 @@ static void ViewportDrawTileSprites(cons
 
	for (const TileSpriteToDraw *ts = tstdv->Begin(); ts != tsend; ++ts) {
 
		Point pt = RemapCoords(ts->x, ts->y, ts->z);
 
		DrawSprite(ts->image, ts->pal, pt.x, pt.y, ts->sub);
 
	}
 
}
 

	
 
/** Sort parent sprites pointer array */
 
static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv)
 
{
 
	ParentSpriteToDraw **psdvend = psdv->End();
 
	ParentSpriteToDraw **psd = psdv->Begin();
 
	while (psd != psdvend) {
 
		ParentSpriteToDraw *ps = *psd;