Kaynağa Gözat

MeshBatch: restore disposeBuffers

Yuxiao Mao 5 ay önce
ebeveyn
işleme
fdd3006d58
1 değiştirilmiş dosya ile 20 ekleme ve 0 silme
  1. 20 0
      h3d/scene/MeshBatch.hx

+ 20 - 0
h3d/scene/MeshBatch.hx

@@ -358,6 +358,26 @@ class MeshBatch extends MultiMaterial {
 		instanceCount++;
 	}
 
+	public function disposeBuffers( useAllocator : Bool = true ) {
+		if( instanceCount == 0 ) return;
+		var p = dataPasses;
+		if ( useAllocator ) {
+			var alloc = hxd.impl.Allocator.get();
+			while( p != null ) {
+				for ( b in p.buffers )
+					alloc.disposeBuffer(b);
+				p.buffers.resize(0);
+				p = p.next;
+			}
+		} else {
+			while( p != null ) {
+				for ( b in p.buffers )
+					b.dispose();
+				p = p.next;
+			}
+		}
+	}
+
 	override function sync(ctx:RenderContext) {
 		super.sync(ctx);
 		if( instanceCount == 0 ) return;