Use weak pointer for MirrorModifierData mirror_ob to avoid memory leak
parent
90d1464405
commit
56b6446913
|
@ -153,6 +153,7 @@ void BlenderModifier_Mirror ::DoIt(aiNode &out, ConversionData &conv_data, const
|
|||
// hijacking the ABI, see the big note in BlenderModifierShowcase::ApplyModifiers()
|
||||
const MirrorModifierData &mir = static_cast<const MirrorModifierData &>(orig_modifier);
|
||||
ai_assert(mir.modifier.type == ModifierData::eModifierType_Mirror);
|
||||
std::shared_ptr<Object> mirror_ob = mir.mirror_ob.lock();
|
||||
|
||||
conv_data.meshes->reserve(conv_data.meshes->size() + out.mNumMeshes);
|
||||
|
||||
|
@ -167,8 +168,8 @@ void BlenderModifier_Mirror ::DoIt(aiNode &out, ConversionData &conv_data, const
|
|||
const float ys = mir.flag & MirrorModifierData::Flags_AXIS_Y ? -1.f : 1.f;
|
||||
const float zs = mir.flag & MirrorModifierData::Flags_AXIS_Z ? -1.f : 1.f;
|
||||
|
||||
if (mir.mirror_ob) {
|
||||
const aiVector3D center(mir.mirror_ob->obmat[3][0], mir.mirror_ob->obmat[3][1], mir.mirror_ob->obmat[3][2]);
|
||||
if (mirror_ob) {
|
||||
const aiVector3D center(mirror_ob->obmat[3][0], mirror_ob->obmat[3][1], mirror_ob->obmat[3][2]);
|
||||
for (unsigned int j = 0; j < mesh->mNumVertices; ++j) {
|
||||
aiVector3D &v = mesh->mVertices[j];
|
||||
|
||||
|
|
|
@ -772,7 +772,9 @@ void Structure ::Convert<MirrorModifierData>(
|
|||
ReadField<ErrorPolicy_Igno>(dest.axis, "axis", db);
|
||||
ReadField<ErrorPolicy_Igno>(dest.flag, "flag", db);
|
||||
ReadField<ErrorPolicy_Igno>(dest.tolerance, "tolerance", db);
|
||||
ReadFieldPtr<ErrorPolicy_Igno>(dest.mirror_ob, "*mirror_ob", db);
|
||||
std::shared_ptr<Object> mirror_ob;
|
||||
ReadFieldPtr<ErrorPolicy_Igno>(mirror_ob, "*mirror_ob", db);
|
||||
dest.mirror_ob = mirror_ob;
|
||||
|
||||
db.reader->IncPtr(size);
|
||||
}
|
||||
|
|
|
@ -690,7 +690,7 @@ struct MirrorModifierData : SharedModifierData {
|
|||
|
||||
short axis, flag;
|
||||
float tolerance;
|
||||
std::shared_ptr<Object> mirror_ob;
|
||||
std::weak_ptr<Object> mirror_ob;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue