浏览代码

Fixing memory consumption for octrees

David Catuhe 11 年之前
父节点
当前提交
14de2efb96
共有 3 个文件被更改,包括 15 次插入15 次删除
  1. 6 6
      Babylon/Mesh/babylon.groundMesh.js
  2. 6 6
      Babylon/Mesh/babylon.groundMesh.ts
  3. 3 3
      babylon.1.12-beta.js

+ 6 - 6
Babylon/Mesh/babylon.groundMesh.js

@@ -21,14 +21,14 @@ var BABYLON;
             configurable: true
             configurable: true
         });
         });
 
 
-        GroundMesh.prototype._setReady = function (state) {
-            if (state) {
-                this.subdivide(this._subdivisions);
-
-                this.createOrUpdateSubmeshesOctree();
+        GroundMesh.prototype.optimize = function (subdivisions) {
+            if (this.getTotalVertices() < 2000) {
+                BABYLON.Tools.Warn("Optimizing GroundMesh requires at least 2000 vertices.");
             }
             }
 
 
-            _super.prototype._setReady.call(this, state);
+            this.subdivide(subdivisions || this._subdivisions);
+
+            this.createOrUpdateSubmeshesOctree();
         };
         };
 
 
         GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
         GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {

+ 6 - 6
Babylon/Mesh/babylon.groundMesh.ts

@@ -13,14 +13,14 @@
             return this._subdivisions;
             return this._subdivisions;
         }
         }
 
 
-        public _setReady(state: boolean): void {
-            if (state) {
-                this.subdivide(this._subdivisions);
-
-                this.createOrUpdateSubmeshesOctree();
+        public optimize(subdivisions?: number): void {
+            if (this.getTotalVertices() < 2000) {
+                Tools.Warn("Optimizing GroundMesh requires at least 2000 vertices.");
             }
             }
 
 
-            super._setReady(state);
+            this.subdivide(subdivisions || this._subdivisions);
+
+            this.createOrUpdateSubmeshesOctree();
         }
         }
 
 
         public getHeightAtCoordinates(x: number, z: number): number {
         public getHeightAtCoordinates(x: number, z: number): number {

文件差异内容过多而无法显示
+ 3 - 3
babylon.1.12-beta.js