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