浏览代码

separate ofFloats/ofSubFloats

Nicolas Cannasse 11 年之前
父节点
当前提交
f999b75b8f
共有 2 个文件被更改,包括 9 次插入3 次删除
  1. 8 2
      h3d/Buffer.hx
  2. 1 1
      h3d/parts/Emitter.hx

+ 8 - 2
h3d/Buffer.hx

@@ -105,13 +105,19 @@ class Buffer {
 		}
 	}
 
-	public static function ofFloats( v : hxd.FloatBuffer, stride : Int, ?flags, ?vertices, ?allocPos ) {
-		var nvert = vertices == null ? Std.int(v.length / stride) : vertices;
+	public static function ofFloats( v : hxd.FloatBuffer, stride : Int, ?flags, ?allocPos ) {
+		var nvert = Std.int(v.length / stride);
 		var b = new Buffer(nvert, stride, flags, allocPos);
 		b.uploadVector(v, 0, nvert);
 		return b;
 	}
 
+	public static function ofSubFloats( v : hxd.FloatBuffer, stride : Int, vertices : Int, ?flags, ?allocPos ) {
+		var b = new Buffer(vertices, stride, flags, allocPos);
+		b.uploadVector(v, 0, vertices);
+		return b;
+	}
+
 }
 
 class BufferOffset {

+ 1 - 1
h3d/parts/Emitter.hx

@@ -558,7 +558,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		}
 		var stride = 10;
 		if( hasColor ) stride += 4;
-		var buffer = h3d.Buffer.ofFloats(tmp, stride, [Quads, Dynamic, RawFormat], Std.int(pos/stride));
+		var buffer = h3d.Buffer.ofSubFloats(tmp, stride, Std.int(pos/stride), [Quads, Dynamic, RawFormat]);
 		var size = eval(state.globalSize);
 
 		/*