Skip to content

Commit

Permalink
Traktor: Prevent checking UV channel name for each vertex when import…
Browse files Browse the repository at this point in the history
…ing FBX.
  • Loading branch information
apistol78 committed May 2, 2024
1 parent dbd476a commit b53006c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions code/Model/Formats/Fbx/MeshConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ bool convertMesh(
}
}

// Setup all texcoord channels.
StaticVector< uint32_t, 64 > texCoordChannels;
texCoordChannels.resize(meshNode->mesh->uv_sets.count);
for (size_t k = 0; k < meshNode->mesh->uv_sets.count; ++k)
{
const ufbx_uv_set& uvSet = meshNode->mesh->uv_sets.data[k];
if (uvSet.vertex_uv.exists)
{
const std::wstring channelName = mbstows(uvSet.name.data);
const uint32_t channel = outModel.addUniqueTexCoordChannel(channelName);
texCoordChannels[k] = channel;
}
}

// Convert polygons.
for (size_t i = 0; i < meshNode->mesh->num_faces; ++i)
{
Expand Down Expand Up @@ -139,8 +153,7 @@ bool convertMesh(
const ufbx_uv_set& uvSet = meshNode->mesh->uv_sets.data[k];
if (uvSet.vertex_uv.exists)
{
const std::wstring channelName = mbstows(uvSet.name.data);
const uint32_t channel = outModel.addUniqueTexCoordChannel(channelName);
const uint32_t channel = texCoordChannels[k];
vertex.setTexCoord(channel, outModel.addUniqueTexCoord(convertVector2(
ufbx_get_vertex_vec2(&uvSet.vertex_uv, vertexIndex)
) * Vector2(1.0f, -1.0f) + Vector2(0.0f, 1.0f)));
Expand Down

0 comments on commit b53006c

Please sign in to comment.