Răsfoiți Sursa

Fix leak in chunkified scene

ShiroSmith 5 ani în urmă
părinte
comite
3b80a5c270
2 a modificat fișierele cu 14 adăugiri și 1 ștergeri
  1. 8 1
      hide/Scene.hx
  2. 6 0
      hide/comp/SceneEditor.hx

+ 8 - 1
hide/Scene.hx

@@ -229,7 +229,6 @@ class Chunk {
 		bounds.zMax = 0;
 	}
 
-
 	public inline function addObject( obj : h3d.scene.Object, b : h3d.col.Bounds) {
 		objectCount++;
 		if( objectCount > objects.length )
@@ -257,6 +256,14 @@ class Scene extends h3d.scene.Scene {
 	public function new() {
 		super();
 	}
+
+	public function reset() {
+		for( c in cs.chunks ) {
+			c.reset();
+			c.objects = [];
+			c.interactives = [];
+		}
+	}
 	
 	override function emitRec( ctx : h3d.scene.RenderContext ) {
 

+ 6 - 0
hide/comp/SceneEditor.hx

@@ -539,6 +539,12 @@ class SceneEditor {
 		var sh = context.shared;
 		sh.root3d.remove();
 		sh.root2d.remove();
+
+		// Prevent leaks
+		var chunkiFiedScene = Std.downcast(scene.s3d, hide.Scene);
+		if( chunkiFiedScene != null )
+			chunkiFiedScene.reset();
+
 		for( c in sh.contexts )
 			if( c != null && c.cleanup != null )
 				c.cleanup();