2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-11-23 05:12:05 +00:00

Moved the re-ordering of indices to the BSP creator instead of the BSP asset linker.

This commit is contained in:
LJW-Dev
2025-11-04 18:32:29 +08:00
parent 0f70c29532
commit c9aa8e373b
3 changed files with 10 additions and 17 deletions

View File

@@ -158,9 +158,12 @@ namespace
vertexVec.insert(vertexVec.end(), tempVertices.begin(), tempVertices.end());
// T6 uses unsigned shorts as their index type so we have to loop and convert them from an unsigned int
for (size_t idx = 0; idx < outIndices.size(); idx++)
for (size_t idx = 0; idx < outIndices.size(); idx += 3)
{
indexVec.emplace_back(static_cast<uint16_t>(outIndices[idx]));
// BO2's index ordering is opposite to the FBX, so its converted here
indexVec.emplace_back(static_cast<uint16_t>(outIndices[idx + 2]));
indexVec.emplace_back(static_cast<uint16_t>(outIndices[idx + 1]));
indexVec.emplace_back(static_cast<uint16_t>(outIndices[idx + 0]));
}
surfaceVec.emplace_back(surface);

View File

@@ -490,17 +490,10 @@ namespace BSP
{
int indexOfFirstIndex = surface.indexOfFirstIndex;
int indexOfFirstVertex = surface.indexOfFirstVertex;
for (int indexIdx = 0; indexIdx < surface.triCount * 3; indexIdx += 3)
for (int indexIdx = 0; indexIdx < surface.triCount * 3; indexIdx++)
{
int firstTriIndex = indexOfFirstIndex + indexIdx;
int triIndex0 = bsp->colWorld.indices[firstTriIndex + 0] + indexOfFirstVertex;
int triIndex1 = bsp->colWorld.indices[firstTriIndex + 1] + indexOfFirstVertex;
int triIndex2 = bsp->colWorld.indices[firstTriIndex + 2] + indexOfFirstVertex;
// triangle index ordering is opposite to blenders, so its converted here
triIndexVec.emplace_back(triIndex2);
triIndexVec.emplace_back(triIndex1);
triIndexVec.emplace_back(triIndex0);
int triIndex = bsp->colWorld.indices[indexOfFirstIndex + indexIdx] + indexOfFirstVertex;
triIndexVec.emplace_back(triIndex);
}
}
// the reinterpret_cast is used as triIndices is just a pointer to an array of indicies, and static_cast can't safely do the conversion

View File

@@ -44,12 +44,9 @@ namespace BSP
assert(indexCount % 3 == 0);
gfxWorld->draw.indexCount = static_cast<int>(indexCount);
gfxWorld->draw.indices = m_memory.Alloc<uint16_t>(indexCount);
for (size_t indexIdx = 0; indexIdx < indexCount; indexIdx += 3)
for (size_t indexIdx = 0; indexIdx < indexCount; indexIdx++)
{
// the editor orders their vertices opposite to bo2, so its converted here
gfxWorld->draw.indices[indexIdx + 2] = bsp->gfxWorld.indices.at(indexIdx + 0);
gfxWorld->draw.indices[indexIdx + 1] = bsp->gfxWorld.indices.at(indexIdx + 1);
gfxWorld->draw.indices[indexIdx + 0] = bsp->gfxWorld.indices.at(indexIdx + 2);
gfxWorld->draw.indices[indexIdx] = bsp->gfxWorld.indices.at(indexIdx);
}
}