chore: properly read uv data from gltf

This commit is contained in:
Jan 2024-09-05 19:09:23 +02:00
parent c261aef1ef
commit 26f4640194
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C
2 changed files with 24 additions and 3 deletions

View File

@ -17,7 +17,28 @@ float HalfFloat::ToFloat(const half_float_t half)
return 0.0f; return 0.0f;
} }
half_float_t HalfFloat::ToHalf(float f) half_float_t HalfFloat::ToHalf(const float f)
{ {
return 0; half_float_t v3;
int v6;
union
{
uint32_t u;
float f;
} result{};
result.f = f;
if (static_cast<int>((2 * result.u) ^ 0x80000000) >> 14 < 0x3FFF)
v6 = static_cast<int>((2 * result.u) ^ 0x80000000) >> 14;
else
v6 = 0x3FFF;
if (v6 > -16384)
v3 = static_cast<half_float_t>(v6);
else
v3 = 0xC000;
return (v3 & 0x3FFFu) | ((result.u >> 16) & 0xC000u);
} }

View File

@ -270,7 +270,7 @@ namespace
float coordinates[3]; float coordinates[3];
float normal[3]; float normal[3];
if (!positionAccessor->GetFloatVec3(vertexIndex, coordinates) || !normalAccessor->GetFloatVec3(vertexIndex, normal) if (!positionAccessor->GetFloatVec3(vertexIndex, coordinates) || !normalAccessor->GetFloatVec3(vertexIndex, normal)
|| !colorAccessor->GetFloatVec4(vertexIndex, vertex.color) || !colorAccessor->GetFloatVec2(vertexIndex, vertex.uv) || !colorAccessor->GetFloatVec4(vertexIndex, vertex.color) || !uvAccessor->GetFloatVec2(vertexIndex, vertex.uv)
|| !jointsAccessor->GetUnsignedVec4(vertexIndex, joints) || !weightsAccessor->GetFloatVec4(vertexIndex, weights)) || !jointsAccessor->GetUnsignedVec4(vertexIndex, joints) || !weightsAccessor->GetFloatVec4(vertexIndex, weights))
{ {
return false; return false;