浏览代码

MeshBatch: restore disposeBuffers

Yuxiao Mao 5 月之前
父节点
当前提交
fdd3006d58
共有 1 个文件被更改,包括 20 次插入0 次删除
  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;