Skip to content

Commit

Permalink
refs #7398 moved getRotation method to Matrix3,
Browse files Browse the repository at this point in the history
removed geometricError recalculation on each "get"
  • Loading branch information
geoscan-builder committed Dec 10, 2018
1 parent 4a8c92d commit ca38e70
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 27 deletions.
21 changes: 21 additions & 0 deletions Source/Core/Matrix3.js
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,27 @@ define([
return result;
};

var UNIT = new Cartesian3(1, 1, 1);
var scaleVector = new Cartesian3();

/**
* Factors rotation matrix from arbitrary Matrix3 by dividing components by scale
*
* @param {Matrix3} rotation-scale matrix
* @param {Matrix3} result rotation matrix with unit scale
* @returns {Matrix3} The modified result parameter.
*/
Matrix3.getRotation = function(matrix, result) {
Matrix3.multiplyByScale(
matrix,
Cartesian3.divideComponents(
UNIT, Matrix3.getScale(matrix, scaleVector), scaleVector
),
result
);
return result;
};

function computeFrobeniusNorm(matrix) {
var norm = 0.0;
for (var i = 0; i < 9; ++i) {
Expand Down
11 changes: 0 additions & 11 deletions Source/Core/Matrix4.js
Original file line number Diff line number Diff line change
Expand Up @@ -2149,10 +2149,6 @@ define([
return result;
};


var UNIT = new Cartesian3(1, 1, 1);
var scratchScale = new Cartesian3();

/**
* Gets the upper left 3x3 rotation matrix of the provided matrix, assuming the matrix is a affine transformation matrix.
*
Expand Down Expand Up @@ -2190,13 +2186,6 @@ define([
result[6] = matrix[8];
result[7] = matrix[9];
result[8] = matrix[10];
Matrix3.multiplyByScale(
result,
Cartesian3.divideComponents(
UNIT, Matrix3.getScale(result, scratchScale), scratchScale
),
result
)
return result;
};

Expand Down
3 changes: 1 addition & 2 deletions Source/Renderer/UniformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,7 @@ define([

var m = uniformState._normal;
Matrix4.getRotation(uniformState.inverseModelView, m);
Matrix3.getRotation(m, m);
Matrix3.transpose(m, m);
}
}
Expand All @@ -1254,15 +1255,13 @@ define([
function cleanInverseNormal(uniformState) {
if (uniformState._inverseNormalDirty) {
uniformState._inverseNormalDirty = false;

Matrix4.getRotation(uniformState.inverseModelView, uniformState._inverseNormal);
}
}

function cleanInverseNormal3D(uniformState) {
if (uniformState._inverseNormal3DDirty) {
uniformState._inverseNormal3DDirty = false;

Matrix4.getRotation(uniformState.inverseModelView3D, uniformState._inverseNormal3D);
}
}
Expand Down
20 changes: 11 additions & 9 deletions Source/Scene/Cesium3DTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ define([
Cesium3DTile._deprecationWarning('geometricErrorUndefined', 'Required property geometricError is undefined for this tile. Using parent\'s geometric error instead.');
}

this.updateGeometricErrorScale();

var refine;
if (defined(header.refine)) {
if (header.refine === 'replace' || header.refine === 'add') {
Expand Down Expand Up @@ -349,8 +351,6 @@ define([
// This can be overridden for testing purposes
Cesium3DTile._deprecationWarning = deprecationWarning;

var scratchScale = new Cartesian3();

defineProperties(Cesium3DTile.prototype, {
/**
* The tileset containing this tile.
Expand Down Expand Up @@ -604,13 +604,7 @@ define([
get : function() {
return this._commandsLength;
}
},

geometricError : {
get : function() {
return Cartesian3.maximumComponent(Matrix4.getScale(this.computedTransform, scratchScale)) * this._geometricError;
}
}
}
});

var scratchJulianDate = new JulianDate();
Expand Down Expand Up @@ -1056,12 +1050,20 @@ define([
this._viewerRequestVolume = this.createBoundingVolume(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
}

this.updateGeometricErrorScale();

// Destroy the debug bounding volumes. They will be generated fresh.
this._debugBoundingVolume = this._debugBoundingVolume && this._debugBoundingVolume.destroy();
this._debugContentBoundingVolume = this._debugContentBoundingVolume && this._debugContentBoundingVolume.destroy();
this._debugViewerRequestVolume = this._debugViewerRequestVolume && this._debugViewerRequestVolume.destroy();
};

Cesium3DTile.prototype.updateGeometricErrorScale = function() {
var scale = Matrix4.getScale(this.computedTransform, scratchScale);
var uniformScale = Cartesian3.maximumComponent(scale);
this.geometricError = this._geometricError * uniformScale;
};

function applyDebugSettings(tile, tileset, frameState) {
var hasContentBoundingVolume = defined(tile._header.content) && defined(tile._header.content.boundingVolume);
var empty = tile.hasEmptyContent || tile.hasTilesetContent;
Expand Down
8 changes: 3 additions & 5 deletions Source/Scene/PointCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ define([
Check.typeOf.object('options.arrayBuffer', options.arrayBuffer);
//>>includeEnd('debug');

var that = this;

// Hold onto the payload until the render resources are created
this._parsedContent = undefined;

Expand Down Expand Up @@ -151,12 +149,12 @@ define([

// Use per-point normals to hide back-facing points.
this.backFaceCulling = false;
bindProperty(this, "backFaceCulling", options.backFaceCulling);
bindProperty(this, 'backFaceCulling', options.backFaceCulling);
this._backFaceCulling = this.backFaceCulling;

// Whether to enable normal shading
this.normalShading = true;
bindProperty(this, "normalShading", options.normalShading);
bindProperty(this, 'normalShading', options.normalShading);
this._normalShading = this.normalShading;

this._opaqueRenderState = undefined;
Expand Down Expand Up @@ -1179,7 +1177,7 @@ define([
vs += ' v_color = color; \n' +
' gl_Position = czm_modelViewProjection * vec4(position, 1.0); \n';

if (usesNormals && true) {
if (usesNormals && backFaceCulling) {
vs += ' float visible = step(-normal.z, 0.0); \n' +
' gl_Position *= visible; \n' +
' gl_PointSize *= visible; \n';
Expand Down

0 comments on commit ca38e70

Please sign in to comment.