mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-06-06 16:52:35 +00:00
WIP unique tree for each material type
This commit is contained in:
@@ -212,6 +212,26 @@ namespace BSP
|
||||
if (leafObjectCount > highestLeafObjectCount)
|
||||
highestLeafObjectCount = leafObjectCount;
|
||||
|
||||
std::vector<unsigned int> uniqueMaterials;
|
||||
for (size_t objIdx = 0; objIdx < leafObjectCount; objIdx++)
|
||||
{
|
||||
int partitionIdx = tree->leaf->getObject(objIdx)->partitionIndex;
|
||||
unsigned materialIndex = partitionToMaterialMap[partitionIdx];
|
||||
bool foundIdx = false;
|
||||
for (unsigned int uniqueMat : uniqueMaterials)
|
||||
{
|
||||
if (uniqueMat == materialIndex)
|
||||
{
|
||||
foundIdx = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundIdx)
|
||||
uniqueMaterials.emplace_back(materialIndex);
|
||||
}
|
||||
|
||||
con::info("{} {}", uniqueMaterials.size(), uniqueMaterials[0]);
|
||||
|
||||
// BO2 has a maximum limit of 128 children per AABB tree (essentially),
|
||||
// so this is fixed by adding multiple parent AABB trees that hold 128 children each
|
||||
size_t result = leafObjectCount / BSPGameConstants::MAX_AABB_TREE_CHILDREN;
|
||||
@@ -533,7 +553,7 @@ namespace BSP
|
||||
|
||||
partitionVec.emplace_back(partition);
|
||||
|
||||
partitionToSurfaceMap.emplace_back(surfIdx);
|
||||
partitionToMaterialMap.emplace_back(surface.materialIndex);
|
||||
}
|
||||
}
|
||||
clipMap->partitionCount = static_cast<int>(partitionVec.size());
|
||||
|
||||
@@ -31,8 +31,7 @@ namespace BSP
|
||||
std::vector<cLeaf_s> leafVec;
|
||||
std::vector<CollisionAabbTree> AABBTreeVec;
|
||||
size_t highestLeafObjectCount = 0;
|
||||
std::vector<unsigned> partitionToSurfaceMap;
|
||||
std::vector<unsigned> surfaceToMaterialMap;
|
||||
std::vector<size_t> partitionToMaterialMap;
|
||||
void addAABBTreeFromLeaf(clipMap_t* clipMap, BSPTree* tree, size_t* out_parentCount, size_t* out_parentStartIndex);
|
||||
int16_t loadBSPNode(clipMap_t* clipMap, BSPTree* tree);
|
||||
bool loadBSPTree(clipMap_t* clipMap, BSPData* bsp);
|
||||
|
||||
Reference in New Issue
Block a user