فهرست منبع

Merge pull request #1082 from nockawa/master

Fix a bug where the boundingInfo of a Geometry and its related Mesh…
Raanan Weber 9 سال پیش
والد
کامیت
0af5e12ea6
2فایلهای تغییر یافته به همراه1072 افزوده شده و 1063 حذف شده
  1. 1050 1046
      src/Mesh/babylon.geometry.js
  2. 22 17
      src/Mesh/babylon.geometry.ts

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1050 - 1046
src/Mesh/babylon.geometry.js


+ 22 - 17
src/Mesh/babylon.geometry.ts

@@ -36,7 +36,8 @@
             }
 
             this._boundingBias = value.clone();
-            this.updateExtend();
+
+            this.updateBoundingInfo(true, null);
         }
 
         constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Mesh) {
@@ -143,28 +144,32 @@
                 var stride = vertexBuffer.getStrideSize();
                 this._totalVertices = data.length / stride;
 
-                if (updateExtends) {
-                    this.updateExtend(data);
-                }
+                this.updateBoundingInfo(updateExtends, data);
+            }
+            this.notifyUpdate(kind);
+        }
 
-                var meshes = this._meshes;
-                var numOfMeshes = meshes.length;
+        private updateBoundingInfo(updateExtends: boolean, data: number[] | Float32Array) {
+            if (updateExtends) {
+                this.updateExtend(data);
+            }
 
-                for (var index = 0; index < numOfMeshes; index++) {
-                    var mesh = meshes[index];
-                    mesh._resetPointsArrayCache();
-                    if (updateExtends) {
-                        mesh._boundingInfo = new BoundingInfo(this._extend.minimum, this._extend.maximum);
+            var meshes = this._meshes;
+            var numOfMeshes = meshes.length;
 
-                        for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
-                            var subMesh = mesh.subMeshes[subIndex];
+            for (var index = 0; index < numOfMeshes; index++) {
+                var mesh = meshes[index];
+                mesh._resetPointsArrayCache();
+                if (updateExtends) {
+                    mesh._boundingInfo = new BoundingInfo(this._extend.minimum, this._extend.maximum);
 
-                            subMesh.refreshBoundingInfo();
-                        }
+                    for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
+                        var subMesh = mesh.subMeshes[subIndex];
+
+                        subMesh.refreshBoundingInfo();
                     }
                 }
-            }
-            this.notifyUpdate(kind);
+            }            
         }
 
         public getTotalVertices(): number {