forked from bartvdbraak/blender
Fix T39452: Meshes without materials causes a memory leak in the game engine
These types of meshes do not use material caching, and thus only the first created material would be saved, but subsequent ones were not. Those subsequent materials were then not being freed. Now we make sure to track all of the materials. Note: Meshes that cannot make use of material caching (no materials or using face textures) can still use up a large amount of RAM since a material is created per face.
This commit is contained in:
parent
84823220b8
commit
7ff123ce5c
@ -942,11 +942,12 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace
|
|||||||
// this way only one KX_BlenderMaterial object has to exist per bucket
|
// this way only one KX_BlenderMaterial object has to exist per bucket
|
||||||
bool bucketCreated;
|
bool bucketCreated;
|
||||||
RAS_MaterialBucket* bucket = scene->FindBucket(polymat, bucketCreated);
|
RAS_MaterialBucket* bucket = scene->FindBucket(polymat, bucketCreated);
|
||||||
if (bucketCreated) {
|
|
||||||
// this is needed to free up memory afterwards
|
// this is needed to free up memory afterwards.
|
||||||
|
// the converter will also prevent duplicates from being registered,
|
||||||
|
// so just register everything.
|
||||||
converter->RegisterPolyMaterial(polymat);
|
converter->RegisterPolyMaterial(polymat);
|
||||||
converter->RegisterBlenderMaterial(bl_mat);
|
converter->RegisterBlenderMaterial(bl_mat);
|
||||||
}
|
|
||||||
|
|
||||||
return bucket;
|
return bucket;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user