Skip to content

Commit

Permalink
Done update if there are no clipping planes
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar Shehata committed Oct 19, 2018
1 parent 1f1b317 commit 790765d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Source/Scene/ClippingPlaneCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/GlobeSurfaceShaderSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 790765d

Please sign in to comment.