From 790765d8d78a5b51b483104c8360db48be0217da Mon Sep 17 00:00:00 2001 From: Omar Shehata Date: Fri, 19 Oct 2018 14:57:53 -0400 Subject: [PATCH] Done update if there are no clipping planes --- Source/Scene/ClippingPlaneCollection.js | 8 +++++++- Source/Scene/GlobeSurfaceShaderSet.js | 2 +- Source/Scene/Model.js | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/Scene/ClippingPlaneCollection.js b/Source/Scene/ClippingPlaneCollection.js index 8fb492a7173d..416d7592445c 100644 --- a/Source/Scene/ClippingPlaneCollection.js +++ b/Source/Scene/ClippingPlaneCollection.js @@ -505,10 +505,16 @@ define([ pixelsNeeded < 0.25 * currentPixelCount) { clippingPlanesTexture.destroy(); clippingPlanesTexture = undefined; + this._clippingPlanesTexture = undefined; } } - if (!defined(clippingPlanesTexture) && pixelsNeeded > 0) { + // If there are no clipping planes, there's nothing to update. + if (this.length === 0) { + return; + } + + if (!defined(clippingPlanesTexture)) { var requiredResolution = computeTextureResolution(pixelsNeeded, textureResolutionScratch); // Allocate twice as much space as needed to avoid frequent texture reallocation. // Allocate in the Y direction, since texture may be as wide as context texture support. diff --git a/Source/Scene/GlobeSurfaceShaderSet.js b/Source/Scene/GlobeSurfaceShaderSet.js index 39c1f1c6ab34..e1f84a38b692 100644 --- a/Source/Scene/GlobeSurfaceShaderSet.js +++ b/Source/Scene/GlobeSurfaceShaderSet.js @@ -145,7 +145,7 @@ define([ (imageryCutoutFlag << 21); var currentClippingShaderState = 0; - if (defined(clippingPlanes)) { + if (defined(clippingPlanes) && clippingPlanes.length > 0) { currentClippingShaderState = enableClippingPlanes ? clippingPlanes.clippingPlanesState : 0; } var surfaceShader = surfaceTile.surfaceShader; diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index 170d81da88eb..0ef261e12bfc 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -1086,7 +1086,7 @@ define([ function isClippingEnabled(model) { var clippingPlanes = model._clippingPlanes; - return defined(clippingPlanes) && clippingPlanes.enabled; + return defined(clippingPlanes) && clippingPlanes.enabled && clippingPlanes.length !== 0; } /** @@ -4250,7 +4250,7 @@ define([ // Regenerate shaders if ClippingPlaneCollection state changed or it was removed var clippingPlanes = this._clippingPlanes; var currentClippingPlanesState = 0; - if (defined(clippingPlanes) && clippingPlanes.enabled) { + if (defined(clippingPlanes) && clippingPlanes.enabled && clippingPlanes.length > 0) { var clippingPlaneOffsetMatrix = defaultValue(this.clippingPlaneOffsetMatrix, modelMatrix); Matrix4.multiply(context.uniformState.view3D, clippingPlaneOffsetMatrix, this._clippingPlaneModelViewMatrix); currentClippingPlanesState = clippingPlanes.clippingPlanesState;