瀏覽代碼

Don't preallocate BigPrim for Graphics (#343)

trethaller 7 年之前
父節點
當前提交
e741faa472
共有 2 個文件被更改,包括 4 次插入1 次删除
  1. 3 1
      h3d/prim/BigPrimitive.hx
  2. 1 0
      h3d/scene/Graphics.hx

+ 3 - 1
h3d/prim/BigPrimitive.hx

@@ -21,6 +21,8 @@ class BigPrimitive extends Primitive {
 	var allocPos : h3d.impl.AllocPos;
 	#end
 
+	public var isStatic = true;
+
 	static var PREV_BUFFER : hxd.FloatBuffer;
 	static var PREV_INDEX : hxd.IndexBuffer;
 
@@ -52,7 +54,7 @@ class BigPrimitive extends Primitive {
 				tmpBuf = new hxd.FloatBuffer();
 			else
 				PREV_BUFFER = null;
-			tmpBuf.grow(65535 * stride);
+			if( isStatic ) tmpBuf.grow(65535 * stride);
 		}
 		if( tmpIdx == null ) {
 			tmpIdx = PREV_INDEX;

+ 1 - 0
h3d/scene/Graphics.hx

@@ -41,6 +41,7 @@ class Graphics extends Mesh {
 
 	public function new(?parent) {
 		bprim = new h3d.prim.BigPrimitive(12);
+		bprim.isStatic = false;
 		super(bprim, null, parent);
 		tmpPoints = [];
 		lineShader = new h3d.shader.LineShader();