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

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

@ -11,4 +11,4 @@ namespace IW5
bool ShouldDump(XAssetInfo<AddonMapEnts>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset) override;
};
}
} // namespace IW5

View File

@ -1,10 +1,10 @@
#include "AssetDumperGfxImage.h"
#include <cassert>
#include "ObjWriting.h"
#include "Image/IwiWriter8.h"
#include "Image/DdsWriter.h"
#include "Image/IwiWriter8.h"
#include "ObjWriting.h"
#include <cassert>
using namespace IW5;

View File

@ -1,11 +1,11 @@
#pragma once
#include <memory>
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW5/IW5.h"
#include "Image/IImageWriter.h"
#include <memory>
namespace IW5
{
class AssetDumperGfxImage final : public AbstractAssetDumper<GfxImage>
@ -21,4 +21,4 @@ namespace IW5
public:
AssetDumperGfxImage();
};
}
} // namespace IW5

View File

@ -11,41 +11,25 @@ bool AssetDumperLoadedSound::ShouldDump(XAssetInfo<LoadedSound>* asset)
void AssetDumperLoadedSound::DumpWavPcm(AssetDumpingContext& context, const LoadedSound* asset, std::ostream& stream)
{
const auto riffMasterChunkSize = sizeof(WAV_CHUNK_ID_RIFF)
+ sizeof(uint32_t)
+ sizeof(WAV_WAVE_ID)
+ sizeof(WavChunkHeader)
+ sizeof(WavFormatChunkPcm)
+ sizeof(WavChunkHeader)
+ sizeof(asset->sound.info.data_len);
const auto riffMasterChunkSize = sizeof(WAV_CHUNK_ID_RIFF) + sizeof(uint32_t) + sizeof(WAV_WAVE_ID) + sizeof(WavChunkHeader) + sizeof(WavFormatChunkPcm)
+ sizeof(WavChunkHeader) + sizeof(asset->sound.info.data_len);
stream.write(reinterpret_cast<const char*>(&WAV_CHUNK_ID_RIFF), sizeof(WAV_CHUNK_ID_RIFF));
stream.write(reinterpret_cast<const char*>(&riffMasterChunkSize), sizeof(riffMasterChunkSize));
stream.write(reinterpret_cast<const char*>(&WAV_WAVE_ID), sizeof(WAV_WAVE_ID));
const WavChunkHeader formatChunkHeader
{
WAV_CHUNK_ID_FMT,
sizeof(WavFormatChunkPcm)
};
const WavChunkHeader formatChunkHeader{WAV_CHUNK_ID_FMT, sizeof(WavFormatChunkPcm)};
stream.write(reinterpret_cast<const char*>(&formatChunkHeader), sizeof(formatChunkHeader));
WavFormatChunkPcm formatChunk
{
WavFormat::PCM,
static_cast<uint16_t>(asset->sound.info.channels),
asset->sound.info.rate,
asset->sound.info.rate * asset->sound.info.channels * asset->sound.info.bits / 8,
static_cast<uint16_t>(asset->sound.info.block_size),
static_cast<uint16_t>(asset->sound.info.bits)
};
WavFormatChunkPcm formatChunk{WavFormat::PCM,
static_cast<uint16_t>(asset->sound.info.channels),
asset->sound.info.rate,
asset->sound.info.rate * asset->sound.info.channels * asset->sound.info.bits / 8,
static_cast<uint16_t>(asset->sound.info.block_size),
static_cast<uint16_t>(asset->sound.info.bits)};
stream.write(reinterpret_cast<const char*>(&formatChunk), sizeof(formatChunk));
const WavChunkHeader dataChunkHeader
{
WAV_CHUNK_ID_DATA,
asset->sound.info.data_len
};
const WavChunkHeader dataChunkHeader{WAV_CHUNK_ID_DATA, asset->sound.info.data_len};
stream.write(reinterpret_cast<const char*>(&dataChunkHeader), sizeof(dataChunkHeader));
stream.write(asset->sound.data, asset->sound.info.data_len);
}

View File

@ -13,4 +13,4 @@ namespace IW5
bool ShouldDump(XAssetInfo<LoadedSound>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset) override;
};
}
} // namespace IW5

View File

@ -1,9 +1,9 @@
#include "AssetDumperLocalizeEntry.h"
#include <sstream>
#include "Localize/LocalizeCommon.h"
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include <sstream>
using namespace IW5;
@ -40,4 +40,4 @@ void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<
{
printf("Could not create string file for dumping localized strings of zone '%s'\n", context.m_zone->m_name.c_str());
}
}
}

View File

@ -10,4 +10,4 @@ namespace IW5
public:
void DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool) override;
};
}
} // namespace IW5

View File

@ -1,12 +1,12 @@
#include "AssetDumperMenuDef.h"
#include <filesystem>
#include <string>
#include "ObjWriting.h"
#include "Game/IW5/GameAssetPoolIW5.h"
#include "Game/IW5/Menu/MenuDumperIW5.h"
#include "Menu/AbstractMenuDumper.h"
#include "ObjWriting.h"
#include <filesystem>
#include <string>
namespace fs = std::filesystem;
@ -55,7 +55,7 @@ void AssetDumperMenuDef::DumpAsset(AssetDumpingContext& context, XAssetInfo<menu
const auto* menu = asset->Asset();
const auto menuFilePath = GetPathForMenu(asset);
if(ObjWriting::ShouldHandleAssetType(ASSET_TYPE_MENULIST))
if (ObjWriting::ShouldHandleAssetType(ASSET_TYPE_MENULIST))
{
// Don't dump menu file separately if the name matches the menu list
const auto* menuListParent = GetParentMenuList(asset);

View File

@ -14,4 +14,4 @@ namespace IW5
bool ShouldDump(XAssetInfo<menuDef_t>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<menuDef_t>* asset) override;
};
}
} // namespace IW5

