higher resolution for waterlevel

Interpret the waterlevel value as tenths of a cube.

This makes the waterlevel variable a float value to the user, while the
map file still stores an integer value - but now it is interpreted
differently - for example, a waterlevel value of 123 now means 12.3 cubes
instead of 123. Old map files are converted during loading.

Note: the values of waterlevel and hdr.waterlevel need to be in sync.

DOCREF waterlevel
This commit is contained in:
ac-stef
2015-05-18 14:59:41 +02:00
parent b1b789eefc
commit ea480a7b0c
15 changed files with 39 additions and 32 deletions
+10 -2
View File
@@ -4,7 +4,15 @@ int wx1, wy1, wx2, wy2;
float wsx1, wsy1, wsx2, wsy2;
VARP(watersubdiv, 1, 4, 64);
VARF(waterlevel, -128, -128, 127, if(!noteditmode("waterlevel")) { hdr.waterlevel = waterlevel; unsavededits++; });
FVARF(waterlevel, -10000, -10000, 127,
{
if(!noteditmode("waterlevel"))
{
hdr.waterlevel = waterlevel * WATERLEVELSCALING;
unsavededits++;
}
waterlevel = float(hdr.waterlevel) / WATERLEVELSCALING; // waterlevel and hdr.waterlevel need to be kept in sync
});
void setwatercolor(const char *r, const char *g, const char *b, const char *a)
{
@@ -274,7 +282,7 @@ void calcwaterscissor()
loopi(4)
{
vec4 &p = v[i];
mvpmatrix.transform(vec(i&1 ? wx2 : wx1, i&2 ? wy2 : wy1, hdr.waterlevel-0.3f), p);
mvpmatrix.transform(vec(i&1 ? wx2 : wx1, i&2 ? wy2 : wy1, waterlevel - 0.3f), p);
if(p.z >= 0)
{
float x = p.x / p.w, y = p.y / p.w;