diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2014-03-28 00:46:22 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2014-03-28 00:51:07 +0400 |
commit | 7ff123ce5c08953a31f5728922be9d56c4ed850c (patch) | |
tree | b767a22fd213546b4bdeeea2d682285010943a80 | |
parent | 84823220b8d2216e25eedcce70ec2edf6b430293 (diff) |
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.
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 9eba103e7c0..8779cdd3249 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -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 bool bucketCreated; RAS_MaterialBucket* bucket = scene->FindBucket(polymat, bucketCreated); - if (bucketCreated) { - // this is needed to free up memory afterwards - converter->RegisterPolyMaterial(polymat); - converter->RegisterBlenderMaterial(bl_mat); - } + + // 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->RegisterBlenderMaterial(bl_mat); return bucket; } |