View File

@ -1,13 +1,13 @@
#include "AssetDumperMenuList.h"
#include "Game/IW5/Menu/MenuDumperIW5.h"
#include "Menu/AbstractMenuDumper.h"
#include "ObjWriting.h"
#include <cassert>
#include <filesystem>
#include <sstream>
#include <set>
#include "ObjWriting.h"
#include "Game/IW5/Menu/MenuDumperIW5.h"
#include "Menu/AbstractMenuDumper.h"
#include <sstream>
namespace fs = std::filesystem;
@ -21,17 +21,17 @@ std::vector<const ExpressionSupportingData*> AssetDumperMenuList::GetAllUniqueEx
if (menuList->menus == nullptr)
return result;
for(auto i = 0; i < menuList->menuCount; i++)
for (auto i = 0; i < menuList->menuCount; i++)
{
if(menuList->menus[i] == nullptr)
if (menuList->menus[i] == nullptr)
continue;
const auto* menu = menuList->menus[i];
if(menu->data == nullptr || menu->data->expressionData == nullptr)
if (menu->data == nullptr || menu->data->expressionData == nullptr)
continue;
if(alreadyAddedSupportingData.find(menu->data->expressionData) == alreadyAddedSupportingData.end())
if (alreadyAddedSupportingData.find(menu->data->expressionData) == alreadyAddedSupportingData.end())
{
result.push_back(menu->data->expressionData);
alreadyAddedSupportingData.emplace(menu->data->expressionData);
@ -53,10 +53,10 @@ void AssetDumperMenuList::DumpFunctions(MenuDumper& menuDumper, const MenuList*
if (supportingData->uifunctions.functions == nullptr)
continue;
for(auto i = 0; i < supportingData->uifunctions.totalFunctions; i++)
for (auto i = 0; i < supportingData->uifunctions.totalFunctions; i++)
{
const auto* function = supportingData->uifunctions.functions[i];
if(function == nullptr)
if (function == nullptr)
continue;
std::stringstream ss;
@ -114,7 +114,7 @@ void AssetDumperMenuList::DumpAsset(AssetDumpingContext& context, XAssetInfo<Men
menuDumper.Start();
if(!ObjWriting::Configuration.MenuLegacyMode)
if (!ObjWriting::Configuration.MenuLegacyMode)
DumpFunctions(menuDumper, menuList);
DumpMenus(menuDumper, menuList);

View File

@ -17,4 +17,4 @@ namespace IW5
bool ShouldDump(XAssetInfo<MenuList>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MenuList>* asset) override;
};
}
} // namespace IW5

View File

@ -1,7 +1,7 @@
#include "AssetDumperRawFile.h"
#include <zlib.h>
#include <stdexcept>
#include <zlib.h>
using namespace IW5;

View File

@ -13,4 +13,4 @@ namespace IW5
bool ShouldDump(XAssetInfo<RawFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset) override;
};
}
} // namespace IW5

View File

@ -11,4 +11,4 @@ namespace IW5
bool ShouldDump(XAssetInfo<StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset) override;
};
}
} // namespace IW5

View File

@ -1,14 +1,14 @@
#include "AssetDumperXModel.h"
#include <cassert>
#include "ObjWriting.h"
#include "Game/IW5/CommonIW5.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 IW5;
namespace IW5
@ -27,7 +27,7 @@ namespace IW5
return true;
}
};
}
} // namespace IW5
bool AssetDumperXModel::ShouldDump(XAssetInfo<XModel>* asset)
{
@ -286,7 +286,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)
{
@ -300,12 +301,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));
@ -403,7 +402,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;
@ -419,17 +420,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;
}
@ -443,17 +438,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
@ -465,21 +454,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
@ -493,25 +473,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
@ -527,29 +495,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];
@ -557,15 +510,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++)

View File

@ -2,9 +2,9 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW5/IW5.h"
#include "Utils/DistinctMapper.h"
#include "Model/XModel/AbstractXModelWriter.h"
#include "Model/Obj/ObjWriter.h"
#include "Model/XModel/AbstractXModelWriter.h"
#include "Utils/DistinctMapper.h"
namespace IW5
{
@ -28,7 +28,8 @@ namespace IW5
static void AddXModelVertices(AbstractXModelWriter& writer, const XModelSurfs* modelSurfs);
static void AllocateXModelBoneWeights(const XModelSurfs* modelSurfs, XModelVertexBoneWeightCollection& weightCollection);
static void AddXModelVertexBoneWeights(AbstractXModelWriter& writer, const XModelSurfs* modelSurfs, XModelVertexBoneWeightCollection& weightCollection);
static void AddXModelFaces(AbstractXModelWriter& writer, const DistinctMapper<Material*>& materialMapper, const XModelSurfs* modelSurfs, int baseSurfaceIndex);
static void
AddXModelFaces(AbstractXModelWriter& writer, const DistinctMapper<Material*>& materialMapper, const XModelSurfs* modelSurfs, int baseSurfaceIndex);
static void DumpXModelExportLod(const AssetDumpingContext& context, XAssetInfo<XModel>* asset, unsigned lod);
static void DumpXModelExport(AssetDumpingContext& context, XAssetInfo<XModel>* asset);
@ -36,4 +37,4 @@ namespace IW5
bool ShouldDump(XAssetInfo<XModel>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<XModel>* asset) override;
};
}
} // namespace IW5