2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-11-22 21:02:07 +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()); 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 // 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); surfaceVec.emplace_back(surface);

View File

@@ -490,17 +490,10 @@ namespace BSP
{ {
int indexOfFirstIndex = surface.indexOfFirstIndex; int indexOfFirstIndex = surface.indexOfFirstIndex;
int indexOfFirstVertex = surface.indexOfFirstVertex; 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 triIndex = bsp->colWorld.indices[indexOfFirstIndex + indexIdx] + indexOfFirstVertex;
int triIndex0 = bsp->colWorld.indices[firstTriIndex + 0] + indexOfFirstVertex; triIndexVec.emplace_back(triIndex);
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);
} }
} }
// 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 // 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); assert(indexCount % 3 == 0);
gfxWorld->draw.indexCount = static_cast<int>(indexCount); gfxWorld->draw.indexCount = static_cast<int>(indexCount);
gfxWorld->draw.indices = m_memory.Alloc<uint16_t>(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] = bsp->gfxWorld.indices.at(indexIdx);
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);
} }
} }