From 7b985bfffae1ee95fbf376b3ee3f35d1bb435463 Mon Sep 17 00:00:00 2001 From: Janine Liu Date: Mon, 14 Mar 2022 17:17:42 -0400 Subject: [PATCH] Remove uniform scale matrix from scene graph --- .../Scene/ModelExperimental/ModelExperimentalNode.js | 7 +------ .../ModelExperimental/ModelExperimentalSceneGraph.js | 12 +++++++----- Source/Scene/ModelExperimental/buildDrawCommands.js | 9 ++------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Source/Scene/ModelExperimental/ModelExperimentalNode.js b/Source/Scene/ModelExperimental/ModelExperimentalNode.js index 4b9d8c634b..730c8a7076 100644 --- a/Source/Scene/ModelExperimental/ModelExperimentalNode.js +++ b/Source/Scene/ModelExperimental/ModelExperimentalNode.js @@ -255,14 +255,9 @@ ModelExperimentalNode.prototype.configurePipeline = function () { */ ModelExperimentalNode.prototype.updateModelMatrix = function () { this._transformDirty = true; - Matrix4.multiplyTransformation( + Matrix4.multiply( this._sceneGraph.computedModelMatrix, this._transform, this._computedTransform ); - Matrix4.multiplyByUniformScale( - this._computedTransform, - this._sceneGraph._scale, - this._computedTransform - ); }; diff --git a/Source/Scene/ModelExperimental/ModelExperimentalSceneGraph.js b/Source/Scene/ModelExperimental/ModelExperimentalSceneGraph.js index fb1d849d46..c457d2132a 100644 --- a/Source/Scene/ModelExperimental/ModelExperimentalSceneGraph.js +++ b/Source/Scene/ModelExperimental/ModelExperimentalSceneGraph.js @@ -119,9 +119,6 @@ export default function ModelExperimentalSceneGraph(options) { this._boundingSphere = undefined; this._computedModelMatrix = Matrix4.clone(this._model.modelMatrix); - this._uniformScaleMatrix = Matrix4.fromUniformScale( - this._model._modifiedScale - ); initialize(this); } @@ -186,6 +183,12 @@ function initialize(sceneGraph) { components.forwardAxis ); + Matrix4.multiplyByUniformScale( + sceneGraph._computedModelMatrix, + model._modifiedScale, + sceneGraph._computedModelMatrix + ); + const rootNodes = scene.nodes; for (let i = 0; i < rootNodes.length; i++) { const rootNode = scene.nodes[i]; @@ -397,8 +400,7 @@ ModelExperimentalSceneGraph.prototype.update = function (frameState) { ModelExperimentalSceneGraph.prototype.updateModelMatrix = function () { const model = this._model; const scale = model._modifiedScale; - this._scale = scale; - this._computedModelMatrix = Matrix4.clone(model.modelMatrix); + Matrix4.clone(model.modelMatrix, this._computedModelMatrix); Matrix4.multiply( this._computedModelMatrix, diff --git a/Source/Scene/ModelExperimental/buildDrawCommands.js b/Source/Scene/ModelExperimental/buildDrawCommands.js index 930abf5a06..d7981be73b 100644 --- a/Source/Scene/ModelExperimental/buildDrawCommands.js +++ b/Source/Scene/ModelExperimental/buildDrawCommands.js @@ -62,16 +62,11 @@ export default function buildDrawCommands( const pass = primitiveRenderResources.alphaOptions.pass; const sceneGraph = model.sceneGraph; - const scaledTransform = Matrix4.multiply( - sceneGraph._uniformScaleMatrix, - primitiveRenderResources.transform, - new Matrix4() - ); const modelMatrix = Matrix4.multiply( sceneGraph.computedModelMatrix, - scaledTransform, - scaledTransform + primitiveRenderResources.transform, + new Matrix4() ); BoundingSphere.transform(