Przeglądaj źródła

remove gc garbage reference on dispose()

Nicolas Cannasse 6 lat temu
rodzic
commit
e4da4c8e48
1 zmienionych plików z 6 dodań i 0 usunięć
  1. 6 0
      h3d/scene/World.hx

+ 6 - 0
h3d/scene/World.hx

@@ -199,6 +199,7 @@ class World extends Object {
 	var allChunks : Array<WorldChunk>;
 	var bigTextures : Array<{ diffuse : h3d.mat.BigTexture, spec : h3d.mat.BigTexture, normal : h3d.mat.BigTexture }>;
 	var textures : Map<String, WorldMaterial>;
+	var autoCollect : Bool;
 
 	public function new( chunkSize : Int, worldSize : Int, ?parent, ?autoCollect = true ) {
 		super(parent);
@@ -209,6 +210,7 @@ class World extends Object {
 		this.chunkSize = chunkSize;
 		this.worldSize = worldSize;
 		this.worldStride = Math.ceil(worldSize / chunkSize);
+		this.autoCollect = autoCollect;
 		if( autoCollect )
 			h3d.Engine.getCurrent().mem.garbage = garbage;
 	}
@@ -606,8 +608,12 @@ class World extends Object {
 		}
 		bigTextures = [];
 		textures = new Map();
+		if( autoCollect )
+			h3d.Engine.getCurrent().mem.garbage = noGarbage;
 	}
 
+	static function noGarbage() {}
+
 	public function onContextLost() {
 		for( c in allChunks )
 			cleanChunk(c);