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,15 +1,15 @@
#include "AssetDumperXModel.h"
#include <cassert>
#include <sstream>
#include "ObjWriting.h"
#include "Game/IW3/CommonIW3.h"
#include "Math/Quaternion.h"
#include "Model/XModel/XModelExportWriter.h"
#include "ObjWriting.h"
#include "Utils/HalfFloat.h"
#include "Utils/QuatInt16.h"
#include <cassert>
#include <sstream>
using namespace IW3;
bool AssetDumperXModel::ShouldDump(XAssetInfo<XModel>* asset)
@ -273,7 +273,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)
{
@ -287,12 +288,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));
@ -398,7 +397,10 @@ void AssetDumperXModel::AllocateXModelBoneWeights(const XModel* model, const uns
weightCollection.weights = std::make_unique<XModelBoneWeight[]>(weightCollection.totalWeightCount);
}
void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer, const XModel* model, const unsigned lod, XModelVertexBoneWeightCollection& weightCollection)
void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
const XModel* model,
const unsigned lod,
XModelVertexBoneWeightCollection& weightCollection)
{
const auto* surfs = &model->surfs[model->lodInfo[lod].surfIndex];
const auto surfCount = model->lodInfo[lod].numsurfs;
@ -417,17 +419,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;
}
@ -441,17 +437,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
@ -463,21 +453,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
@ -491,25 +472,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
@ -525,29 +494,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];
@ -555,10 +509,7 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
for (; handledVertices < surface.vertCount; handledVertices++)
{
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
nullptr,
0
});
writer.AddVertexBoneWeights(XModelVertexBoneWeights{nullptr, 0});
}
}
}