From b42f66bea4e0d82eee151017a3d8a3b9429de024 Mon Sep 17 00:00:00 2001 From: markusobi Date: Wed, 25 Oct 2017 18:28:40 +0200 Subject: [PATCH] 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 --- examples/27-terrain/terrain.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/27-terrain/terrain.cpp b/examples/27-terrain/terrain.cpp index e9ee604c0..82a6012ae 100644 --- a/examples/27-terrain/terrain.cpp +++ b/examples/27-terrain/terrain.cpp @@ -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; }