Skip to content

Commit

Permalink
Minor clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
bagnell committed Feb 16, 2018
1 parent 567a110 commit 7c46e11
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 27 deletions.
14 changes: 6 additions & 8 deletions Source/Scene/ClassificationPrimitive.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
define([
'../Core/ColorGeometryInstanceAttribute',
'../Core/combine',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
Expand All @@ -26,7 +25,6 @@ define([
'./StencilOperation'
], function(
ColorGeometryInstanceAttribute,
combine,
defaultValue,
defined,
defineProperties,
Expand Down Expand Up @@ -594,7 +592,7 @@ define([
});
}

function createColorCommands(classificationPrimitive, colorCommands, frameState) {
function createColorCommands(classificationPrimitive, colorCommands) {
var primitive = classificationPrimitive._primitive;
var length = primitive._va.length * 3;
colorCommands.length = length;
Expand Down Expand Up @@ -669,7 +667,7 @@ define([
}
}

function createPickCommands(classificationPrimitive, pickCommands, frameState) {
function createPickCommands(classificationPrimitive, pickCommands) {
var primitive = classificationPrimitive._primitive;
var pickOffsets = primitive._pickOffsets;
var length = pickOffsets.length * 3;
Expand Down Expand Up @@ -737,9 +735,9 @@ define([
}
}

function createCommands(classificationPrimitive, appearance, material, translucent, twoPasses, colorCommands, pickCommands, frameState) {
createColorCommands(classificationPrimitive, colorCommands, frameState);
createPickCommands(classificationPrimitive, pickCommands, frameState);
function createCommands(classificationPrimitive, appearance, material, translucent, twoPasses, colorCommands, pickCommands) {
createColorCommands(classificationPrimitive, colorCommands);
createPickCommands(classificationPrimitive, pickCommands);
}

function boundingVolumeIndex(commandIndex, length) {
Expand Down Expand Up @@ -892,7 +890,7 @@ define([
createShaderProgram(that, frameState);
};
primitiveOptions._createCommandsFunction = function(primitive, appearance, material, translucent, twoPasses, colorCommands, pickCommands) {
createCommands(that, undefined, undefined, true, false, colorCommands, pickCommands, frameState);
createCommands(that, undefined, undefined, true, false, colorCommands, pickCommands);
};

if (defined(this._updateAndQueueCommandsFunction)) {
Expand Down
3 changes: 0 additions & 3 deletions Source/Scene/GlobeSurfaceShaderSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ define([
vs.defines.push(quantizationDefine);
fs.defines.push('TEXTURE_UNITS ' + numberOfDayTextures);

if (frameState.logDepthBuffer) {
fs.defines.push('LOG_DEPTH_BUFFER');
}
if (applyBrightness) {
fs.defines.push('APPLY_BRIGHTNESS');
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/PointCloud3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ define([

vs += ' v_color = color; \n' +
' gl_Position = czm_modelViewProjection * vec4(position, 1.0); \n' +
' v_inverse_depth = 1. / gl_Position.w; \n';
' v_inverse_depth = 1.0 / gl_Position.w; \n';

if (hasNormals && backFaceCulling) {
vs += ' float visible = step(-normal.z, 0.0); \n' +
Expand Down
19 changes: 7 additions & 12 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ define([
*/
function Scene(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);

var canvas = options.canvas;
var contextOptions = options.contextOptions;
var creditContainer = options.creditContainer;
Expand All @@ -262,20 +261,16 @@ define([
creditContainer.style['padding-right'] = '5px';
canvas.parentNode.appendChild(creditContainer);
}
if (context.fragmentDepth) {
this.logDepthBuffer = true;
} else {
this.logDepthBuffer = false;
}
if (!defined(creditViewport)) {
creditViewport = canvas.parentNode;
}

this._logDepthBuffer = context.fragmentDepth;

this._id = createGuid();
this._jobScheduler = new JobScheduler();
this._frameState = new FrameState(context, new CreditDisplay(creditContainer, ' • ', creditViewport), this._jobScheduler);
this._frameState.scene3DOnly = defaultValue(options.scene3DOnly, false);
this._frameState.logDepthBuffer = this.logDepthBuffer;
this._removeCreditContainer = !hasCreditContainer;
this._creditContainer = creditContainer;

Expand Down Expand Up @@ -773,7 +768,7 @@ define([
var far = camera.frustum.far;
var numFrustums;
var farToNearRatio;
if (this.logDepthBuffer) {
if (this._logDepthBuffer) {
numFrustums = 1;
farToNearRatio = far / near;
} else {
Expand Down Expand Up @@ -1719,21 +1714,21 @@ define([
// Exploit temporal coherence. If the frustums haven't changed much, use the frustums computed
// last frame, else compute the new frustums and sort them by frustum again.
var is2D = scene.mode === SceneMode.SCENE2D;

var logDepth = scene._logDepthBuffer && !(camera.frustum instanceof OrthographicFrustum || camera.frustum instanceof OrthographicOffCenterFrustum);
var farToNearRatio = scene.farToNearRatio;
var numFrustums;

if (!is2D) {
// The multifrustum for 3D/CV is non-uniformly distributed.
if (scene.logDepthBuffer) {
if (logDepth) {
numFrustums = 1;
farToNearRatio = far / near;
} else {
numFrustums = Math.ceil(Math.log(far / near) / Math.log(scene.farToNearRatio));
}
} else {
// The multifrustum for 2D is uniformly distributed. To avoid z-fighting in 2D,
// the camera i smoved to just before the frustum and the frustum depth is scaled
// the camera is moved to just before the frustum and the frustum depth is scaled
// to be in [1.0, nearToFarDistance2D].
far = Math.min(far, camera.position.z + scene.nearToFarDistance2D);
near = Math.min(near, far);
Expand All @@ -1745,7 +1740,7 @@ define([
farChange = far / frustumCommandsList[numberOfFrustums - 1].far;
}
if ((near !== Number.MAX_VALUE && (numFrustums !== numberOfFrustums || (frustumCommandsList.length !== 0 &&
((scene.logDepthBuffer && isFinite(farChange) && !CesiumMath.equalsEpsilon(1, farChange, CesiumMath.EPSILON8)) ||
((logDepth && isFinite(farChange) && !CesiumMath.equalsEpsilon(1, farChange, CesiumMath.EPSILON8)) ||
(near < frustumCommandsList[0].near || (far > frustumCommandsList[numberOfFrustums - 1].far && !CesiumMath.equalsEpsilon(far, frustumCommandsList[numberOfFrustums - 1].far, CesiumMath.EPSILON8)))))))) {
updateFrustums(near, far, farToNearRatio, numFrustums, frustumCommandsList, is2D, scene.nearToFarDistance2D);
createPotentiallyVisibleSet(scene);
Expand Down
5 changes: 2 additions & 3 deletions Source/Scene/SceneTransforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ define([
var ndc = Cartesian4.clone(Cartesian4.UNIT_W, scratchNDC);
ndc.x = (drawingBufferPosition.x - viewport.x) / viewport.width * 2.0 - 1.0;
ndc.y = (drawingBufferPosition.y - viewport.y) / viewport.height * 2.0 - 1.0;
if (scene.logDepthBuffer) {
if (scene._logDepthBuffer) {
var frustumCommand = scene._frustumCommandsList[0];
var far = frustumCommand.far;
var near = frustumCommand.near;
Expand Down Expand Up @@ -343,8 +343,7 @@ define([
var w = 1.0 / worldCoords.w;
Cartesian3.multiplyByScalar(worldCoords, w, worldCoords);
}
result = Cartesian3.fromCartesian4(worldCoords, result);
return result;
return Cartesian3.fromCartesian4(worldCoords, result);
};

return SceneTransforms;
Expand Down

0 comments on commit 7c46e11

Please sign in to comment.