mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
fix: use after free when dumping xmodel vertex weights
This commit is contained in:
parent
826e59d627
commit
2497a9f228
@ -393,10 +393,11 @@ namespace
|
|||||||
weightCollection.weights.resize(totalWeightCount);
|
weightCollection.weights.resize(totalWeightCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddXModelVertexBoneWeights(XModelCommon& out, const XModel* model, const unsigned lod, XModelVertexBoneWeightCollection& weightCollection)
|
void AddXModelVertexBoneWeights(XModelCommon& out, const XModel* model, const unsigned lod)
|
||||||
{
|
{
|
||||||
const auto* surfs = &model->surfs[model->lodInfo[lod].surfIndex];
|
const auto* surfs = &model->surfs[model->lodInfo[lod].surfIndex];
|
||||||
const auto surfCount = model->lodInfo[lod].numsurfs;
|
const auto surfCount = model->lodInfo[lod].numsurfs;
|
||||||
|
auto& weightCollection = out.m_bone_weight_data;
|
||||||
|
|
||||||
size_t weightOffset = 0u;
|
size_t weightOffset = 0u;
|
||||||
|
|
||||||
@ -533,14 +534,13 @@ namespace
|
|||||||
void PopulateXModelWriter(XModelCommon& out, const AssetDumpingContext& context, const unsigned lod, const XModel* model)
|
void PopulateXModelWriter(XModelCommon& out, const AssetDumpingContext& context, const unsigned lod, const XModel* model)
|
||||||
{
|
{
|
||||||
DistinctMapper<Material*> materialMapper(model->numsurfs);
|
DistinctMapper<Material*> materialMapper(model->numsurfs);
|
||||||
XModelVertexBoneWeightCollection boneWeightCollection;
|
AllocateXModelBoneWeights(model, lod, out.m_bone_weight_data);
|
||||||
AllocateXModelBoneWeights(model, lod, boneWeightCollection);
|
|
||||||
|
|
||||||
AddXModelBones(out, context, model);
|
AddXModelBones(out, context, model);
|
||||||
AddXModelMaterials(out, materialMapper, model);
|
AddXModelMaterials(out, materialMapper, model);
|
||||||
AddXModelObjects(out, model, lod, materialMapper);
|
AddXModelObjects(out, model, lod, materialMapper);
|
||||||
AddXModelVertices(out, model, lod);
|
AddXModelVertices(out, model, lod);
|
||||||
AddXModelVertexBoneWeights(out, model, lod, boneWeightCollection);
|
AddXModelVertexBoneWeights(out, model, lod);
|
||||||
AddXModelFaces(out, model, lod);
|
AddXModelFaces(out, model, lod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,8 +390,9 @@ namespace
|
|||||||
weightCollection.weights.resize(totalWeightCount);
|
weightCollection.weights.resize(totalWeightCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddXModelVertexBoneWeights(XModelCommon& out, const XModelSurfs* modelSurfs, XModelVertexBoneWeightCollection& weightCollection)
|
void AddXModelVertexBoneWeights(XModelCommon& out, const XModelSurfs* modelSurfs)
|
||||||
{
|
{
|
||||||
|
auto& weightCollection = out.m_bone_weight_data;
|
||||||
size_t weightOffset = 0u;
|
size_t weightOffset = 0u;
|
||||||
|
|
||||||
for (auto surfIndex = 0u; surfIndex < modelSurfs->numsurfs; surfIndex++)
|
for (auto surfIndex = 0u; surfIndex < modelSurfs->numsurfs; surfIndex++)
|
||||||
@ -526,14 +527,13 @@ namespace
|
|||||||
const auto* modelSurfs = model->lodInfo[lod].modelSurfs;
|
const auto* modelSurfs = model->lodInfo[lod].modelSurfs;
|
||||||
|
|
||||||
DistinctMapper<Material*> materialMapper(model->numsurfs);
|
DistinctMapper<Material*> materialMapper(model->numsurfs);
|
||||||
XModelVertexBoneWeightCollection boneWeightCollection;
|
AllocateXModelBoneWeights(modelSurfs, out.m_bone_weight_data);
|
||||||
AllocateXModelBoneWeights(modelSurfs, boneWeightCollection);
|
|
||||||
|
|
||||||
AddXModelBones(out, context, model);
|
AddXModelBones(out, context, model);
|
||||||
AddXModelMaterials(out, materialMapper, model);
|
AddXModelMaterials(out, materialMapper, model);
|
||||||
AddXModelObjects(out, modelSurfs, materialMapper, model->lodInfo[lod].surfIndex);
|
AddXModelObjects(out, modelSurfs, materialMapper, model->lodInfo[lod].surfIndex);
|
||||||
AddXModelVertices(out, modelSurfs);
|
AddXModelVertices(out, modelSurfs);
|
||||||
AddXModelVertexBoneWeights(out, modelSurfs, boneWeightCollection);
|
AddXModelVertexBoneWeights(out, modelSurfs);
|
||||||
AddXModelFaces(out, modelSurfs);
|
AddXModelFaces(out, modelSurfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,8 +389,9 @@ namespace
|
|||||||
weightCollection.weights.resize(totalWeightCount);
|
weightCollection.weights.resize(totalWeightCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddXModelVertexBoneWeights(XModelCommon& out, const XModelSurfs* modelSurfs, XModelVertexBoneWeightCollection& weightCollection)
|
void AddXModelVertexBoneWeights(XModelCommon& out, const XModelSurfs* modelSurfs)
|
||||||
{
|
{
|
||||||
|
auto& weightCollection = out.m_bone_weight_data;
|
||||||
size_t weightOffset = 0u;
|
size_t weightOffset = 0u;
|
||||||
|
|
||||||
for (auto surfIndex = 0u; surfIndex < modelSurfs->numsurfs; surfIndex++)
|
for (auto surfIndex = 0u; surfIndex < modelSurfs->numsurfs; surfIndex++)
|
||||||
@ -525,14 +526,13 @@ namespace
|
|||||||
const auto* modelSurfs = model->lodInfo[lod].modelSurfs;
|
const auto* modelSurfs = model->lodInfo[lod].modelSurfs;
|
||||||
|
|
||||||
DistinctMapper<Material*> materialMapper(model->numsurfs);
|
DistinctMapper<Material*> materialMapper(model->numsurfs);
|
||||||
XModelVertexBoneWeightCollection boneWeightCollection;
|
AllocateXModelBoneWeights(modelSurfs, out.m_bone_weight_data);
|
||||||
AllocateXModelBoneWeights(modelSurfs, boneWeightCollection);
|
|
||||||
|
|
||||||
AddXModelBones(out, context, model);
|
AddXModelBones(out, context, model);
|
||||||
AddXModelMaterials(out, materialMapper, model);
|
AddXModelMaterials(out, materialMapper, model);
|
||||||
AddXModelObjects(out, modelSurfs, materialMapper, model->lodInfo[lod].surfIndex);
|
AddXModelObjects(out, modelSurfs, materialMapper, model->lodInfo[lod].surfIndex);
|
||||||
AddXModelVertices(out, modelSurfs);
|
AddXModelVertices(out, modelSurfs);
|
||||||
AddXModelVertexBoneWeights(out, modelSurfs, boneWeightCollection);
|
AddXModelVertexBoneWeights(out, modelSurfs);
|
||||||
AddXModelFaces(out, modelSurfs);
|
AddXModelFaces(out, modelSurfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,10 +393,11 @@ namespace
|
|||||||
weightCollection.weights.resize(totalWeightCount);
|
weightCollection.weights.resize(totalWeightCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddXModelVertexBoneWeights(XModelCommon& out, const XModel* model, const unsigned lod, XModelVertexBoneWeightCollection& weightCollection)
|
void AddXModelVertexBoneWeights(XModelCommon& out, const XModel* model, const unsigned lod)
|
||||||
{
|
{
|
||||||
const auto* surfs = &model->surfs[model->lodInfo[lod].surfIndex];
|
const auto* surfs = &model->surfs[model->lodInfo[lod].surfIndex];
|
||||||
const auto surfCount = model->lodInfo[lod].numsurfs;
|
const auto surfCount = model->lodInfo[lod].numsurfs;
|
||||||
|
auto& weightCollection = out.m_bone_weight_data;
|
||||||
|
|
||||||
size_t weightOffset = 0u;
|
size_t weightOffset = 0u;
|
||||||
|
|
||||||
@ -533,14 +534,13 @@ namespace
|
|||||||
void PopulateXModelWriter(XModelCommon& out, const AssetDumpingContext& context, const unsigned lod, const XModel* model)
|
void PopulateXModelWriter(XModelCommon& out, const AssetDumpingContext& context, const unsigned lod, const XModel* model)
|
||||||
{
|
{
|
||||||
DistinctMapper<Material*> materialMapper(model->numsurfs);
|
DistinctMapper<Material*> materialMapper(model->numsurfs);
|
||||||
XModelVertexBoneWeightCollection boneWeightCollection;
|
AllocateXModelBoneWeights(model, lod, out.m_bone_weight_data);
|
||||||
AllocateXModelBoneWeights(model, lod, boneWeightCollection);
|
|
||||||
|
|
||||||
AddXModelBones(out, context, model);
|
AddXModelBones(out, context, model);
|
||||||
AddXModelMaterials(out, materialMapper, model);
|
AddXModelMaterials(out, materialMapper, model);
|
||||||
AddXModelObjects(out, model, lod, materialMapper);
|
AddXModelObjects(out, model, lod, materialMapper);
|
||||||
AddXModelVertices(out, model, lod);
|
AddXModelVertices(out, model, lod);
|
||||||
AddXModelVertexBoneWeights(out, model, lod, boneWeightCollection);
|
AddXModelVertexBoneWeights(out, model, lod);
|
||||||
AddXModelFaces(out, model, lod);
|
AddXModelFaces(out, model, lod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,10 +411,11 @@ namespace
|
|||||||
weightCollection.weights.resize(totalWeightCount);
|
weightCollection.weights.resize(totalWeightCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddXModelVertexBoneWeights(XModelCommon& out, const XModel* model, const unsigned lod, XModelVertexBoneWeightCollection& weightCollection)
|
void AddXModelVertexBoneWeights(XModelCommon& out, const XModel* model, const unsigned lod)
|
||||||
{
|
{
|
||||||
const auto* surfs = &model->surfs[model->lodInfo[lod].surfIndex];
|
const auto* surfs = &model->surfs[model->lodInfo[lod].surfIndex];
|
||||||
const auto surfCount = model->lodInfo[lod].numsurfs;
|
const auto surfCount = model->lodInfo[lod].numsurfs;
|
||||||
|
auto& weightCollection = out.m_bone_weight_data;
|
||||||
|
|
||||||
if (!surfs)
|
if (!surfs)
|
||||||
return;
|
return;
|
||||||
@ -557,14 +558,13 @@ namespace
|
|||||||
void PopulateXModelWriter(XModelCommon& out, const AssetDumpingContext& context, const unsigned lod, const XModel* model)
|
void PopulateXModelWriter(XModelCommon& out, const AssetDumpingContext& context, const unsigned lod, const XModel* model)
|
||||||
{
|
{
|
||||||
DistinctMapper<Material*> materialMapper(model->numsurfs);
|
DistinctMapper<Material*> materialMapper(model->numsurfs);
|
||||||
XModelVertexBoneWeightCollection boneWeightCollection;
|
AllocateXModelBoneWeights(model, lod, out.m_bone_weight_data);
|
||||||
AllocateXModelBoneWeights(model, lod, boneWeightCollection);
|
|
||||||
|
|
||||||
AddXModelBones(out, context, model);
|
AddXModelBones(out, context, model);
|
||||||
AddXModelMaterials(out, materialMapper, model);
|
AddXModelMaterials(out, materialMapper, model);
|
||||||
AddXModelObjects(out, model, lod, materialMapper);
|
AddXModelObjects(out, model, lod, materialMapper);
|
||||||
AddXModelVertices(out, model, lod);
|
AddXModelVertices(out, model, lod);
|
||||||
AddXModelVertexBoneWeights(out, model, lod, boneWeightCollection);
|
AddXModelVertexBoneWeights(out, model, lod);
|
||||||
AddXModelFaces(out, model, lod);
|
AddXModelFaces(out, model, lod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user