Browse Source

Fix particles, align particle data

Ben Adams 9 years ago
parent
commit
3af010fdd2
2 changed files with 5 additions and 6 deletions
  1. 1 1
      src/Mesh/babylon.buffer.ts
  2. 4 5
      src/Particles/babylon.particleSystem.ts

+ 1 - 1
src/Mesh/babylon.buffer.ts

@@ -30,7 +30,7 @@
 
         public createVertexBuffer(kind: string, offset: number, size: number, stride?: number): VertexBuffer {
             // a lot of these parameters are ignored as they are overriden by the buffer
-            return new VertexBuffer(this._engine, this, kind, this._updatable, true, stride, this._instanced, offset, size);
+            return new VertexBuffer(this._engine, this, kind, this._updatable, true, stride ? stride : this._strideSize, this._instanced, offset, size);
         }
 
         // Properties

+ 4 - 5
src/Particles/babylon.particleSystem.ts

@@ -123,9 +123,9 @@
 
             this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
 
-            // 11 floats per particle (x, y, z, r, g, b, a, angle, size, offsetX, offsetY)
-            this._vertexData = new Float32Array(capacity * 11);
-            this._vertexBuffer = new Buffer(scene.getEngine(), this._vertexData, true, 11);
+            // 11 floats per particle (x, y, z, r, g, b, a, angle, size, offsetX, offsetY) + 1 filler
+            this._vertexData = new Float32Array(capacity * 12);
+            this._vertexBuffer = new Buffer(scene.getEngine(), this._vertexData, true, 12);
 
             var positions = this._vertexBuffer.createVertexBuffer(VertexBuffer.PositionKind, 0, 3);
             var colors = this._vertexBuffer.createVertexBuffer(VertexBuffer.ColorKind, 3, 4);
@@ -213,7 +213,7 @@
         }
 
         public _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void {
-            var offset = index * 11;
+            var offset = index * 12;
             this._vertexData[offset] = particle.position.x;
             this._vertexData[offset + 1] = particle.position.y;
             this._vertexData[offset + 2] = particle.position.z;
@@ -449,7 +449,6 @@
         public clone(name: string, newEmitter: any): ParticleSystem {
             var result = new ParticleSystem(name, this._capacity, this._scene);
 
-            // TODO
             Tools.DeepCopy(this, result, ["particles"]);
 
             if (newEmitter === undefined) {