Fix T37920: BGE LibLoad failed for meshes with no materials

This commit is contained in:
Campbell Barton 2013-12-30 15:49:13 +11:00
parent 0d6ae3fda2
commit 6a473305af
Notes: blender-bot 2023-02-14 11:27:28 +01:00
Referenced by commit 51c32ac199, Revert "Fix T37920: BGE LibLoad failed for meshes with no materials"
Referenced by issue #38133, Deleting a single dupligroup instance removes all instances
Referenced by issue #37920, Repeatedly calling LibLoad and LibFree on the same library / blend will cause a crash.
4 changed files with 25 additions and 3 deletions

View File

@ -1313,6 +1313,8 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie)
int size_before = obs->GetCount();
gameobj->RemoveMeshes();
/* Eventually calls RemoveNodeDestructObject
* frees m_map_gameobject_to_blender from UnregisterGameObject */
scene->RemoveObject(gameobj);

View File

@ -558,7 +558,7 @@ RAS_MeshSlot* RAS_MaterialBucket::CopyMesh(RAS_MeshSlot *ms)
return &m_meshSlots.back();
}
void RAS_MaterialBucket::RemoveMesh(RAS_MeshSlot* ms)
void RAS_MaterialBucket::RemoveMeshSlot(RAS_MeshSlot *ms)
{
list<RAS_MeshSlot>::iterator it;
@ -570,6 +570,20 @@ void RAS_MaterialBucket::RemoveMesh(RAS_MeshSlot* ms)
}
}
void RAS_MaterialBucket::RemoveMesh(RAS_MeshObject *mesh)
{
list<RAS_MeshSlot>::iterator it;
it=m_meshSlots.begin();
while (it != m_meshSlots.end()) {
if ((*it).m_mesh == mesh) {
m_meshSlots.erase(it++);
}
else {
++it;
}
}
}
list<RAS_MeshSlot>::iterator RAS_MaterialBucket::msBegin()
{
return m_meshSlots.begin();

View File

@ -228,7 +228,8 @@ public:
class RAS_MeshSlot* AddMesh(int numverts);
class RAS_MeshSlot* CopyMesh(class RAS_MeshSlot *ms);
void RemoveMesh(class RAS_MeshSlot* ms);
void RemoveMeshSlot(class RAS_MeshSlot *ms);
void RemoveMesh(class RAS_MeshObject *mesh);
void Optimize(MT_Scalar distance);
void ActivateMesh(RAS_MeshSlot* slot)
{

View File

@ -458,9 +458,14 @@ void RAS_MeshObject::RemoveFromBuckets(void *clientobj)
if (!msp)
continue;
/* see [#37920] */
#if 0
RAS_MeshSlot *ms = *msp;
it->m_bucket->RemoveMesh(ms);
it->m_bucket->RemoveMeshSlot(ms);
#else
it->m_bucket->RemoveMesh(this);
#endif
it->m_slots.remove(clientobj);
}
}