소스 검색

Added performat matrix.isIdentity() function

David Catuhe 8 년 전
부모
커밋
4f1df92b84
6개의 변경된 파일10040개의 추가작업 그리고 10017개의 파일을 삭제
  1. 4961 4959
      dist/preview release/babylon.d.ts
  2. 40 40
      dist/preview release/babylon.js
  3. 19 8
      dist/preview release/babylon.max.js
  4. 4961 4959
      dist/preview release/babylon.module.d.ts
  5. 41 41
      dist/preview release/babylon.worker.js
  6. 18 10
      src/Math/babylon.math.ts

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 4961 - 4959
dist/preview release/babylon.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 40 - 40
dist/preview release/babylon.js


+ 19 - 8
dist/preview release/babylon.max.js

@@ -2730,25 +2730,36 @@ var __extends = (this && this.__extends) || (function () {
     BABYLON.Quaternion = Quaternion;
     var Matrix = (function () {
         function Matrix() {
+            this._isIdentity = false;
+            this._isIdentityDirty = true;
             this.m = new Float32Array(16);
             this._markAsUpdated();
         }
         Matrix.prototype._markAsUpdated = function () {
             this.updateFlag = Matrix._updateFlagSeed++;
+            this._isIdentityDirty = true;
         };
         // Properties
         /**
          * Boolean : True is the matrix is the identity matrix
          */
         Matrix.prototype.isIdentity = function () {
-            if (this.m[0] !== 1.0 || this.m[5] !== 1.0 || this.m[10] !== 1.0 || this.m[15] !== 1.0)
-                return false;
-            if (this.m[1] !== 0.0 || this.m[2] !== 0.0 || this.m[3] !== 0.0 ||
-                this.m[4] !== 0.0 || this.m[6] !== 0.0 || this.m[7] !== 0.0 ||
-                this.m[8] !== 0.0 || this.m[9] !== 0.0 || this.m[11] !== 0.0 ||
-                this.m[12] !== 0.0 || this.m[13] !== 0.0 || this.m[14] !== 0.0)
-                return false;
-            return true;
+            if (this._isIdentityDirty) {
+                this._isIdentityDirty = false;
+                if (this.m[0] !== 1.0 || this.m[5] !== 1.0 || this.m[10] !== 1.0 || this.m[15] !== 1.0) {
+                    this._isIdentity = false;
+                }
+                else if (this.m[1] !== 0.0 || this.m[2] !== 0.0 || this.m[3] !== 0.0 ||
+                    this.m[4] !== 0.0 || this.m[6] !== 0.0 || this.m[7] !== 0.0 ||
+                    this.m[8] !== 0.0 || this.m[9] !== 0.0 || this.m[11] !== 0.0 ||
+                    this.m[12] !== 0.0 || this.m[13] !== 0.0 || this.m[14] !== 0.0) {
+                    this._isIdentity = false;
+                }
+                else {
+                    this._isIdentity = true;
+                }
+            }
+            return this._isIdentity;
         };
         /**
          * Returns the matrix determinant (float).

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 4961 - 4959
dist/preview release/babylon.module.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 41 - 41
dist/preview release/babylon.worker.js


+ 18 - 10
src/Math/babylon.math.ts

@@ -2923,11 +2923,14 @@
         private static _zAxis: Vector3 = Vector3.Zero();
         private static _updateFlagSeed = 0;
 
-        public updateFlag: number;
+        private _isIdentity = false;
+        private _isIdentityDirty = true;
+        public updateFlag: number;        
         public m: Float32Array = new Float32Array(16);
 
         public _markAsUpdated() {
             this.updateFlag = Matrix._updateFlagSeed++;
+            this._isIdentityDirty = true;
         }
 
         public constructor() {
@@ -2939,16 +2942,21 @@
          * Boolean : True is the matrix is the identity matrix
          */
         public isIdentity(): boolean {
-            if (this.m[0] !== 1.0 || this.m[5] !== 1.0 || this.m[10] !== 1.0 || this.m[15] !== 1.0)
-                return false;
-
-            if (this.m[1] !== 0.0 || this.m[2] !== 0.0 || this.m[3] !== 0.0 ||
-                this.m[4] !== 0.0 || this.m[6] !== 0.0 || this.m[7] !== 0.0 ||
-                this.m[8] !== 0.0 || this.m[9] !== 0.0 || this.m[11] !== 0.0 ||
-                this.m[12] !== 0.0 || this.m[13] !== 0.0 || this.m[14] !== 0.0)
-                return false;
+            if (this._isIdentityDirty) {
+                this._isIdentityDirty = false;
+                if (this.m[0] !== 1.0 || this.m[5] !== 1.0 || this.m[10] !== 1.0 || this.m[15] !== 1.0) {
+                    this._isIdentity = false;
+                } else if (this.m[1] !== 0.0 || this.m[2] !== 0.0 || this.m[3] !== 0.0 ||
+                    this.m[4] !== 0.0 || this.m[6] !== 0.0 || this.m[7] !== 0.0 ||
+                    this.m[8] !== 0.0 || this.m[9] !== 0.0 || this.m[11] !== 0.0 ||
+                    this.m[12] !== 0.0 || this.m[13] !== 0.0 || this.m[14] !== 0.0) {
+                    this._isIdentity = false;
+                } else {
+                    this._isIdentity = true;
+                }
+            }
 
-            return true;
+            return this._isIdentity;
         }
         /**
          * Returns the matrix determinant (float).