فهرست منبع

update what's new + change Material dispose signature

Julien Barrois 6 سال پیش
والد
کامیت
92bdfd66b2

+ 7 - 1
dist/preview release/what's new.md

@@ -18,7 +18,13 @@
 - `PBRMaterial` and `StandardMaterial` now use hot swapping feature for shaders. This means they can keep using a previous shader while a new one is being compiled ([Deltakosh](https://github.com/deltakosh))
 - Performance oriented changes ([barroij](https://github.com/barroij))
   - prevent avoidable matrix inversion or square root computation.
-  - enable a removal in O(1) from the `transformNodes`array of the Scene.
+  - enable a removal in O(1) from the `transformNodes` array and `materials` array of the `Scene`. As a consequence, the order of the element within these arrays might change during a removal.
+  - enable a removal in O(1) from the `instances` array of a `Mesh`. As a consequence, the order of the element within this array might change during a removal.
+  - Stop calling splice on the `scene.meshes` array and on the `engine._uniformBuffer` when removing an element. As a consequence, the order of the element within these array might change during a removal.
+  - Added an option `useMaterialMeshMap` in the `Scene` constructor options. When set to true, each `Material` isntance will have and will keep up-to-date a map of its bound meshes. This is to avoid browsing all the meshes of the scene to retrieve the ones bound to the current material when disposing the Material. Disabled by default.
+  - Added an option `useClonedMeshhMap` in the `Scene` constructor options. When set to true, each `Mesh` will have and will keep up-to-date a map of cloned meshes. This is to avoid browsing all the meshes of the scene to retrieve the ones that have the current mesh as source mesh. Disabled by default.
+  - Added `blockfreeActiveMeshesAndRenderingGroups` property in the `Scene`, following the same model as `blockMaterialDirtyMechanism`. This is to avoid calling `Scene.freeActiveMeshes` and `Scene.freeRenderingGroups` for each disposed mesh when we dispose several meshes in a row. One have to set `blockfreeActiveMeshesAndRenderingGroups` to `true` just before disposing the meshes, and set it back to `false` just after.
+  - Prevent from doing useless and possible time consuming computation when disposing the `ShaderMaterial` of a `LinesMesh`.
 
 ### glTF Loader
 

+ 2 - 5
src/Materials/babylon.material.ts

@@ -769,9 +769,6 @@ module BABYLON {
         public _indexInSceneMaterialArray = -1;
 
         /** @hidden */
-        public disposingLineMeshColorShader: boolean = false;
-
-        /** @hidden */
         public meshMap: Nullable<{[id: string]: AbstractMesh | undefined}>;
 
         /**
@@ -1275,7 +1272,7 @@ module BABYLON {
          * @param forceDisposeEffect specifies if effects should be forcefully disposed
          * @param forceDisposeTextures specifies if textures should be forcefully disposed
          */
-        public dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void {
+        public dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, isLineMeshColorShader?: boolean): void {
             const scene = this.getScene();
             // Animations
             scene.stopAnimation(this);
@@ -1284,7 +1281,7 @@ module BABYLON {
             // Remove from scene
             scene.removeMaterial(this);
 
-            if (!this.disposingLineMeshColorShader) {
+            if (isLineMeshColorShader !== true) {
                 // Remove from meshes
                 if (this.meshMap) {
                     for (let meshId in this.meshMap) {

+ 2 - 2
src/Materials/babylon.shaderMaterial.ts

@@ -657,7 +657,7 @@ module BABYLON {
          * @param forceDisposeEffect specifies if effects should be forcefully disposed
          * @param forceDisposeTextures specifies if textures should be forcefully disposed
          */
-        public dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void {
+        public dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, isLineMeshColorShader?: boolean): void {
 
             if (forceDisposeTextures) {
                 var name: string;
@@ -675,7 +675,7 @@ module BABYLON {
 
             this._textures = {};
 
-            super.dispose(forceDisposeEffect, forceDisposeTextures);
+            super.dispose(forceDisposeEffect, forceDisposeTextures, isLineMeshColorShader);
         }
 
         /**

+ 1 - 3
src/Mesh/babylon.linesMesh.ts

@@ -163,9 +163,7 @@ module BABYLON {
          * @param doNotRecurse If children should be disposed
          */
         public dispose(doNotRecurse?: boolean): void {
-            this._colorShader.disposingLineMeshColorShader = true;
-            this._colorShader.dispose();
-            this._colorShader.disposingLineMeshColorShader = false;
+            this._colorShader.dispose(false, false, true);
             super.dispose(doNotRecurse);
         }