Browse Source

report more accurately clear while flushing error

ncannasse 8 years ago
parent
commit
9d31ddef1a
1 changed files with 8 additions and 5 deletions
  1. 8 5
      h3d/prim/BigPrimitive.hx

+ 8 - 5
h3d/prim/BigPrimitive.hx

@@ -16,6 +16,7 @@ class BigPrimitive extends Primitive {
 	var bufPos : Int;
 	var idxPos : Int;
 	var startIndex : Int;
+	var flushing : Bool;
 	#if debug
 	var allocPos : h3d.impl.AllocPos;
 	#end
@@ -106,21 +107,19 @@ class BigPrimitive extends Primitive {
 		return count;
 	}
 
-	static var TOTAL = 0;
-
 	/**
 		Flush the current buffer.
 		It is required to call begin() after a flush()
 	**/
 	public function flush() {
 		if( tmpBuf != null ) {
-			if( tmpIdx == null ) throw "tmpIdx is null";
 			if( bufPos > 0 && idxPos > 0 ) {
-				var b = h3d.Buffer.ofSubFloats(tmpBuf, stride, Std.int(bufPos/stride) #if debug ,null,allocPos #end);
+				flushing = true;
+				var b = h3d.Buffer.ofSubFloats(tmpBuf, stride, Std.int(bufPos / stride) #if debug , null, allocPos #end);
 				if( isRaw ) b.flags.set(RawFormat);
 				buffers.push(b);
-				if( tmpIdx == null ) throw "tmpIdx is null(2)";
 				allIndexes.push(h3d.Indexes.alloc(tmpIdx, 0, idxPos));
+				flushing = false;
 			}
 			if( PREV_BUFFER == null || PREV_BUFFER.length < tmpBuf.length )
 				PREV_BUFFER = tmpBuf;
@@ -149,6 +148,10 @@ class BigPrimitive extends Primitive {
 	}
 
 	public function clear() {
+
+		if( flushing )
+			throw "Cannot clear() BigPrimitive while it's flushing";
+
 		bounds.empty();
 		for( b in buffers )
 			b.dispose();