浏览代码

Introduced a way to cancel pivotMatrix and consider it only as, well, a pivot matrix :D

David Catuhe 7 年之前
父节点
当前提交
653d3c3e8d

文件差异内容过多而无法显示
+ 3065 - 3063
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 37 - 37
dist/preview release/babylon.js


+ 11 - 1
dist/preview release/babylon.max.js

@@ -12352,6 +12352,7 @@ var BABYLON;
             _this._collisionsScalingMatrix = BABYLON.Matrix.Zero();
             _this._isDirty = false;
             _this._pivotMatrix = BABYLON.Matrix.Identity();
+            _this._postMultiplyPivotMatrix = false;
             _this._isDisposed = false;
             _this._renderId = 0;
             _this._intersectionsInProgress = new Array();
@@ -13287,9 +13288,14 @@ var BABYLON;
          * Sets a new pivot matrix to the mesh.
          * Returns the AbstractMesh.
          */
-        AbstractMesh.prototype.setPivotMatrix = function (matrix) {
+        AbstractMesh.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
+            if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = false; }
             this._pivotMatrix = matrix;
             this._cache.pivotMatrixUpdated = true;
+            this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
+            if (this._postMultiplyPivotMatrix) {
+                this._pivotMatrixInverse = BABYLON.Matrix.Invert(matrix);
+            }
             return this;
         };
         /**
@@ -13525,6 +13531,10 @@ var BABYLON;
             else {
                 this._worldMatrix.copyFrom(this._localWorld);
             }
+            // Post multiply inverse of pivotMatrix
+            if (this._postMultiplyPivotMatrix) {
+                this._worldMatrix.multiplyToRef(this._pivotMatrixInverse, this._worldMatrix);
+            }
             // Bounding info
             this._updateBoundingInfo();
             // Absolute position

文件差异内容过多而无法显示
+ 3065 - 3063
dist/preview release/babylon.module.d.ts


文件差异内容过多而无法显示
+ 37 - 37
dist/preview release/babylon.worker.js


文件差异内容过多而无法显示
+ 6758 - 6756
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


文件差异内容过多而无法显示
+ 37 - 37
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 11 - 1
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -12352,6 +12352,7 @@ var BABYLON;
             _this._collisionsScalingMatrix = BABYLON.Matrix.Zero();
             _this._isDirty = false;
             _this._pivotMatrix = BABYLON.Matrix.Identity();
+            _this._postMultiplyPivotMatrix = false;
             _this._isDisposed = false;
             _this._renderId = 0;
             _this._intersectionsInProgress = new Array();
@@ -13287,9 +13288,14 @@ var BABYLON;
          * Sets a new pivot matrix to the mesh.
          * Returns the AbstractMesh.
          */
-        AbstractMesh.prototype.setPivotMatrix = function (matrix) {
+        AbstractMesh.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
+            if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = false; }
             this._pivotMatrix = matrix;
             this._cache.pivotMatrixUpdated = true;
+            this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
+            if (this._postMultiplyPivotMatrix) {
+                this._pivotMatrixInverse = BABYLON.Matrix.Invert(matrix);
+            }
             return this;
         };
         /**
@@ -13525,6 +13531,10 @@ var BABYLON;
             else {
                 this._worldMatrix.copyFrom(this._localWorld);
             }
+            // Post multiply inverse of pivotMatrix
+            if (this._postMultiplyPivotMatrix) {
+                this._worldMatrix.multiplyToRef(this._pivotMatrixInverse, this._worldMatrix);
+            }
             // Bounding info
             this._updateBoundingInfo();
             // Absolute position

文件差异内容过多而无法显示
+ 6758 - 6756
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


+ 13 - 1
src/Mesh/babylon.abstractMesh.ts

@@ -384,6 +384,8 @@
 
         public _boundingInfo: BoundingInfo;
         private _pivotMatrix = Matrix.Identity();
+        private _pivotMatrixInverse: Matrix;
+        private _postMultiplyPivotMatrix = false;
         public _isDisposed = false;
         public _renderId = 0;
 
@@ -1087,9 +1089,14 @@
          * Sets a new pivot matrix to the mesh.  
          * Returns the AbstractMesh.
          */
-        public setPivotMatrix(matrix: Matrix): AbstractMesh {
+        public setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix = false): AbstractMesh {
             this._pivotMatrix = matrix;
             this._cache.pivotMatrixUpdated = true;
+            this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
+
+            if (this._postMultiplyPivotMatrix) {
+                this._pivotMatrixInverse = Matrix.Invert(matrix);
+            }
             return this;
         }
 
@@ -1365,6 +1372,11 @@
                 this._worldMatrix.copyFrom(this._localWorld);
             }
 
+            // Post multiply inverse of pivotMatrix
+            if (this._postMultiplyPivotMatrix) {
+                this._worldMatrix.multiplyToRef(this._pivotMatrixInverse, this._worldMatrix);
+            }
+
             // Bounding info
             this._updateBoundingInfo();