mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-05-06 20:44:57 +00:00
refactor: fix remaining x64 compilation issues
This commit is contained in:
parent
a6107e24a2
commit
365b627523
@ -56,8 +56,8 @@ namespace
|
||||
void CreateFromString(const std::string& templateString)
|
||||
{
|
||||
const auto templateStringLength = templateString.size();
|
||||
auto partStart = 0u;
|
||||
for (auto i = 0u; i < templateStringLength; i++)
|
||||
auto partStart = 0uz;
|
||||
for (auto i = 0uz; i < templateStringLength; i++)
|
||||
{
|
||||
if (templateString[i] != '?')
|
||||
continue;
|
||||
|
@ -126,10 +126,10 @@ namespace
|
||||
bone.globalOffset[1] = model->baseMat[boneNum].trans[1];
|
||||
bone.globalOffset[2] = model->baseMat[boneNum].trans[2];
|
||||
bone.globalRotation = {
|
||||
model->baseMat[boneNum].quat[0],
|
||||
model->baseMat[boneNum].quat[1],
|
||||
model->baseMat[boneNum].quat[2],
|
||||
model->baseMat[boneNum].quat[3],
|
||||
.x = model->baseMat[boneNum].quat[0],
|
||||
.y = model->baseMat[boneNum].quat[1],
|
||||
.z = model->baseMat[boneNum].quat[2],
|
||||
.w = model->baseMat[boneNum].quat[3],
|
||||
};
|
||||
|
||||
if (boneNum < model->numRootBones)
|
||||
@ -137,7 +137,7 @@ namespace
|
||||
bone.localOffset[0] = 0;
|
||||
bone.localOffset[1] = 0;
|
||||
bone.localOffset[2] = 0;
|
||||
bone.localRotation = {0, 0, 0, 1};
|
||||
bone.localRotation = {.x = 0, .y = 0, .z = 0, .w = 1};
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -145,10 +145,10 @@ namespace
|
||||
bone.localOffset[1] = model->trans[boneNum - model->numRootBones][1];
|
||||
bone.localOffset[2] = model->trans[boneNum - model->numRootBones][2];
|
||||
bone.localRotation = {
|
||||
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]),
|
||||
.x = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][0]),
|
||||
.y = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][1]),
|
||||
.z = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][2]),
|
||||
.w = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][3]),
|
||||
};
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ namespace
|
||||
|
||||
void AddXModelMaterials(XModelCommon& out, DistinctMapper<Material*>& materialMapper, const XModel* model)
|
||||
{
|
||||
for (auto surfaceMaterialNum = 0; surfaceMaterialNum < model->numsurfs; surfaceMaterialNum++)
|
||||
for (auto surfaceMaterialNum = 0u; surfaceMaterialNum < model->numsurfs; surfaceMaterialNum++)
|
||||
{
|
||||
Material* material = model->materialHandles[surfaceMaterialNum];
|
||||
if (materialMapper.Add(material))
|
||||
@ -271,7 +271,7 @@ namespace
|
||||
const auto surfCount = model->lodInfo[lod].numsurfs;
|
||||
auto& weightCollection = out.m_bone_weight_data;
|
||||
|
||||
size_t weightOffset = 0u;
|
||||
auto weightOffset = 0u;
|
||||
|
||||
for (auto surfIndex = 0u; surfIndex < surfCount; surfIndex++)
|
||||
{
|
||||
@ -285,7 +285,8 @@ namespace
|
||||
const auto& vertList = surface.vertList[vertListIndex];
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), 1.0f};
|
||||
weightCollection.weights[weightOffset++] =
|
||||
XModelBoneWeight{.boneIndex = static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), .weight = 1.0f};
|
||||
|
||||
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
||||
{
|
||||
@ -303,7 +304,7 @@ namespace
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = 1.0f};
|
||||
|
||||
vertsBlendOffset += 1;
|
||||
|
||||
@ -319,8 +320,8 @@ namespace
|
||||
const auto boneWeight1 = BoneWeight16(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{.boneIndex = boneIndex0, .weight = boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1};
|
||||
|
||||
vertsBlendOffset += 3;
|
||||
|
||||
@ -338,9 +339,9 @@ namespace
|
||||
const auto boneWeight2 = BoneWeight16(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{.boneIndex = boneIndex0, .weight = boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex2, .weight = boneWeight2};
|
||||
|
||||
vertsBlendOffset += 5;
|
||||
|
||||
@ -360,10 +361,10 @@ namespace
|
||||
const auto boneWeight3 = BoneWeight16(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{.boneIndex = boneIndex0, .weight = boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex2, .weight = boneWeight2};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex3, .weight = boneWeight3};
|
||||
|
||||
vertsBlendOffset += 7;
|
||||
|
||||
|
@ -121,10 +121,10 @@ namespace
|
||||
bone.globalOffset[1] = model->baseMat[boneNum].trans[1];
|
||||
bone.globalOffset[2] = model->baseMat[boneNum].trans[2];
|
||||
bone.globalRotation = {
|
||||
model->baseMat[boneNum].quat[0],
|
||||
model->baseMat[boneNum].quat[1],
|
||||
model->baseMat[boneNum].quat[2],
|
||||
model->baseMat[boneNum].quat[3],
|
||||
.x = model->baseMat[boneNum].quat[0],
|
||||
.y = model->baseMat[boneNum].quat[1],
|
||||
.z = model->baseMat[boneNum].quat[2],
|
||||
.w = model->baseMat[boneNum].quat[3],
|
||||
};
|
||||
|
||||
if (boneNum < model->numRootBones)
|
||||
@ -132,7 +132,7 @@ namespace
|
||||
bone.localOffset[0] = 0;
|
||||
bone.localOffset[1] = 0;
|
||||
bone.localOffset[2] = 0;
|
||||
bone.localRotation = {0, 0, 0, 1};
|
||||
bone.localRotation = {.x = 0, .y = 0, .z = 0, .w = 1};
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -140,10 +140,10 @@ namespace
|
||||
bone.localOffset[1] = model->trans[boneNum - model->numRootBones][1];
|
||||
bone.localOffset[2] = model->trans[boneNum - model->numRootBones][2];
|
||||
bone.localRotation = {
|
||||
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]),
|
||||
.x = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][0]),
|
||||
.y = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][1]),
|
||||
.z = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][2]),
|
||||
.w = QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][3]),
|
||||
};
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ namespace
|
||||
|
||||
void AddXModelMaterials(XModelCommon& out, DistinctMapper<Material*>& materialMapper, const XModel* model)
|
||||
{
|
||||
for (auto surfaceMaterialNum = 0; surfaceMaterialNum < model->numsurfs; surfaceMaterialNum++)
|
||||
for (auto surfaceMaterialNum = 0u; surfaceMaterialNum < model->numsurfs; surfaceMaterialNum++)
|
||||
{
|
||||
Material* material = model->materialHandles[surfaceMaterialNum];
|
||||
if (materialMapper.Add(material))
|
||||
@ -254,7 +254,7 @@ namespace
|
||||
void AddXModelVertexBoneWeights(XModelCommon& out, const XModelSurfs* modelSurfs)
|
||||
{
|
||||
auto& weightCollection = out.m_bone_weight_data;
|
||||
size_t weightOffset = 0u;
|
||||
auto weightOffset = 0u;
|
||||
|
||||
for (auto surfIndex = 0u; surfIndex < modelSurfs->numsurfs; surfIndex++)
|
||||
{
|
||||
@ -268,11 +268,12 @@ namespace
|
||||
const auto& vertList = surface.vertList[vertListIndex];
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), 1.0f};
|
||||
weightCollection.weights[weightOffset++] =
|
||||
XModelBoneWeight{.boneIndex = static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), .weight = 1.0f};
|
||||
|
||||
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
||||
{
|
||||
out.m_vertex_bone_weights.emplace_back(boneWeightOffset, 1);
|
||||
out.m_vertex_bone_weights.emplace_back(boneWeightOffset, 1u);
|
||||
}
|
||||
handledVertices += vertList.vertCount;
|
||||
}
|
||||
@ -286,7 +287,7 @@ namespace
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = 1.0f};
|
||||
|
||||
vertsBlendOffset += 1;
|
||||
|
||||
@ -302,8 +303,8 @@ namespace
|
||||
const auto boneWeight1 = BoneWeight16(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{.boneIndex = boneIndex0, .weight = boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1};
|
||||
|
||||
vertsBlendOffset += 3;
|
||||
|
||||
@ -321,9 +322,9 @@ namespace
|
||||
const auto boneWeight2 = BoneWeight16(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{.boneIndex = boneIndex0, .weight = boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex2, .weight = boneWeight2};
|
||||
|
||||
vertsBlendOffset += 5;
|
||||
|
||||
@ -343,10 +344,10 @@ namespace
|
||||
const auto boneWeight3 = BoneWeight16(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{.boneIndex = boneIndex0, .weight = boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex2, .weight = boneWeight2};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex3, .weight = boneWeight3};
|
||||
|
||||
vertsBlendOffset += 7;
|
||||
|
||||
|
@ -271,13 +271,13 @@ void MenuDumper::WriteStatementSkipInitialUnnecessaryParenthesis(const Statement
|
||||
|
||||
void MenuDumper::WriteStatementNaive(const Statement_s* statement) const
|
||||
{
|
||||
const auto entryCount = static_cast<unsigned>(statement->numEntries);
|
||||
const auto entryCount = static_cast<size_t>(statement->numEntries);
|
||||
|
||||
const auto missingClosingParenthesis = statement->numEntries > 0 && statement->entries[0].type == EET_OPERATOR
|
||||
&& statement->entries[0].data.op == OP_LEFTPAREN
|
||||
&& FindStatementClosingParenthesis(statement, 0) >= static_cast<size_t>(statement->numEntries);
|
||||
|
||||
for (auto i = 0u; i < entryCount; i++)
|
||||
for (auto i = 0uz; i < entryCount; i++)
|
||||
{
|
||||
const auto& entry = statement->entries[i];
|
||||
if (entry.type == EET_OPERAND)
|
||||
@ -314,7 +314,7 @@ void MenuDumper::WriteStatementNaive(const Statement_s* statement) const
|
||||
const auto closingParenPos = FindStatementClosingParenthesis(statement, i);
|
||||
m_stream << "(";
|
||||
|
||||
if (closingParenPos - i + 1 >= 1)
|
||||
if (closingParenPos - i + 1u >= 1u)
|
||||
{
|
||||
const auto& staticDvarEntry = statement->entries[i + 1];
|
||||
if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT)
|
||||
|
@ -240,7 +240,7 @@ void MenuDumper::WriteStatementEntryRange(const Statement_s* statement, size_t s
|
||||
void MenuDumper::WriteStatementNaive(const Statement_s* statement) const
|
||||
{
|
||||
const auto entryCount = static_cast<unsigned>(statement->numEntries);
|
||||
for (auto i = 0u; i < entryCount; i++)
|
||||
for (auto i = 0uz; i < entryCount; i++)
|
||||
{
|
||||
const auto& entry = statement->entries[i];
|
||||
if (entry.type == EET_OPERAND)
|
||||
@ -277,9 +277,9 @@ void MenuDumper::WriteStatementNaive(const Statement_s* statement) const
|
||||
const auto closingParenPos = FindStatementClosingParenthesis(statement, i);
|
||||
m_stream << "(";
|
||||
|
||||
if (closingParenPos - i + 1 >= 1)
|
||||
if (closingParenPos - i + 1u >= 1u)
|
||||
{
|
||||
const auto& staticDvarEntry = statement->entries[i + 1];
|
||||
const auto& staticDvarEntry = statement->entries[i + 1u];
|
||||
if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT)
|
||||
{
|
||||
if (statement->supportingData && statement->supportingData->staticDvarList.staticDvars && staticDvarEntry.data.operand.internals.intVal >= 0
|
||||
|
@ -297,12 +297,12 @@ class XModelBinWriter7 final : public XModelBinWriterBase
|
||||
|
||||
void WriteFaces(const XModelCommon& xmodel)
|
||||
{
|
||||
auto totalFaceCount = 0u;
|
||||
auto totalFaceCount = 0uz;
|
||||
for (const auto& object : xmodel.m_objects)
|
||||
totalFaceCount += object.m_faces.size();
|
||||
|
||||
XModelBinWriterBase::Write(static_cast<uint32_t>(XModelBinHash::FACE_COUNT));
|
||||
XModelBinWriterBase::Write(totalFaceCount);
|
||||
XModelBinWriterBase::Write(static_cast<uint32_t>(totalFaceCount));
|
||||
|
||||
auto objectIndex = 0u;
|
||||
for (const auto& object : xmodel.m_objects)
|
||||
|
@ -122,11 +122,11 @@ class XModelExportWriter6 final : public XModelExportWriterBase
|
||||
|
||||
void WriteFaces(const XModelCommon& xmodel) const
|
||||
{
|
||||
auto totalFaceCount = 0u;
|
||||
auto totalFaceCount = 0uz;
|
||||
for (const auto& object : xmodel.m_objects)
|
||||
totalFaceCount += object.m_faces.size();
|
||||
|
||||
m_stream << "NUMFACES " << totalFaceCount << "\n";
|
||||
m_stream << std::format("NUMFACES {}\n", totalFaceCount);
|
||||
|
||||
auto objectIndex = 0u;
|
||||
for (const auto& object : xmodel.m_objects)
|
||||
|
@ -343,7 +343,7 @@ namespace GAME_NAMESPACE
|
||||
if (!surfs)
|
||||
return;
|
||||
|
||||
size_t weightOffset = 0u;
|
||||
auto weightOffset = 0u;
|
||||
|
||||
for (auto surfIndex = 0u; surfIndex < surfCount; surfIndex++)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ void BinOutput::EmitJson(const nlohmann::json& json) const
|
||||
|
||||
void BinOutput::EmitBuffer(const void* buffer, const size_t bufferSize) const
|
||||
{
|
||||
const auto chunkLength = utils::Align<uint32_t>(bufferSize, 4u);
|
||||
const auto chunkLength = utils::Align<uint32_t>(static_cast<uint32_t>(bufferSize), 4u);
|
||||
Write(&chunkLength, sizeof(chunkLength));
|
||||
Write(&CHUNK_MAGIC_BIN, sizeof(CHUNK_MAGIC_BIN));
|
||||
|
||||
|
@ -74,7 +74,7 @@ namespace
|
||||
if (!gltf.nodes.has_value())
|
||||
gltf.nodes.emplace();
|
||||
|
||||
m_first_mesh_node = gltf.nodes->size();
|
||||
m_first_mesh_node = static_cast<unsigned>(gltf.nodes->size());
|
||||
|
||||
auto meshIndex = 0u;
|
||||
for (const auto& object : xmodel.m_objects)
|
||||
@ -123,7 +123,7 @@ namespace
|
||||
|
||||
rootNode.children->push_back(m_first_bone_node);
|
||||
|
||||
m_root_node = gltf.nodes->size();
|
||||
m_root_node = static_cast<unsigned>(gltf.nodes->size());
|
||||
gltf.nodes->emplace_back(std::move(rootNode));
|
||||
}
|
||||
|
||||
@ -211,12 +211,12 @@ namespace
|
||||
|
||||
JsonImage image;
|
||||
image.uri = std::move(uri);
|
||||
const auto imageIndex = gltf.images->size();
|
||||
const auto imageIndex = static_cast<unsigned>(gltf.images->size());
|
||||
gltf.images->emplace_back(std::move(image));
|
||||
|
||||
JsonTexture texture;
|
||||
texture.source = imageIndex;
|
||||
const auto textureIndex = gltf.textures->size();
|
||||
const auto textureIndex = static_cast<unsigned>(gltf.textures->size());
|
||||
gltf.textures->emplace_back(texture);
|
||||
|
||||
return textureIndex;
|
||||
@ -231,7 +231,7 @@ namespace
|
||||
gltf.nodes.emplace();
|
||||
|
||||
const auto boneCount = common.m_bones.size();
|
||||
m_first_bone_node = gltf.nodes->size();
|
||||
m_first_bone_node = static_cast<unsigned>(gltf.nodes->size());
|
||||
for (auto boneIndex = 0u; boneIndex < boneCount; boneIndex++)
|
||||
{
|
||||
JsonNode boneNode;
|
||||
@ -319,12 +319,12 @@ namespace
|
||||
JsonBufferView vertexBufferView;
|
||||
vertexBufferView.buffer = 0u;
|
||||
vertexBufferView.byteOffset = bufferOffset;
|
||||
vertexBufferView.byteStride = sizeof(GltfVertex);
|
||||
vertexBufferView.byteLength = sizeof(GltfVertex) * xmodel.m_vertices.size();
|
||||
vertexBufferView.byteStride = static_cast<unsigned>(sizeof(GltfVertex));
|
||||
vertexBufferView.byteLength = static_cast<unsigned>(sizeof(GltfVertex) * xmodel.m_vertices.size());
|
||||
vertexBufferView.target = JsonBufferViewTarget::ARRAY_BUFFER;
|
||||
bufferOffset += vertexBufferView.byteLength;
|
||||
|
||||
m_vertex_buffer_view = gltf.bufferViews->size();
|
||||
m_vertex_buffer_view = static_cast<unsigned>(gltf.bufferViews->size());
|
||||
gltf.bufferViews->emplace_back(vertexBufferView);
|
||||
|
||||
if (!xmodel.m_bone_weight_data.weights.empty())
|
||||
@ -332,40 +332,40 @@ namespace
|
||||
JsonBufferView jointsBufferView;
|
||||
jointsBufferView.buffer = 0u;
|
||||
jointsBufferView.byteOffset = bufferOffset;
|
||||
jointsBufferView.byteLength = sizeof(uint8_t) * xmodel.m_vertices.size() * 4u;
|
||||
jointsBufferView.byteLength = static_cast<unsigned>(sizeof(uint8_t) * xmodel.m_vertices.size() * 4u);
|
||||
jointsBufferView.target = JsonBufferViewTarget::ARRAY_BUFFER;
|
||||
bufferOffset += jointsBufferView.byteLength;
|
||||
|
||||
m_joints_buffer_view = gltf.bufferViews->size();
|
||||
m_joints_buffer_view = static_cast<unsigned>(gltf.bufferViews->size());
|
||||
gltf.bufferViews->emplace_back(jointsBufferView);
|
||||
|
||||
JsonBufferView weightsBufferView;
|
||||
weightsBufferView.buffer = 0u;
|
||||
weightsBufferView.byteOffset = bufferOffset;
|
||||
weightsBufferView.byteLength = sizeof(float) * xmodel.m_vertices.size() * 4u;
|
||||
weightsBufferView.byteLength = static_cast<unsigned>(sizeof(float) * xmodel.m_vertices.size() * 4u);
|
||||
weightsBufferView.target = JsonBufferViewTarget::ARRAY_BUFFER;
|
||||
bufferOffset += weightsBufferView.byteLength;
|
||||
|
||||
m_weights_buffer_view = gltf.bufferViews->size();
|
||||
m_weights_buffer_view = static_cast<unsigned>(gltf.bufferViews->size());
|
||||
gltf.bufferViews->emplace_back(weightsBufferView);
|
||||
|
||||
JsonBufferView inverseBindMatricesBufferView;
|
||||
inverseBindMatricesBufferView.buffer = 0u;
|
||||
inverseBindMatricesBufferView.byteOffset = bufferOffset;
|
||||
inverseBindMatricesBufferView.byteLength = sizeof(float) * xmodel.m_bones.size() * 16u;
|
||||
inverseBindMatricesBufferView.byteLength = static_cast<unsigned>(sizeof(float) * xmodel.m_bones.size() * 16u);
|
||||
bufferOffset += inverseBindMatricesBufferView.byteLength;
|
||||
|
||||
m_inverse_bind_matrices_buffer_view = gltf.bufferViews->size();
|
||||
m_inverse_bind_matrices_buffer_view = static_cast<unsigned>(gltf.bufferViews->size());
|
||||
gltf.bufferViews->emplace_back(inverseBindMatricesBufferView);
|
||||
}
|
||||
|
||||
m_first_index_buffer_view = gltf.bufferViews->size();
|
||||
m_first_index_buffer_view = static_cast<unsigned>(gltf.bufferViews->size());
|
||||
for (const auto& object : xmodel.m_objects)
|
||||
{
|
||||
JsonBufferView indicesBufferView;
|
||||
indicesBufferView.buffer = 0u;
|
||||
indicesBufferView.byteOffset = bufferOffset;
|
||||
indicesBufferView.byteLength = sizeof(unsigned short) * object.m_faces.size() * 3u;
|
||||
indicesBufferView.byteLength = static_cast<unsigned>(sizeof(unsigned short) * object.m_faces.size() * 3u);
|
||||
indicesBufferView.target = JsonBufferViewTarget::ELEMENT_ARRAY_BUFFER;
|
||||
bufferOffset += indicesBufferView.byteLength;
|
||||
|
||||
@ -380,29 +380,29 @@ namespace
|
||||
|
||||
JsonAccessor positionAccessor;
|
||||
positionAccessor.bufferView = m_vertex_buffer_view;
|
||||
positionAccessor.byteOffset = offsetof(GltfVertex, coordinates);
|
||||
positionAccessor.byteOffset = static_cast<unsigned>(offsetof(GltfVertex, coordinates));
|
||||
positionAccessor.componentType = JsonAccessorComponentType::FLOAT;
|
||||
positionAccessor.count = xmodel.m_vertices.size();
|
||||
positionAccessor.count = static_cast<unsigned>(xmodel.m_vertices.size());
|
||||
positionAccessor.type = JsonAccessorType::VEC3;
|
||||
m_position_accessor = gltf.accessors->size();
|
||||
m_position_accessor = static_cast<unsigned>(gltf.accessors->size());
|
||||
gltf.accessors->emplace_back(positionAccessor);
|
||||
|
||||
JsonAccessor normalAccessor;
|
||||
normalAccessor.bufferView = m_vertex_buffer_view;
|
||||
normalAccessor.byteOffset = offsetof(GltfVertex, normal);
|
||||
normalAccessor.byteOffset = static_cast<unsigned>(offsetof(GltfVertex, normal));
|
||||
normalAccessor.componentType = JsonAccessorComponentType::FLOAT;
|
||||
normalAccessor.count = xmodel.m_vertices.size();
|
||||
normalAccessor.count = static_cast<unsigned>(xmodel.m_vertices.size());
|
||||
normalAccessor.type = JsonAccessorType::VEC3;
|
||||
m_normal_accessor = gltf.accessors->size();
|
||||
m_normal_accessor = static_cast<unsigned>(gltf.accessors->size());
|
||||
gltf.accessors->emplace_back(normalAccessor);
|
||||
|
||||
JsonAccessor uvAccessor;
|
||||
uvAccessor.bufferView = m_vertex_buffer_view;
|
||||
uvAccessor.byteOffset = offsetof(GltfVertex, uv);
|
||||
uvAccessor.byteOffset = static_cast<unsigned>(offsetof(GltfVertex, uv));
|
||||
uvAccessor.componentType = JsonAccessorComponentType::FLOAT;
|
||||
uvAccessor.count = xmodel.m_vertices.size();
|
||||
uvAccessor.count = static_cast<unsigned>(xmodel.m_vertices.size());
|
||||
uvAccessor.type = JsonAccessorType::VEC2;
|
||||
m_uv_accessor = gltf.accessors->size();
|
||||
m_uv_accessor = static_cast<unsigned>(gltf.accessors->size());
|
||||
gltf.accessors->emplace_back(uvAccessor);
|
||||
|
||||
if (!xmodel.m_bone_weight_data.weights.empty())
|
||||
@ -410,29 +410,29 @@ namespace
|
||||
JsonAccessor jointsAccessor;
|
||||
jointsAccessor.bufferView = m_joints_buffer_view;
|
||||
jointsAccessor.componentType = JsonAccessorComponentType::UNSIGNED_BYTE;
|
||||
jointsAccessor.count = xmodel.m_vertices.size();
|
||||
jointsAccessor.count = static_cast<unsigned>(xmodel.m_vertices.size());
|
||||
jointsAccessor.type = JsonAccessorType::VEC4;
|
||||
m_joints_accessor = gltf.accessors->size();
|
||||
m_joints_accessor = static_cast<unsigned>(gltf.accessors->size());
|
||||
gltf.accessors->emplace_back(jointsAccessor);
|
||||
|
||||
JsonAccessor weightsAccessor;
|
||||
weightsAccessor.bufferView = m_weights_buffer_view;
|
||||
weightsAccessor.componentType = JsonAccessorComponentType::FLOAT;
|
||||
weightsAccessor.count = xmodel.m_vertices.size();
|
||||
weightsAccessor.count = static_cast<unsigned>(xmodel.m_vertices.size());
|
||||
weightsAccessor.type = JsonAccessorType::VEC4;
|
||||
m_weights_accessor = gltf.accessors->size();
|
||||
m_weights_accessor = static_cast<unsigned>(gltf.accessors->size());
|
||||
gltf.accessors->emplace_back(weightsAccessor);
|
||||
|
||||
JsonAccessor inverseBindMatricesAccessor;
|
||||
inverseBindMatricesAccessor.bufferView = m_inverse_bind_matrices_buffer_view;
|
||||
inverseBindMatricesAccessor.componentType = JsonAccessorComponentType::FLOAT;
|
||||
inverseBindMatricesAccessor.count = xmodel.m_bones.size();
|
||||
inverseBindMatricesAccessor.count = static_cast<unsigned>(xmodel.m_bones.size());
|
||||
inverseBindMatricesAccessor.type = JsonAccessorType::MAT4;
|
||||
m_inverse_bind_matrices_accessor = gltf.accessors->size();
|
||||
m_inverse_bind_matrices_accessor = static_cast<unsigned>(gltf.accessors->size());
|
||||
gltf.accessors->emplace_back(inverseBindMatricesAccessor);
|
||||
}
|
||||
|
||||
m_first_index_accessor = gltf.accessors->size();
|
||||
m_first_index_accessor = static_cast<unsigned>(gltf.accessors->size());
|
||||
for (auto i = 0u; i < xmodel.m_objects.size(); i++)
|
||||
{
|
||||
const auto& object = xmodel.m_objects[i];
|
||||
@ -440,7 +440,7 @@ namespace
|
||||
JsonAccessor indicesAccessor;
|
||||
indicesAccessor.bufferView = m_first_index_buffer_view + i;
|
||||
indicesAccessor.componentType = JsonAccessorComponentType::UNSIGNED_SHORT;
|
||||
indicesAccessor.count = object.m_faces.size() * 3u;
|
||||
indicesAccessor.count = static_cast<unsigned>(object.m_faces.size() * 3u);
|
||||
indicesAccessor.type = JsonAccessorType::SCALAR;
|
||||
|
||||
gltf.accessors->emplace_back(indicesAccessor);
|
||||
@ -452,7 +452,7 @@ namespace
|
||||
const auto expectedBufferSize = GetExpectedBufferSize(xmodel);
|
||||
bufferData.resize(expectedBufferSize);
|
||||
|
||||
auto currentBufferOffset = 0u;
|
||||
auto currentBufferOffset = 0uz;
|
||||
|
||||
float minPosition[3]{
|
||||
std::numeric_limits<float>::max(),
|
||||
@ -576,7 +576,7 @@ namespace
|
||||
|
||||
static size_t GetExpectedBufferSize(const XModelCommon& xmodel)
|
||||
{
|
||||
auto result = 0u;
|
||||
auto result = 0uz;
|
||||
|
||||
result += xmodel.m_vertices.size() * sizeof(GltfVertex);
|
||||
|
||||
@ -603,7 +603,7 @@ namespace
|
||||
gltf.buffers.emplace();
|
||||
|
||||
JsonBuffer jsonBuffer;
|
||||
jsonBuffer.byteLength = bufferData.size();
|
||||
jsonBuffer.byteLength = static_cast<unsigned>(bufferData.size());
|
||||
|
||||
if (!bufferData.empty())
|
||||
jsonBuffer.uri = m_output->CreateBufferUri(bufferData.data(), bufferData.size());
|
||||
|
@ -380,7 +380,7 @@ namespace
|
||||
return;
|
||||
|
||||
auto& weightCollection = out.m_bone_weight_data;
|
||||
size_t weightOffset = 0u;
|
||||
auto weightOffset = 0u;
|
||||
|
||||
for (auto surfIndex = 0u; surfIndex < surfCount; surfIndex++)
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ private:
|
||||
ObjWriting::Configuration.AssetTypesToHandleBitfield = std::vector<bool>(assetTypeCount);
|
||||
|
||||
std::vector<bool> handledSpecifiedAssets(m_args.m_specified_asset_types.size());
|
||||
for (auto i = 0; i < assetTypeCount; i++)
|
||||
for (auto i = 0u; i < assetTypeCount; i++)
|
||||
{
|
||||
const auto assetTypeName = std::string(*context.m_zone.m_pools->GetAssetTypeName(i));
|
||||
|
||||
@ -136,7 +136,7 @@ private:
|
||||
std::cerr << "Valid asset types are:\n";
|
||||
|
||||
auto first = true;
|
||||
for (auto i = 0; i < assetTypeCount; i++)
|
||||
for (auto i = 0u; i < assetTypeCount; i++)
|
||||
{
|
||||
const auto assetTypeName = std::string(*context.m_zone.m_pools->GetAssetTypeName(i));
|
||||
|
||||
|
@ -251,7 +251,7 @@ void UnlinkerArgs::AddSpecifiedAssetType(std::string value)
|
||||
|
||||
void UnlinkerArgs::ParseCommaSeparatedAssetTypeString(const std::string& input)
|
||||
{
|
||||
auto currentPos = 0u;
|
||||
auto currentPos = 0uz;
|
||||
size_t endPos;
|
||||
|
||||
std::string lowerInput(input);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Loading/ContentLoaderBase.h"
|
||||
#include "Loading/IContentLoadingEntryPoint.h"
|
||||
@ -7,17 +8,18 @@ namespace IW4
|
||||
{
|
||||
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
|
||||
{
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
public:
|
||||
ContentLoader();
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
|
||||
private:
|
||||
void LoadScriptStringList(bool atStreamStart);
|
||||
|
||||
void LoadXAsset(bool atStreamStart) const;
|
||||
void LoadXAssetArray(bool atStreamStart, size_t count);
|
||||
|
||||
public:
|
||||
ContentLoader();
|
||||
|
||||
void Load(Zone* zone, IZoneInputStream* stream) override;
|
||||
XAsset* varXAsset;
|
||||
ScriptStringList* varScriptStringList;
|
||||
};
|
||||
} // namespace IW4
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
LoadDataInBlock(const_cast<void*>(reinterpret_cast<const void*>(dst)), sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T> void Load(T* dst, const uint32_t count)
|
||||
template<typename T> void Load(T* dst, const size_t count)
|
||||
{
|
||||
LoadDataInBlock(const_cast<void*>(reinterpret_cast<const void*>(dst)), count * sizeof(T));
|
||||
}
|
||||
|
@ -10,12 +10,6 @@
|
||||
|
||||
class OutputProcessorDeflate::Impl
|
||||
{
|
||||
z_stream m_stream{};
|
||||
OutputProcessorDeflate* m_base;
|
||||
|
||||
std::unique_ptr<uint8_t[]> m_buffer;
|
||||
size_t m_buffer_size;
|
||||
|
||||
public:
|
||||
Impl(OutputProcessorDeflate* baseClass, const size_t bufferSize)
|
||||
: m_buffer(std::make_unique<uint8_t[]>(bufferSize)),
|
||||
@ -29,7 +23,7 @@ public:
|
||||
m_stream.avail_in = 0;
|
||||
m_stream.next_in = Z_NULL;
|
||||
m_stream.next_out = m_buffer.get();
|
||||
m_stream.avail_out = m_buffer_size;
|
||||
m_stream.avail_out = static_cast<unsigned>(m_buffer_size);
|
||||
|
||||
const int ret = deflateInit(&m_stream, Z_DEFAULT_COMPRESSION);
|
||||
|
||||
@ -52,7 +46,7 @@ public:
|
||||
void Write(const void* buffer, const size_t length)
|
||||
{
|
||||
m_stream.next_in = static_cast<const Bytef*>(buffer);
|
||||
m_stream.avail_in = length;
|
||||
m_stream.avail_in = static_cast<unsigned>(length);
|
||||
|
||||
while (m_stream.avail_in > 0)
|
||||
{
|
||||
@ -60,7 +54,7 @@ public:
|
||||
{
|
||||
m_base->m_base_stream->Write(m_buffer.get(), m_buffer_size);
|
||||
m_stream.next_out = m_buffer.get();
|
||||
m_stream.avail_out = m_buffer_size;
|
||||
m_stream.avail_out = static_cast<unsigned>(m_buffer_size);
|
||||
}
|
||||
|
||||
const auto ret = deflate(&m_stream, Z_NO_FLUSH);
|
||||
@ -79,7 +73,7 @@ public:
|
||||
{
|
||||
m_base->m_base_stream->Write(m_buffer.get(), m_buffer_size - m_stream.avail_out);
|
||||
m_stream.next_out = m_buffer.get();
|
||||
m_stream.avail_out = m_buffer_size;
|
||||
m_stream.avail_out = static_cast<unsigned>(m_buffer_size);
|
||||
}
|
||||
|
||||
const auto ret = deflate(&m_stream, Z_FINISH);
|
||||
@ -96,14 +90,21 @@ public:
|
||||
{
|
||||
m_base->m_base_stream->Write(m_buffer.get(), m_buffer_size - m_stream.avail_out);
|
||||
m_stream.next_out = m_buffer.get();
|
||||
m_stream.avail_out = m_buffer_size;
|
||||
m_stream.avail_out = static_cast<unsigned>(m_buffer_size);
|
||||
}
|
||||
}
|
||||
|
||||
_NODISCARD int64_t Pos() const
|
||||
[[nodiscard]] int64_t Pos() const
|
||||
{
|
||||
return m_base->m_base_stream->Pos();
|
||||
}
|
||||
|
||||
private:
|
||||
z_stream m_stream{};
|
||||
OutputProcessorDeflate* m_base;
|
||||
|
||||
std::unique_ptr<uint8_t[]> m_buffer;
|
||||
size_t m_buffer_size;
|
||||
};
|
||||
|
||||
OutputProcessorDeflate::OutputProcessorDeflate()
|
||||
|
@ -13,7 +13,7 @@ class OutputProcessorDeflate final : public OutputStreamProcessor
|
||||
|
||||
public:
|
||||
OutputProcessorDeflate();
|
||||
OutputProcessorDeflate(size_t bufferSize);
|
||||
explicit OutputProcessorDeflate(size_t bufferSize);
|
||||
~OutputProcessorDeflate() override;
|
||||
OutputProcessorDeflate(const OutputProcessorDeflate& other) = delete;
|
||||
OutputProcessorDeflate(OutputProcessorDeflate&& other) noexcept = default;
|
||||
|
@ -9,10 +9,10 @@ StepWriteZero::StepWriteZero(const size_t count)
|
||||
|
||||
void StepWriteZero::PerformStep(ZoneWriter* zoneWriter, IWritingStream* stream)
|
||||
{
|
||||
const uint64_t num = 0;
|
||||
constexpr uint64_t num = 0;
|
||||
size_t toWrite;
|
||||
|
||||
for (auto i = 0u; i < m_count; i += toWrite)
|
||||
for (auto i = 0uz; i < m_count; i += toWrite)
|
||||
{
|
||||
toWrite = std::min(sizeof(uint64_t), m_count - i);
|
||||
stream->Write(&num, toWrite);
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
return static_cast<T*>(WriteDataInBlock(reinterpret_cast<const void*>(dst), sizeof(T)));
|
||||
}
|
||||
|
||||
template<typename T> T* Write(T* dst, const uint32_t count)
|
||||
template<typename T> T* Write(T* dst, const size_t count)
|
||||
{
|
||||
return static_cast<T*>(WriteDataInBlock(reinterpret_cast<const void*>(dst), count * sizeof(T)));
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ namespace
|
||||
|
||||
pos_type seekpos(const pos_type pos, std::ios_base::openmode) override
|
||||
{
|
||||
if (pos > m_data.size())
|
||||
if (pos > static_cast<pos_type>(m_data.size()))
|
||||
m_data.resize(static_cast<decltype(m_data)::size_type>(pos));
|
||||
m_pos = static_cast<size_t>(pos);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user