fix heightmaps

This commit is contained in:
Asuro
2025-06-20 03:00:42 +02:00
parent 67c1489da0
commit ffcc5bd134

View File

@@ -123,14 +123,14 @@ namespace Game
startTime = bx::getHPCounter();
for (uint32_t v = 0; v < HeightMap::Height; ++v)
{
float vPos = mesh.MinPos.y + (float)v / HeightMap::Height * mesh.Size.y;
float vPos = mesh.MinPos.z + (float)v / HeightMap::Height * mesh.Size.z;
for (uint32_t u = 0; u < HeightMap::Width; ++u)
{
float uPos = mesh.MinPos.x + (float)u / HeightMap::Width * mesh.Size.x;
Gen::Vec3 rayStart = {uPos, vPos, SIZE_LIMIT};
Gen::Vec3 rayEnd = {uPos, vPos, -SIZE_LIMIT};
Gen::Vec3 rayStart = {uPos, mesh.MinPos.y, vPos};
Gen::Vec3 rayEnd = {uPos, mesh.MaxPos.y, vPos};
Gen::Vec3 ptOut;
for (int16_t i = 0; i < indexBufferView.byteLength; i += indexStride * 3)
@@ -148,8 +148,8 @@ namespace Game
reinterpret_cast<Gen::Vec3*>(&posBuffer.data[posBufferView.byteOffset + *idxC * posStride]);
if (Gen::RayTriangleIntersect(rayStart, rayEnd, *triA, *triB, *triC, ptOut))
{
float len = mesh.MaxPos.z - ptOut.z;
uint8_t val = (uint8_t)(len / mesh.Size.z * UINT8_MAX);
float len = ptOut.y - mesh.MinPos.y;
uint8_t val = (uint8_t)(len / mesh.Size.y * UINT8_MAX);
int32_t idx = v * HeightMap::Width + u;
if (mesh.Height.Values[idx] < val)
{
@@ -157,7 +157,7 @@ namespace Game
}
if (len < 0.0f)
{
LOG_ONCE("%f / %f = %u", len, mesh.Size.z, val);
LOG_ONCE("%f / %f = %u", len, mesh.Size.y, val);
}
}
}