Revert "fix(rendering): remap M2 vertex bone indices through bone lookup table"

This reverts commit 04ad88330f.
This commit is contained in:
Kelsi 2026-04-03 22:26:14 -07:00
parent 04ad88330f
commit 634bac6c7a
2 changed files with 5 additions and 19 deletions

View file

@ -1486,17 +1486,7 @@ void CharacterRenderer::setupModelBuffers(M2ModelGPU& gpuModel) {
auto& dst = gpuVerts[i];
dst.position = src.position;
std::memcpy(dst.boneWeights, src.boneWeights, 4);
// Remap bone indices through the bone lookup table.
// M2 vertex bone indices are lookup table indices, not direct bone indices.
for (int j = 0; j < 4; j++) {
uint8_t idx = src.boneIndices[j];
if (idx < model.boneLookupTable.size()) {
dst.boneIndices[j] = static_cast<uint8_t>(
std::min<uint16_t>(model.boneLookupTable[idx], 255));
} else {
dst.boneIndices[j] = 0;
}
}
std::memcpy(dst.boneIndices, src.boneIndices, 4);
dst.normal = src.normal;
dst.texCoords = src.texCoords[0]; // Use first UV set
dst.tangent = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f); // default

View file

@ -1158,14 +1158,10 @@ bool M2Renderer::loadModel(const pipeline::M2Model& model, uint32_t modelId) {
vertexData.push_back(w1);
vertexData.push_back(w2);
vertexData.push_back(w3);
// Remap bone indices through the bone lookup table.
// M2 vertex bone indices are lookup table indices, not direct bone indices.
for (int j = 0; j < 4; j++) {
uint8_t idx = v.boneIndices[j];
uint16_t actual = (idx < model.boneLookupTable.size())
? model.boneLookupTable[idx] : 0;
vertexData.push_back(static_cast<float>(std::min(actual, uint16_t(127))));
}
vertexData.push_back(static_cast<float>(std::min(v.boneIndices[0], uint8_t(127))));
vertexData.push_back(static_cast<float>(std::min(v.boneIndices[1], uint8_t(127))));
vertexData.push_back(static_cast<float>(std::min(v.boneIndices[2], uint8_t(127))));
vertexData.push_back(static_cast<float>(std::min(v.boneIndices[3], uint8_t(127))));
}
// Upload vertex buffer to GPU