[Bf-blender-cvs] [7ff123c] master: Fix T39452: Meshes without materials causes a memory leak in the game engine

Mitchell Stokes noreply at git.blender.org
Thu Mar 27 21:51:53 CET 2014


Commit: 7ff123ce5c08953a31f5728922be9d56c4ed850c
Author: Mitchell Stokes
Date:   Thu Mar 27 13:46:22 2014 -0700
https://developer.blender.org/rB7ff123ce5c08953a31f5728922be9d56c4ed850c

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.

===================================================================

M	source/gameengine/Converter/BL_BlenderDataConversion.cpp

===================================================================

diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 9eba103..8779cdd 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;
 }




More information about the Bf-blender-cvs mailing list