Răsfoiți Sursa

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
markusobi 8 ani în urmă
părinte
comite
b42f66bea4
1 a modificat fișierele cu 6 adăugiri și 6 ștergeri
  1. 6 6
      examples/27-terrain/terrain.cpp

+ 6 - 6
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;
 			}