Example 27 Terrain: Fixed incorrect height display in mode Height Texture (#1266)

* fixed incorrect out of bounds check in terrain example

* added texture coordinates offset for texture2DLod lookup

* fixed compile error
This commit is contained in:
markusobi 2017-10-25 18:28:40 +02:00 committed by Branimir Karadžić
parent c63317899b
commit b42f66bea4

View File

@ -197,8 +197,8 @@ public:
vert->m_x = (float)x;
vert->m_y = m_terrain.m_heightMap[(y * s_terrainSize) + x];
vert->m_z = (float)y;
vert->m_u = (float)x / (float)s_terrainSize;
vert->m_v = (float)y / (float)s_terrainSize;
vert->m_u = (x + 0.5f) / s_terrainSize;
vert->m_v = (y + 0.5f) / s_terrainSize;
m_terrain.m_vertexCount++;
}
@ -298,14 +298,14 @@ public:
{
int32_t brush_x = _x + area_x;
if (brush_x < 0
|| brush_x > (int32_t)s_terrainSize)
|| brush_x >= (int32_t)s_terrainSize)
{
continue;
}
int32_t brush_y = _y + area_y;
if (brush_y < 0
|| brush_y > (int32_t)s_terrainSize)
|| brush_y >= (int32_t)s_terrainSize)
{
continue;
}
@ -365,9 +365,9 @@ public:
bx::vec3Add(pos, pos, ray_dir);
if (pos[0] < 0
|| pos[0] > s_terrainSize
|| pos[0] >= s_terrainSize
|| pos[2] < 0
|| pos[2] > s_terrainSize)
|| pos[2] >= s_terrainSize)
{
continue;
}