Skip to content

Commit 8c560e6

Browse files
authored
refactor(heightmap): Clarify magic numbers related to VERTEX_BUFFER_TILE_LENGTH (#2079)
1 parent 9df76f7 commit 8c560e6

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

Core/GameEngineDevice/Include/W3DDevice/GameClient/HeightMap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include "W3DDevice/GameClient/WorldHeightMap.h"
3838
#include "W3DDevice/GameClient/BaseHeightMap.h"
3939

40-
#define VERTEX_BUFFER_TILE_LENGTH 32 //tiles of side length 32 (grid of 33x33 vertices).
4140

4241
// Adjust the triangles to make cliff sides most attractive. jba.
4342
#define FLIP_TRIANGLES 1

Core/GameEngineDevice/Include/W3DDevice/GameClient/WorldHeightMap.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ typedef std::vector<ICoord2D> VecICoord2D;
4242
/** MapObject class
4343
Not ref counted. Do not store pointers to this class. */
4444

45+
#define VERTEX_BUFFER_TILE_LENGTH 32 //tiles of side length 32 (grid of 33x33 vertices).
46+
4547
#define K_MIN_HEIGHT 0
4648
#define K_MAX_HEIGHT 255
4749

@@ -105,10 +107,10 @@ class WorldHeightMap : public RefCountClass,
105107
enum {TILE_4x4, TILE_6x6, TILE_8x8} m_tileMode;
106108
#endif
107109
enum {
108-
NORMAL_DRAW_WIDTH = 129,
109-
NORMAL_DRAW_HEIGHT = 129,
110-
STRETCH_DRAW_WIDTH = 65,
111-
STRETCH_DRAW_HEIGHT = 65
110+
NORMAL_DRAW_WIDTH = 1 + 4*VERTEX_BUFFER_TILE_LENGTH,
111+
NORMAL_DRAW_HEIGHT = 1 + 4*VERTEX_BUFFER_TILE_LENGTH,
112+
STRETCH_DRAW_WIDTH = 1 + 2*VERTEX_BUFFER_TILE_LENGTH,
113+
STRETCH_DRAW_HEIGHT = 1 + 2*VERTEX_BUFFER_TILE_LENGTH,
112114
};
113115

114116
protected:

Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ bool BaseHeightMapRenderObjClass::Cast_Ray(RayCollisionTestClass & raytest)
693693
Int EndCellX = 0;
694694
Int StartCellY = 0;
695695
Int EndCellY = 0;
696-
const Int overhang = 2*32+m_map->getBorderSizeInline(); // Allow picking past the edge for scrolling & objects.
696+
const Int overhang = 2*VERTEX_BUFFER_TILE_LENGTH + m_map->getBorderSizeInline(); // Allow picking past the edge for scrolling & objects.
697697
Vector3 minPt(MAP_XY_FACTOR*(-overhang), MAP_XY_FACTOR*(-overhang), -MAP_XY_FACTOR);
698698
Vector3 maxPt(MAP_XY_FACTOR*(m_map->getXExtent()+overhang),
699699
MAP_XY_FACTOR*(m_map->getYExtent()+overhang), MAP_HEIGHT_SCALE*m_map->getMaxHeightValue()+MAP_XY_FACTOR);

Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,8 +1170,8 @@ void HeightMapRenderObjClass::oversizeTerrain(Int tilesToOversize)
11701170
Int height = WorldHeightMap::NORMAL_DRAW_HEIGHT;
11711171
if (tilesToOversize>0 && tilesToOversize<5)
11721172
{
1173-
width += 32*tilesToOversize;
1174-
height += 32*tilesToOversize;
1173+
width += VERTEX_BUFFER_TILE_LENGTH * tilesToOversize;
1174+
height += VERTEX_BUFFER_TILE_LENGTH * tilesToOversize;
11751175
if (width>m_map->getXExtent())
11761176
width = m_map->getXExtent();
11771177
if (height>m_map->getYExtent())

0 commit comments

Comments
 (0)