Просмотр исходного кода

- Fixing a bug on post processes indices.
- Fixing a bug on not reusable post process.
- Fixing a bug who could generate an error in PostProcess/babylon.postProcessManager.js

michael-korbas 11 лет назад
Родитель
Сommit
d92f8c0416

+ 8 - 2
Babylon/Cameras/babylon.camera.js

@@ -160,6 +160,7 @@ var BABYLON = BABYLON || {};
 
     BABYLON.Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
         if (!postProcess._reusable && this._postProcesses.indexOf(postProcess) > -1) {
+            console.error("You're trying to reuse a post process not defined as reusable.");
             return;
         }
 
@@ -185,7 +186,7 @@ var BABYLON = BABYLON || {};
         }
 
         for (var i = 0; i < this._postProcessesTakenIndices.length; ++i) {
-            if (this._postProcessesTakentIndices[i] < insertAt) {
+            if (this._postProcessesTakenIndices[i] < insertAt) {
                 continue;
             }
 
@@ -197,6 +198,10 @@ var BABYLON = BABYLON || {};
             break;
         }
 
+        if (!add && this._postProcessesTakenIndices.indexOf(insertAt) == -1) {
+            this._postProcessesTakenIndices.push(insertAt);
+        }
+
         result = insertAt + add;
 
         this._postProcesses[result] = postProcess;
@@ -207,6 +212,8 @@ var BABYLON = BABYLON || {};
     BABYLON.Camera.prototype.detachPostProcess = function (postProcess, atIndices) {
         var result = [];
 
+        atIndices = (atIndices instanceof Array) ? atIndices : [atIndices];
+
         if (!atIndices) {
 
             var length = this._postProcesses.length;
@@ -224,7 +231,6 @@ var BABYLON = BABYLON || {};
             }
 
         }
-
         else {
             for (var i = 0; i < atIndices.length; i++) {
                 var foundPostProcess = this._postProcesses[atIndices[i]];

+ 3 - 1
Babylon/PostProcess/babylon.postProcess.js

@@ -77,7 +77,9 @@ var BABYLON = BABYLON || {};
         // Clear
         this._engine.clear(scene.clearColor, scene.autoClear || scene.forceWireframe, true);
 
-        this._currentRenderTextureInd = (this._currentRenderTextureInd+1)%2;
+        if (this._reusable) {
+            this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
+        }
     };
 
     BABYLON.PostProcess.prototype.apply = function () {

+ 1 - 1
Babylon/PostProcess/babylon.postProcessManager.js

@@ -50,7 +50,7 @@ var BABYLON = BABYLON || {};
         var engine = this._scene.getEngine();
         
         for (var index = 0; index < postProcessesTakenIndices.length; index++) {
-            if (postProcessesTakenIndices[index] < postProcesses.length - 1) {
+            if (postProcessesTakenIndices[index] < postProcessesTakenIndices.length - 1) {
                 postProcesses[postProcessesTakenIndices[index + 1]].activate(this._scene.activeCamera);
             } else {
                 engine.restoreDefaultFramebuffer();