2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-11-22 21:02:07 +00:00

chore: use auto instead of repeated types

This commit is contained in:
Jan Laupetin
2025-11-09 22:09:06 +01:00
parent e9e0c7f511
commit 9471cbc1f4
9 changed files with 47 additions and 47 deletions

View File

@@ -142,7 +142,7 @@ namespace BSP
}
else
{
const PlaneSide side = node->objectIsInFront(*object);
const auto side = node->objectIsInFront(*object);
if (side == SIDE_FRONT)
{
node->front->addObjectToTree(std::move(object));

View File

@@ -259,7 +259,7 @@ namespace BSP
}
}
std::unique_ptr<BSPData> bsp = std::make_unique<BSPData>();
auto bsp = std::make_unique<BSPData>();
bsp->name = mapName;
bsp->bspName = "maps/mp/" + mapName + ".d3dbsp";

View File

@@ -75,9 +75,9 @@ namespace BSP
float BSPUtil::distBetweenPoints(const vec3_t& p1, const vec3_t& p2)
{
const float x = p2.x - p1.x;
const float y = p2.y - p1.y;
const float z = p2.z - p1.z;
const auto x = p2.x - p1.x;
const auto y = p2.y - p1.y;
const auto z = p2.z - p1.z;
return sqrtf((x * x) + (y * y) + (z * z));
}
@@ -85,16 +85,16 @@ namespace BSP
// angles are in euler degrees
void BSPUtil::convertAnglesToAxis(const vec3_t* angles, vec3_t* axis)
{
const float xRadians = angles->x * 0.017453292f; // M_PI / 180.0f
const float yRadians = angles->y * 0.017453292f; // M_PI / 180.0f
const float zRadians = angles->z * 0.017453292f; // M_PI / 180.0f
const auto xRadians = angles->x * 0.017453292f; // M_PI / 180.0f
const auto yRadians = angles->y * 0.017453292f; // M_PI / 180.0f
const auto zRadians = angles->z * 0.017453292f; // M_PI / 180.0f
const float cosX = cos(xRadians);
const float sinX = sin(xRadians);
const float cosY = cos(yRadians);
const float sinY = sin(yRadians);
const float cosZ = cos(zRadians);
const float sinZ = sin(zRadians);
const auto cosX = cos(xRadians);
const auto sinX = sin(xRadians);
const auto cosY = cos(yRadians);
const auto sinY = sin(yRadians);
const auto cosZ = cos(zRadians);
const auto sinZ = sin(zRadians);
axis[0].x = cosX * cosY;
axis[0].y = cosX * sinY;

View File

@@ -16,7 +16,7 @@ namespace BSP
if (assetName.length() == 0)
return nullptr;
FootstepTableDef* footstepTable = m_memory.Alloc<FootstepTableDef>();
auto* footstepTable = m_memory.Alloc<FootstepTableDef>();
footstepTable->name = m_memory.Dup(assetName.c_str());
memset(footstepTable->sndAliasTable, 0, sizeof(footstepTable->sndAliasTable));
@@ -73,32 +73,32 @@ namespace BSP
MapEntsLinker mapEntsLinker(m_memory, m_search_path, m_context);
SkinnedVertsLinker skinnedVertsLinker(m_memory, m_search_path, m_context);
ComWorld* comWorld = comWorldLinker.linkComWorld(bsp);
auto* comWorld = comWorldLinker.linkComWorld(bsp);
if (comWorld == nullptr)
return false;
m_context.AddAsset<AssetComWorld>(comWorld->name, comWorld);
MapEnts* mapEnts = mapEntsLinker.linkMapEnts(bsp);
auto* mapEnts = mapEntsLinker.linkMapEnts(bsp);
if (mapEnts == nullptr)
return false;
m_context.AddAsset<AssetMapEnts>(mapEnts->name, mapEnts);
GameWorldMp* gameWorldMp = gameWorldMpLinker.linkGameWorldMp(bsp);
auto* gameWorldMp = gameWorldMpLinker.linkGameWorldMp(bsp);
if (gameWorldMp == nullptr)
return false;
m_context.AddAsset<AssetGameWorldMp>(gameWorldMp->name, gameWorldMp);
SkinnedVertsDef* skinnedVerts = skinnedVertsLinker.linkSkinnedVerts(bsp);
auto* skinnedVerts = skinnedVertsLinker.linkSkinnedVerts(bsp);
if (skinnedVerts == nullptr)
return false;
m_context.AddAsset<AssetSkinnedVerts>(skinnedVerts->name, skinnedVerts);
GfxWorld* gfxWorld = gfxWorldLinker.linkGfxWorld(bsp); // requires mapents asset
auto* gfxWorld = gfxWorldLinker.linkGfxWorld(bsp); // requires mapents asset
if (gfxWorld == nullptr)
return false;
m_context.AddAsset<AssetGfxWorld>(gfxWorld->name, gfxWorld);
clipMap_t* clipMap = clipMapLinker.linkClipMap(bsp); // requires gfxworld and mapents asset
auto* clipMap = clipMapLinker.linkClipMap(bsp); // requires gfxworld and mapents asset
if (clipMap == nullptr)
return false;
m_context.AddAsset<AssetClipMap>(clipMap->name, clipMap);

View File

@@ -129,7 +129,7 @@ namespace BSP
// Submodels are used for the world and map ent collision (triggers, bomb zones, etc)
auto gfxWorldAsset = m_context.LoadDependency<AssetGfxWorld>(bsp.bspName);
assert(gfxWorldAsset != nullptr);
GfxWorld* gfxWorld = gfxWorldAsset->Asset();
auto* gfxWorld = gfxWorldAsset->Asset();
// Right now there is only one submodel, the world sub model
assert(gfxWorld->modelCount == 1);
@@ -137,7 +137,7 @@ namespace BSP
clipMap.numSubModels = 1;
clipMap.cmodels = m_memory.Alloc<cmodel_t>(clipMap.numSubModels);
GfxBrushModel* gfxModel = &gfxWorld->models[0];
auto* gfxModel = &gfxWorld->models[0];
clipMap.cmodels[0].mins.x = gfxModel->bounds[0].x;
clipMap.cmodels[0].mins.y = gfxModel->bounds[0].y;
clipMap.cmodels[0].mins.z = gfxModel->bounds[0].z;
@@ -420,14 +420,14 @@ namespace BSP
}
BSPUtil::updateAABBWithPoint(vertex, worldMins, worldMaxs);
}
std::unique_ptr<BSPTree> tree = std::make_unique<BSPTree>(worldMins.x, worldMins.y, worldMins.z, worldMaxs.x, worldMaxs.y, worldMaxs.z, 0);
const auto tree = std::make_unique<BSPTree>(worldMins.x, worldMins.y, worldMins.z, worldMaxs.x, worldMaxs.y, worldMaxs.z, 0);
assert(!tree->isLeaf);
for (int partitionIdx = 0; partitionIdx < clipMap.partitionCount; partitionIdx++)
{
vec3_t partitionMins;
vec3_t partitionMaxs;
CollisionPartition* partition = &clipMap.partitions[partitionIdx];
auto* partition = &clipMap.partitions[partitionIdx];
for (int uindIdx = 0; uindIdx < partition->nuinds; uindIdx++)
{
uint16_t uind = clipMap.info.uinds[partition->fuind + uindIdx];
@@ -440,7 +440,7 @@ namespace BSP
}
BSPUtil::updateAABBWithPoint(vert, partitionMins, partitionMaxs);
}
std::shared_ptr<BSPObject> currObject =
auto currObject =
std::make_shared<BSPObject>(partitionMins.x, partitionMins.y, partitionMins.z, partitionMaxs.x, partitionMaxs.y, partitionMaxs.z, partitionIdx);
tree->addObjectToTree(std::move(currObject));
}
@@ -491,11 +491,11 @@ namespace BSP
std::vector<uint16_t> triIndexVec;
for (const BSPSurface& surface : bsp.colWorld.surfaces)
{
const int indexOfFirstIndex = surface.indexOfFirstIndex;
const int indexOfFirstVertex = surface.indexOfFirstVertex;
for (int indexIdx = 0; indexIdx < surface.triCount * 3; indexIdx++)
const auto indexOfFirstIndex = surface.indexOfFirstIndex;
const auto indexOfFirstVertex = surface.indexOfFirstVertex;
for (auto indexIdx = 0; indexIdx < surface.triCount * 3; indexIdx++)
{
int triIndex = bsp.colWorld.indices[indexOfFirstIndex + indexIdx] + indexOfFirstVertex;
auto triIndex = bsp.colWorld.indices[indexOfFirstIndex + indexIdx] + indexOfFirstVertex;
triIndexVec.emplace_back(triIndex);
}
}
@@ -512,9 +512,9 @@ namespace BSP
// partitions are made for each triangle, not one for each surface.
// one for each surface causes physics bugs, as the entire bounding box is considered solid instead of the surface itself (for some reason).
// so a partition is made for each triangle which removes the physics bugs but likely makes the game run slower
const int indexOfFirstTri = surface.indexOfFirstIndex / 3;
const int indexOfFirstVertex = surface.indexOfFirstVertex;
for (int triIdx = 0; triIdx < surface.triCount; triIdx++)
const auto indexOfFirstTri = surface.indexOfFirstIndex / 3;
const auto indexOfFirstVertex = surface.indexOfFirstVertex;
for (auto triIdx = 0; triIdx < surface.triCount; triIdx++)
{
CollisionPartition partition;
partition.triCount = 1;
@@ -524,7 +524,7 @@ namespace BSP
partition.fuind = static_cast<int>(uniqueIndicesVec.size());
// All tri indices are unique since there is only one tri per partition
uint16_t* tri = clipMap.triIndices[partition.firstTri];
auto* tri = clipMap.triIndices[partition.firstTri];
uniqueIndicesVec.emplace_back(tri[0]);
uniqueIndicesVec.emplace_back(tri[1]);
uniqueIndicesVec.emplace_back(tri[2]);

View File

@@ -24,7 +24,7 @@ namespace BSP
gameWorldMp->path.nodeTreeCount = 0;
// The game has 128 empty nodes allocated
const int extraNodeCount = gameWorldMp->path.nodeCount + 128;
const auto extraNodeCount = gameWorldMp->path.nodeCount + 128;
gameWorldMp->path.nodes = m_memory.Alloc<pathnode_t>(extraNodeCount);
gameWorldMp->path.basenodes = m_memory.Alloc<pathbasenode_t>(extraNodeCount);
gameWorldMp->path.pathVis = nullptr;

View File

@@ -675,11 +675,11 @@ namespace BSP
gfxWorld.dpvsDyn.dynEntClientWordCount[1] = 0;
gfxWorld.dpvsDyn.usageCount = 0;
const int dynEntCellBitsSize = gfxWorld.dpvsDyn.dynEntClientWordCount[0] * gfxWorld.dpvsPlanes.cellCount;
const auto dynEntCellBitsSize = gfxWorld.dpvsDyn.dynEntClientWordCount[0] * gfxWorld.dpvsPlanes.cellCount;
gfxWorld.dpvsDyn.dynEntCellBits[0] = m_memory.Alloc<unsigned int>(dynEntCellBitsSize);
gfxWorld.dpvsDyn.dynEntCellBits[1] = nullptr;
const int dynEntVisData0Size = gfxWorld.dpvsDyn.dynEntClientWordCount[0] * 32;
const auto dynEntVisData0Size = gfxWorld.dpvsDyn.dynEntClientWordCount[0] * 32;
gfxWorld.dpvsDyn.dynEntVisData[0][0] = m_memory.Alloc<char>(dynEntVisData0Size);
gfxWorld.dpvsDyn.dynEntVisData[0][1] = m_memory.Alloc<char>(dynEntVisData0Size);
gfxWorld.dpvsDyn.dynEntVisData[0][2] = m_memory.Alloc<char>(dynEntVisData0Size);
@@ -687,7 +687,7 @@ namespace BSP
gfxWorld.dpvsDyn.dynEntVisData[1][1] = nullptr;
gfxWorld.dpvsDyn.dynEntVisData[1][2] = nullptr;
const unsigned int dynEntShadowVisCount = gfxWorld.dpvsDyn.dynEntClientCount[0] * (gfxWorld.primaryLightCount - gfxWorld.sunPrimaryLightIndex - 1);
const auto dynEntShadowVisCount = gfxWorld.dpvsDyn.dynEntClientCount[0] * (gfxWorld.primaryLightCount - gfxWorld.sunPrimaryLightIndex - 1);
gfxWorld.primaryLightDynEntShadowVis[0] = m_memory.Alloc<unsigned int>(dynEntShadowVisCount);
gfxWorld.primaryLightDynEntShadowVis[1] = nullptr;
@@ -697,14 +697,14 @@ namespace BSP
bool GfxWorldLinker::loadOutdoors(GfxWorld& gfxWorld) const
{
const float xRecip = 1.0f / (gfxWorld.maxs.x - gfxWorld.mins.x);
const float xScale = -(xRecip * gfxWorld.mins.x);
const auto xRecip = 1.0f / (gfxWorld.maxs.x - gfxWorld.mins.x);
const auto xScale = -(xRecip * gfxWorld.mins.x);
const float yRecip = 1.0f / (gfxWorld.maxs.y - gfxWorld.mins.y);
const float yScale = -(yRecip * gfxWorld.mins.y);
const auto yRecip = 1.0f / (gfxWorld.maxs.y - gfxWorld.mins.y);
const auto yScale = -(yRecip * gfxWorld.mins.y);
const float zRecip = 1.0f / (gfxWorld.maxs.z - gfxWorld.mins.z);
const float zScale = -(zRecip * gfxWorld.mins.z);
const auto zRecip = 1.0f / (gfxWorld.maxs.z - gfxWorld.mins.z);
const auto zScale = -(zRecip * gfxWorld.mins.z);
memset(gfxWorld.outdoorLookupMatrix, 0, sizeof(gfxWorld.outdoorLookupMatrix));

View File

@@ -13,7 +13,7 @@ namespace BSP
{
// Pretty sure maxSkinnedVerts relates to the max amount of xmodel skinned verts a map will have
// But setting it to the world vertex count seems to work
T6::SkinnedVertsDef* skinnedVerts = m_memory.Alloc<T6::SkinnedVertsDef>();
auto* skinnedVerts = m_memory.Alloc<T6::SkinnedVertsDef>();
skinnedVerts->name = m_memory.Dup("skinnedverts");
skinnedVerts->maxSkinnedVerts = static_cast<unsigned int>(bsp.gfxWorld.vertices.size());

View File

@@ -32,12 +32,12 @@ namespace
bool FinalizeZone(AssetCreationContext& context) override
{
const std::unique_ptr<BSPData> bsp = BSP::createBSPData(m_zone.m_name, m_search_path);
const auto bsp = BSP::createBSPData(m_zone.m_name, m_search_path);
if (bsp == nullptr)
return false;
BSPLinker linker(m_memory, m_search_path, context);
const bool result = linker.linkBSP(*bsp);
const auto result = linker.linkBSP(*bsp);
if (!result)
con::error("BSP link has failed.");