Browse Source

Fix tiny bugs with gpuparticle.stop

David Catuhe 7 years ago
parent
commit
3dd95db58e

File diff suppressed because it is too large
+ 9994 - 9994
Playground/babylon.d.txt


File diff suppressed because it is too large
+ 9862 - 9862
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 18 - 18
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 11 - 4
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 18 - 18
dist/preview release/babylon.worker.js


File diff suppressed because it is too large
+ 2622 - 2622
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


File diff suppressed because it is too large
+ 18 - 18
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 6 - 0
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -24096,6 +24096,12 @@ var BABYLON;
          * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
          */
         Scene.prototype.freezeActiveMeshes = function () {
+            if (!this.activeCamera) {
+                return this;
+            }
+            if (!this._frustumPlanes) {
+                this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
+            }
             this._evaluateActiveMeshes();
             this._activeMeshesFrozen = true;
             return this;

File diff suppressed because it is too large
+ 8 - 2
dist/preview release/customConfigurations/minimalGLTFViewer/es6.js


File diff suppressed because it is too large
+ 13 - 6
dist/preview release/es6.js


File diff suppressed because it is too large
+ 12 - 12
dist/preview release/viewer/babylon.viewer.js


File diff suppressed because it is too large
+ 11 - 4
dist/preview release/viewer/babylon.viewer.max.js


+ 6 - 2
src/Engine/babylon.engine.ts

@@ -214,6 +214,7 @@
         generateStencilBuffer?: boolean;
         type?: number;
         samplingMode?: number;
+        format?: number;
     }
 
     /**
@@ -3883,12 +3884,14 @@
                 fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
                 fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
                 fullOptions.samplingMode = options.samplingMode === undefined ? Texture.TRILINEAR_SAMPLINGMODE : options.samplingMode;
+                fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
             } else {
                 fullOptions.generateMipMaps = <boolean>options;
                 fullOptions.generateDepthBuffer = true;
                 fullOptions.generateStencilBuffer = false;
                 fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
                 fullOptions.samplingMode = Texture.TRILINEAR_SAMPLINGMODE;
+                fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
             }
 
             if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
@@ -3919,7 +3922,7 @@
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
 
-            gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type), width, height, 0, gl.RGBA, this._getWebGLTextureType(fullOptions.type), null);
+            gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
 
             // Create the framebuffer
             var framebuffer = gl.createFramebuffer();
@@ -4302,6 +4305,7 @@
               generateStencilBuffer: false,
               type: Engine.TEXTURETYPE_UNSIGNED_INT,
               samplingMode: Texture.TRILINEAR_SAMPLINGMODE,
+              format: Engine.TEXTUREFORMAT_RGBA,
               ...options
             };
             fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
@@ -4332,7 +4336,7 @@
             gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
 
             for (var face = 0; face < 6; face++) {
-                gl.texImage2D((gl.TEXTURE_CUBE_MAP_POSITIVE_X + face), 0, this._getRGBABufferInternalSizedFormat(fullOptions.type), size, size, 0, gl.RGBA, this._getWebGLTextureType(fullOptions.type), null);
+                gl.texImage2D((gl.TEXTURE_CUBE_MAP_POSITIVE_X + face), 0, this._getRGBABufferInternalSizedFormat(fullOptions.type), size, size, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
             }
 
             // Create the framebuffer

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

@@ -496,12 +496,13 @@
          * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
          */
         public animate(): void {           
-            if (!this._stopped) {
-                this._timeDelta = this.updateSpeed * this._scene.getAnimationRatio();   
-                this._actualFrame += this._timeDelta;
+            this._timeDelta = this.updateSpeed * this._scene.getAnimationRatio();   
+            this._actualFrame += this._timeDelta;
 
-                if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration)
+            if (!this._stopped) {
+                if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
                     this.stop();
+                }
             }             
         }        
 

+ 1 - 1
src/Shaders/gpuUpdateParticles.vertex.fx

@@ -74,7 +74,7 @@ void main() {
       outLife = life;
       outSeed = seed;
       outColor = vec4(0.,0.,0.,0.);
-      outSize = size;
+      outSize = 0.;
       outDirection = direction;
       return;
     }

+ 8 - 0
src/babylon.scene.ts

@@ -3237,6 +3237,14 @@
          * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
          */
         public freezeActiveMeshes(): Scene {
+            if (!this.activeCamera) {
+                return this;
+            }
+            
+            if (!this._frustumPlanes) {
+                this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
+            }
+
             this._evaluateActiveMeshes();
             this._activeMeshesFrozen = true;
             return this;

+ 1 - 0
tests/validation/config.json

@@ -386,6 +386,7 @@
     },
     {
       "title": "Instances",
+      "renderCount": 2,
       "scriptToRun": "/Demos/Instances/instances.js",
       "functionToCall": "CreateInstancesTestScene",
       "referenceImage": "instances.png",