summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tiletex.h
diff options
context:
space:
mode:
authorEnne Walker <ennewalker@users.sourceforge.net>2010-01-17 19:33:07 -0500
committerEnne Walker <ennewalker@users.sourceforge.net>2010-01-17 19:53:13 -0500
commit227420e531ae481224410978e01c834507cc61d2 (patch)
tree93b0bbe0f909bb20820a61e1836df1bb03736636 /crawl-ref/source/tiletex.h
parentf903462645b80653998fe987732752038be862d4 (diff)
downloadcrawl-ref-227420e531ae481224410978e01c834507cc61d2.tar.gz
crawl-ref-227420e531ae481224410978e01c834507cc61d2.zip
Tile transparency in water without overlays.
In order for jpeg's waves to work on deep water as well as shallow, we need to not use partially transparent overlays to simulate an actor or an item being submerged. Now, non-flying objects on water will be drawn transparently to blend with the water below. This should mostly look the same, except it will now work on top of waves and will not require a mask for each water type. As a nice side-effect, ghosts are now transparent again and the water on top of submerged objects now animates properly. See the comments in tilebuf.cc for details. The mask tile itself can be adjusted to change the water level, but the parameters to SubmergedTileBuffer will need to be changed to compensate depending on what the new art looks like.
Diffstat (limited to 'crawl-ref/source/tiletex.h')
-rw-r--r--crawl-ref/source/tiletex.h41
1 files changed, 28 insertions, 13 deletions
diff --git a/crawl-ref/source/tiletex.h b/crawl-ref/source/tiletex.h
index a50b85dc26..c95067a3fe 100644
--- a/crawl-ref/source/tiletex.h
+++ b/crawl-ref/source/tiletex.h
@@ -76,12 +76,13 @@ public:
void set_info(int max, tile_info_func *info);
inline const tile_info &get_info(int idx) const;
- inline void get_coords(int idx, int ofs_x, int ofs_y,
+ inline bool get_coords(int idx, int ofs_x, int ofs_y,
float &pos_sx, float &pos_sy,
float &pos_ex, float &pos_ey,
float &tex_sx, float &tex_sy,
float &tex_ex, float &tex_ey,
- bool centre = true, int ymax = -1) const;
+ bool centre = true, int ymin = -1, int ymax = -1,
+ float tile_x = TILE_X, float tile_y = TILE_Y) const;
protected:
int m_tile_max;
@@ -94,12 +95,13 @@ inline const tile_info &TilesTexture::get_info(int idx) const
return m_info_func(idx);
}
-inline void TilesTexture::get_coords(int idx, int ofs_x, int ofs_y,
+inline bool TilesTexture::get_coords(int idx, int ofs_x, int ofs_y,
float &pos_sx, float &pos_sy,
float &pos_ex, float &pos_ey,
float &tex_sx, float &tex_sy,
float &tex_ex, float &tex_ey,
- bool centre, int ymax) const
+ bool centre, int ymin, int ymax,
+ float tile_x, float tile_y) const
{
const tile_info &inf = get_info(idx);
@@ -110,19 +112,32 @@ inline void TilesTexture::get_coords(int idx, int ofs_x, int ofs_y,
int size_ox = centre ? TILE_X / 2 - inf.width / 2 : 0;
int size_oy = centre ? TILE_Y - inf.height : 0;
- int ey = inf.ey;
- if (ymax > 0)
- ey = std::min(inf.sy + ymax - inf.offset_y, ey);
+ int pos_sy_adjust = ofs_y + inf.offset_y + size_oy;
+ int pos_ey_adjust = pos_sy_adjust + inf.ey - inf.sy;
- pos_sx += (ofs_x + inf.offset_x + size_ox) / (float) TILE_X;
- pos_sy += (ofs_y + inf.offset_y + size_oy) / (float) TILE_Y;
- pos_ex = pos_sx + (inf.ex - inf.sx) / (float)TILE_X;
- pos_ey = pos_sy + (ey - inf.sy) / (float)TILE_Y;
+ int sy = pos_sy_adjust;
+ if (ymin >= 0)
+ sy = std::max(ymin, sy);
+
+ int ey = pos_ey_adjust;
+ if (ymax >= 0)
+ ey = std::min(ymax, ey);
+
+ // Nothing to draw.
+ if (sy >= ey)
+ return (false);
+
+ pos_sx += (ofs_x + inf.offset_x + size_ox) / tile_x;
+ pos_sy += sy / tile_y;
+ pos_ex = pos_sx + (inf.ex - inf.sx) / tile_x;
+ pos_ey = pos_sy + (ey - sy) / tile_y;
tex_sx = inf.sx / fwidth;
- tex_sy = inf.sy / fheight;
+ tex_sy = (inf.sy + sy - pos_sy_adjust) / fheight;
tex_ex = inf.ex / fwidth;
- tex_ey = ey / fheight;
+ tex_ey = (inf.ey + ey - pos_ey_adjust) / fheight;
+
+ return (true);
}
#endif