aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/Map.cpp58
-rw-r--r--src/game/Map.h4
2 files changed, 59 insertions, 3 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index 2211aa5b69c..8d0b40c90ac 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -1082,8 +1082,8 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const
int gx=(int)(32-x/SIZE_OF_GRIDS); //grid x
int gy=(int)(32-y/SIZE_OF_GRIDS); //grid y
- float lx=MAP_RESOLUTION*(32 -x/SIZE_OF_GRIDS - gx);
- float ly=MAP_RESOLUTION*(32 -y/SIZE_OF_GRIDS - gy);
+ float lx=128*(32 -x/SIZE_OF_GRIDS - gx);
+ float ly=128*(32 -y/SIZE_OF_GRIDS - gy);
// ensure GridMap is loaded
const_cast<Map*>(this)->EnsureGridCreated(GridPair(63-gx,63-gy));
@@ -1095,10 +1095,63 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const
int lx_int = (int)lx;
int ly_int = (int)ly;
+ lx -= lx_int;
+ ly -= ly_int;
+
+ float a,b,c;
+ if (lx+ly < 1)
+ {
+ if (lx > ly)
+ {
+ // 1
+ float h1 = gmap->v9[lx_int][ly_int];
+ float h2 = gmap->v9[lx_int+1][ly_int];
+ float h5 = 2 * gmap->v8[lx_int][ly_int];
+ a = h2-h1;
+ b = h5-h1-h2;
+ c = h1;
+ }
+ else
+ {
+ // 2
+ float h1 = gmap->v9[lx_int][ly_int];
+ float h3 = gmap->v9[lx_int][ly_int+1];
+ float h5 = 2 * gmap->v8[lx_int][ly_int];
+ a = h5 - h1 - h3;
+ b = h3 - h1;
+ c = h1;
+ }
+ }
+ else
+ {
+ if (lx > ly)
+ {
+ // 3
+ float h2 = gmap->v9[lx_int+1][ly_int];
+ float h4 = gmap->v9[lx_int+1][ly_int+1];
+ float h5 = 2 * gmap->v8[lx_int][ly_int];
+ a = h2 + h4 - h5;
+ b = h4 - h2;
+ c = h5 - h4;
+ }
+ else
+ {
+ // 4
+ float h3 = gmap->v9[lx_int][ly_int+1];
+ float h4 = gmap->v9[lx_int+1][ly_int+1];
+ float h5 = 2 * gmap->v8[lx_int][ly_int];
+ a = h4 - h3;
+ b = h3 + h4 - h5;
+ c = h5 - h4;
+ }
+ }
+ float _mapheight = a * lx + b * ly + c;
+
// In some very rare case this will happen. Need find a better way.
if(lx_int == MAP_RESOLUTION) --lx_int;
if(ly_int == MAP_RESOLUTION) --ly_int;
+ /*
float zi[4];
// Probe 4 nearest points (except border cases)
zi[0] = gmap->Z[lx_int][ly_int];
@@ -1117,6 +1170,7 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const
// Use the simplified bilinear equation, as described in [url="http://en.wikipedia.org/wiki/Bilinear_interpolation"]http://en.wikipedia.org/wiki/Bilinear_interpolation[/url]
float _mapheight = b[0] + (b[1]*fact_x) + (b[2]*fact_y) + (b[3]*fact_x*fact_y);
+ */
// look from a bit higher pos to find the floor, ignore under surface case
if(z + 2.0f > _mapheight)
mapHeight = _mapheight;
diff --git a/src/game/Map.h b/src/game/Map.h
index fb921309cba..10d8c914cc2 100644
--- a/src/game/Map.h
+++ b/src/game/Map.h
@@ -75,7 +75,9 @@ typedef struct
uint16 area_flag[16][16];
uint8 terrain_type[16][16];
float liquid_level[128][128];
- float Z[MAP_RESOLUTION][MAP_RESOLUTION];
+ float v9[16 * 8 + 1][16 * 8 + 1];
+ float v8[16 * 8][16 * 8];
+ //float Z[MAP_RESOLUTION][MAP_RESOLUTION];
}GridMap;
struct CreatureMover