Bladeren bron

Fixing memory consumption for octrees

David Catuhe 11 jaren geleden
bovenliggende
commit
14de2efb96
3 gewijzigde bestanden met toevoegingen van 15 en 15 verwijderingen
  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
         });
 
-        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) {

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

@@ -13,14 +13,14 @@
             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 {

File diff suppressed because it is too large
+ 3 - 3
babylon.1.12-beta.js