Reformat code with clang format

This commit is contained in:
Clang Format
2023-11-19 15:28:38 +01:00
committed by Jan
parent 22e17272fd
commit 6b4f5d94a8
1099 changed files with 16763 additions and 18076 deletions

View File

@ -1,14 +1,14 @@
#include "AssetDumperXModel.h"
#include <cassert>
#include "ObjWriting.h"
#include "Game/IW4/CommonIW4.h"
#include "Math/Quaternion.h"
#include "Model/XModel/XModelExportWriter.h"
#include "ObjWriting.h"
#include "Utils/HalfFloat.h"
#include "Utils/QuatInt16.h"
#include <cassert>
using namespace IW4;
namespace IW4
@ -27,7 +27,7 @@ namespace IW4
return true;
}
};
}
} // namespace IW4
bool AssetDumperXModel::ShouldDump(XAssetInfo<XModel>* asset)
{
@ -287,7 +287,8 @@ void AssetDumperXModel::AddXModelBones(const AssetDumpingContext& context, Abstr
bone.globalOffset[0] = model->baseMat[boneNum].trans[0];
bone.globalOffset[1] = model->baseMat[boneNum].trans[1];
bone.globalOffset[2] = model->baseMat[boneNum].trans[2];
bone.globalRotation = Quaternion32(model->baseMat[boneNum].quat[0], model->baseMat[boneNum].quat[1], model->baseMat[boneNum].quat[2], model->baseMat[boneNum].quat[3]);
bone.globalRotation =
Quaternion32(model->baseMat[boneNum].quat[0], model->baseMat[boneNum].quat[1], model->baseMat[boneNum].quat[2], model->baseMat[boneNum].quat[3]);
if (boneNum < model->numRootBones)
{
@ -301,12 +302,10 @@ void AssetDumperXModel::AddXModelBones(const AssetDumpingContext& context, Abstr
bone.localOffset[0] = model->trans[boneNum - model->numRootBones][0];
bone.localOffset[1] = model->trans[boneNum - model->numRootBones][1];
bone.localOffset[2] = model->trans[boneNum - model->numRootBones][2];
bone.localRotation = Quaternion32(
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][0]),
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][1]),
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][2]),
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][3])
);
bone.localRotation = Quaternion32(QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][0]),
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][1]),
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][2]),
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][3]));
}
writer.AddBone(std::move(bone));
@ -404,7 +403,9 @@ void AssetDumperXModel::AllocateXModelBoneWeights(const XModelSurfs* modelSurfs,
weightCollection.weights = std::make_unique<XModelBoneWeight[]>(weightCollection.totalWeightCount);
}
void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer, const XModelSurfs* modelSurfs, XModelVertexBoneWeightCollection& weightCollection)
void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
const XModelSurfs* modelSurfs,
XModelVertexBoneWeightCollection& weightCollection)
{
size_t weightOffset = 0u;
@ -420,17 +421,11 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
const auto& vertList = surface.vertList[vertListIndex];
const auto* boneWeightOffset = &weightCollection.weights[weightOffset];
weightCollection.weights[weightOffset++] = XModelBoneWeight{
static_cast<int>(vertList.boneOffset / sizeof(DObjSkelMat)),
1.0f
};
weightCollection.weights[weightOffset++] = XModelBoneWeight{static_cast<int>(vertList.boneOffset / sizeof(DObjSkelMat)), 1.0f};
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
{
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
boneWeightOffset,
1
});
writer.AddVertexBoneWeights(XModelVertexBoneWeights{boneWeightOffset, 1});
}
handledVertices += vertList.vertCount;
}
@ -444,17 +439,11 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
{
const auto* boneWeightOffset = &weightCollection.weights[weightOffset];
const auto boneIndex0 = static_cast<int>(surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat));
weightCollection.weights[weightOffset++] = XModelBoneWeight{
boneIndex0,
1.0f
};
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
vertsBlendOffset += 1;
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
boneWeightOffset,
1
});
writer.AddVertexBoneWeights(XModelVertexBoneWeights{boneWeightOffset, 1});
}
// 2 bone weights
@ -466,21 +455,12 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
const auto boneWeight1 = HalfFloat::ToFloat(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
const auto boneWeight0 = 1.0f - boneWeight1;
weightCollection.weights[weightOffset++] = XModelBoneWeight{
boneIndex0,
boneWeight0
};
weightCollection.weights[weightOffset++] = XModelBoneWeight{
boneIndex1,
boneWeight1
};
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0};
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1};
vertsBlendOffset += 3;
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
boneWeightOffset,
2
});
writer.AddVertexBoneWeights(XModelVertexBoneWeights{boneWeightOffset, 2});
}
// 3 bone weights
@ -494,25 +474,13 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
const auto boneWeight2 = HalfFloat::ToFloat(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
weightCollection.weights[weightOffset++] = XModelBoneWeight{
boneIndex0,
boneWeight0
};
weightCollection.weights[weightOffset++] = XModelBoneWeight{
boneIndex1,
boneWeight1
};
weightCollection.weights[weightOffset++] = XModelBoneWeight{
boneIndex2,
boneWeight2
};
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0};
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1};
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex2, boneWeight2};
vertsBlendOffset += 5;
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
boneWeightOffset,
3
});
writer.AddVertexBoneWeights(XModelVertexBoneWeights{boneWeightOffset, 3});
}
// 4 bone weights
@ -528,29 +496,14 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
const auto boneWeight3 = HalfFloat::ToFloat(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
weightCollection.weights[weightOffset++] = XModelBoneWeight{
boneIndex0,
boneWeight0
};
weightCollection.weights[weightOffset++] = XModelBoneWeight{
boneIndex1,
boneWeight1
};
weightCollection.weights[weightOffset++] = XModelBoneWeight{
boneIndex2,
boneWeight2
};
weightCollection.weights[weightOffset++] = XModelBoneWeight{
boneIndex3,
boneWeight3
};
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0};
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1};
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex2, boneWeight2};
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex3, boneWeight3};
vertsBlendOffset += 7;
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
boneWeightOffset,
4
});
writer.AddVertexBoneWeights(XModelVertexBoneWeights{boneWeightOffset, 4});
}
handledVertices += surface.vertInfo.vertCount[0] + surface.vertInfo.vertCount[1] + surface.vertInfo.vertCount[2] + surface.vertInfo.vertCount[3];
@ -558,15 +511,14 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
for (; handledVertices < surface.vertCount; handledVertices++)
{
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
nullptr,
0
});
writer.AddVertexBoneWeights(XModelVertexBoneWeights{nullptr, 0});
}
}
}
void AssetDumperXModel::AddXModelFaces(AbstractXModelWriter& writer, const DistinctMapper<Material*>& materialMapper, const XModelSurfs* modelSurfs,
void AssetDumperXModel::AddXModelFaces(AbstractXModelWriter& writer,
const DistinctMapper<Material*>& materialMapper,
const XModelSurfs* modelSurfs,
const int baseSurfaceIndex)
{
for (auto surfIndex = 0u; surfIndex < modelSurfs->numsurfs; surfIndex++)