Explorar el Código

fixy issue with getHierarchyBoundingVectors

David Catuhe hace 8 años
padre
commit
d81aba0d67

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1429 - 1429
dist/preview release/babylon.d.ts


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 5 - 5
dist/preview release/babylon.js


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

@@ -13283,16 +13283,28 @@ var BABYLON;
          * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
          * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
          */
          */
         AbstractMesh.prototype.getHierarchyBoundingVectors = function () {
         AbstractMesh.prototype.getHierarchyBoundingVectors = function () {
-            this.computeWorldMatrix();
-            var min = this.getBoundingInfo().boundingBox.minimumWorld;
-            var max = this.getBoundingInfo().boundingBox.maximumWorld;
-            var descendants = this.getDescendants(false, function (node) { return node.subMeshes; });
+            this.computeWorldMatrix(true);
+            var min;
+            var max;
+            if (!this.subMeshes) {
+                min = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+                max = new BABYLON.Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
+            }
+            else {
+                min = this.getBoundingInfo().boundingBox.minimumWorld;
+                max = this.getBoundingInfo().boundingBox.maximumWorld;
+            }
+            var descendants = this.getDescendants(false);
             for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
             for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
                 var descendant = descendants_1[_i];
                 var descendant = descendants_1[_i];
                 var childMesh = descendant;
                 var childMesh = descendant;
-                childMesh.computeWorldMatrix();
-                var minBox = childMesh.getBoundingInfo().boundingBox.minimumWorld;
-                var maxBox = childMesh.getBoundingInfo().boundingBox.maximumWorld;
+                childMesh.computeWorldMatrix(true);
+                if (childMesh.getTotalVertices() === 0) {
+                    continue;
+                }
+                var boundingBox = childMesh.getBoundingInfo().boundingBox;
+                var minBox = boundingBox.minimumWorld;
+                var maxBox = boundingBox.maximumWorld;
                 BABYLON.Tools.CheckExtends(minBox, min, max);
                 BABYLON.Tools.CheckExtends(minBox, min, max);
                 BABYLON.Tools.CheckExtends(maxBox, min, max);
                 BABYLON.Tools.CheckExtends(maxBox, min, max);
             }
             }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1429 - 1429
dist/preview release/babylon.module.d.ts


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 5 - 5
dist/preview release/babylon.worker.js


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 4096 - 4096
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 5 - 5
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 19 - 7
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -13283,16 +13283,28 @@ var BABYLON;
          * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
          * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
          */
          */
         AbstractMesh.prototype.getHierarchyBoundingVectors = function () {
         AbstractMesh.prototype.getHierarchyBoundingVectors = function () {
-            this.computeWorldMatrix();
-            var min = this.getBoundingInfo().boundingBox.minimumWorld;
-            var max = this.getBoundingInfo().boundingBox.maximumWorld;
-            var descendants = this.getDescendants(false, function (node) { return node.subMeshes; });
+            this.computeWorldMatrix(true);
+            var min;
+            var max;
+            if (!this.subMeshes) {
+                min = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+                max = new BABYLON.Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
+            }
+            else {
+                min = this.getBoundingInfo().boundingBox.minimumWorld;
+                max = this.getBoundingInfo().boundingBox.maximumWorld;
+            }
+            var descendants = this.getDescendants(false);
             for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
             for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
                 var descendant = descendants_1[_i];
                 var descendant = descendants_1[_i];
                 var childMesh = descendant;
                 var childMesh = descendant;
-                childMesh.computeWorldMatrix();
-                var minBox = childMesh.getBoundingInfo().boundingBox.minimumWorld;
-                var maxBox = childMesh.getBoundingInfo().boundingBox.maximumWorld;
+                childMesh.computeWorldMatrix(true);
+                if (childMesh.getTotalVertices() === 0) {
+                    continue;
+                }
+                var boundingBox = childMesh.getBoundingInfo().boundingBox;
+                var minBox = boundingBox.minimumWorld;
+                var maxBox = boundingBox.maximumWorld;
                 BABYLON.Tools.CheckExtends(minBox, min, max);
                 BABYLON.Tools.CheckExtends(minBox, min, max);
                 BABYLON.Tools.CheckExtends(maxBox, min, max);
                 BABYLON.Tools.CheckExtends(maxBox, min, max);
             }
             }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 4096 - 4096
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


+ 22 - 7
src/Mesh/babylon.abstractMesh.ts

@@ -1159,18 +1159,33 @@
          * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
          * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
          */
          */
         public getHierarchyBoundingVectors(): { min: Vector3, max: Vector3 }{
         public getHierarchyBoundingVectors(): { min: Vector3, max: Vector3 }{
-            this.computeWorldMatrix();
-            let min = this.getBoundingInfo().boundingBox.minimumWorld;
-            let max = this.getBoundingInfo().boundingBox.maximumWorld;
+            this.computeWorldMatrix(true);
 
 
-            let descendants = this.getDescendants(false, (node) => (<any>node).subMeshes);
+            let min: Vector3;
+            let max: Vector3;
+            
+            if (!this.subMeshes) {
+                min = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+                max = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
+            } else {
+                min = this.getBoundingInfo().boundingBox.minimumWorld;
+                max = this.getBoundingInfo().boundingBox.maximumWorld;
+            }
+
+            let descendants = this.getDescendants(false);
 
 
             for (var descendant of descendants) {
             for (var descendant of descendants) {
                 let childMesh = <AbstractMesh>descendant;
                 let childMesh = <AbstractMesh>descendant;
 
 
-                childMesh.computeWorldMatrix();
-                var minBox = childMesh.getBoundingInfo().boundingBox.minimumWorld;
-                var maxBox = childMesh.getBoundingInfo().boundingBox.maximumWorld;
+                childMesh.computeWorldMatrix(true);
+
+                if (childMesh.getTotalVertices() === 0) {
+                    continue;
+                }
+                let boundingBox = childMesh.getBoundingInfo().boundingBox;
+
+                var minBox = boundingBox.minimumWorld;
+                var maxBox = boundingBox.maximumWorld;
 
 
                 Tools.CheckExtends(minBox, min, max);
                 Tools.CheckExtends(minBox, min, max);
                 Tools.CheckExtends(maxBox, min, max);
                 Tools.CheckExtends(maxBox, min, max);