浏览代码

Merge remote-tracking branch 'upstream/master' into fix.CreateXXX.optionable

jbousquie 10 年之前
父节点
当前提交
862cb56938

+ 4 - 0
Tools/ActionsBuilder/Sources/actionsbuilder.list.js

@@ -78,6 +78,9 @@ var ActionsBuilder;
                 if (this._viewer.root.type === ActionsBuilder.Type.OBJECT && excludedTriggers.indexOf(i) !== -1) {
                     continue;
                 }
+                else if (this._viewer.root.type === ActionsBuilder.Type.SCENE && excludedTriggers.indexOf(i) === -1) {
+                    continue;
+                }
                 var trigger = this._createListElement(this.triggersList, yPosition, element.text, ActionsBuilder.Type.TRIGGER, textColor, true, element);
                 trigger.rect.attr("fill", Raphael.rgb(133, 154, 185));
                 yPosition += List.ELEMENT_HEIGHT;
@@ -249,3 +252,4 @@ var ActionsBuilder;
     })();
     ActionsBuilder.List = List;
 })(ActionsBuilder || (ActionsBuilder = {}));
+//# sourceMappingURL=actionsbuilder.list.js.map

+ 3 - 0
Tools/ActionsBuilder/Sources/actionsbuilder.max.js

@@ -282,6 +282,9 @@ var ActionsBuilder;
                 if (this._viewer.root.type === ActionsBuilder.Type.OBJECT && excludedTriggers.indexOf(i) !== -1) {
                     continue;
                 }
+                else if (this._viewer.root.type === ActionsBuilder.Type.SCENE && excludedTriggers.indexOf(i) === -1) {
+                    continue;
+                }
                 var trigger = this._createListElement(this.triggersList, yPosition, element.text, ActionsBuilder.Type.TRIGGER, textColor, true, element);
                 trigger.rect.attr("fill", Raphael.rgb(133, 154, 185));
                 yPosition += List.ELEMENT_HEIGHT;

+ 4 - 0
Tools/ActionsBuilder/actionsbuilder.list.ts

@@ -94,6 +94,10 @@
                 if (this._viewer.root.type === Type.OBJECT && excludedTriggers.indexOf(i) !== -1) {
                     continue;
                 }
+                else if (this._viewer.root.type === Type.SCENE && excludedTriggers.indexOf(i) === -1) {
+                    continue;
+                }
+
                 var trigger = this._createListElement(this.triggersList, yPosition, element.text, Type.TRIGGER, textColor, true, element);
 
                 trigger.rect.attr("fill", Raphael.rgb(133, 154, 185));

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

@@ -10,6 +10,8 @@
     - Fixed bug with `Mesh.attachToBone` when bone's matrix has a negative determinant ([deltakosh](https://github.com/deltakosh))
     - Fixed a possible but with the active camera while taking a screenshot [PR](https://github.com/BabylonJS/Babylon.js/pull/701) ([RaananW](https://github.com/RaananW))
     - Fixed a bug with worker-collisions and instances [PR](https://github.com/BabylonJS/Babylon.js/pull/705) ([RaananW](https://github.com/RaananW))
+    - Fixed a bug with removed meshes and geometries from the worker-cache [PR](https://github.com/BabylonJS/Babylon.js/pull/711) ([RaananW](https://github.com/RaananW))
   - **Breaking changes**
-    - `Mesh.CreateCylinder()` old signature (without _subdivisions_ parameter) deprecated ([jerome](https://github.com/jbousquie))
+    - `VertexData.CreateCylinder()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
+    - `VertexData.CreateRibbon()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
 

+ 28 - 10
src/Collisions/babylon.collisionWorker.js

@@ -19,12 +19,18 @@ var BABYLON;
         CollisionCache.prototype.addMesh = function (mesh) {
             this._meshes[mesh.uniqueId] = mesh;
         };
+        CollisionCache.prototype.removeMesh = function (uniqueId) {
+            delete this._meshes[uniqueId];
+        };
         CollisionCache.prototype.getGeometry = function (id) {
             return this._geometries[id];
         };
         CollisionCache.prototype.addGeometry = function (geometry) {
             this._geometries[geometry.id] = geometry;
         };
+        CollisionCache.prototype.removeGeometry = function (id) {
+            delete this._geometries[id];
+        };
         return CollisionCache;
     })();
     BABYLON.CollisionCache = CollisionCache;
@@ -156,20 +162,32 @@ var BABYLON;
             postMessage(reply, undefined);
         };
         CollisionDetectorTransferable.prototype.onUpdate = function (payload) {
-            for (var id in payload.updatedGeometries) {
-                if (payload.updatedGeometries.hasOwnProperty(id)) {
-                    this._collisionCache.addGeometry(payload.updatedGeometries[id]);
-                }
-            }
-            for (var uniqueId in payload.updatedMeshes) {
-                if (payload.updatedMeshes.hasOwnProperty(uniqueId)) {
-                    this._collisionCache.addMesh(payload.updatedMeshes[uniqueId]);
-                }
-            }
+            var _this = this;
             var replay = {
                 error: BABYLON.WorkerReplyType.SUCCESS,
                 taskType: BABYLON.WorkerTaskType.UPDATE
             };
+            try {
+                for (var id in payload.updatedGeometries) {
+                    if (payload.updatedGeometries.hasOwnProperty(id)) {
+                        this._collisionCache.addGeometry(payload.updatedGeometries[id]);
+                    }
+                }
+                for (var uniqueId in payload.updatedMeshes) {
+                    if (payload.updatedMeshes.hasOwnProperty(uniqueId)) {
+                        this._collisionCache.addMesh(payload.updatedMeshes[uniqueId]);
+                    }
+                }
+                payload.removedGeometries.forEach(function (id) {
+                    _this._collisionCache.removeGeometry(id);
+                });
+                payload.removedMeshes.forEach(function (uniqueId) {
+                    _this._collisionCache.removeMesh(uniqueId);
+                });
+            }
+            catch (x) {
+                replay.error = BABYLON.WorkerReplyType.UNKNOWN_ERROR;
+            }
             postMessage(replay, undefined);
         };
         CollisionDetectorTransferable.prototype.onCollision = function (payload) {

+ 35 - 12
src/Collisions/babylon.collisionWorker.ts

@@ -22,6 +22,10 @@ module BABYLON {
         public addMesh(mesh: SerializedMesh) {
             this._meshes[mesh.uniqueId] = mesh;
         }
+		
+		public removeMesh(uniqueId: number) {
+            delete this._meshes[uniqueId];
+        }
 
         public getGeometry(id: string): SerializedGeometry {
             return this._geometries[id];
@@ -30,6 +34,10 @@ module BABYLON {
         public addGeometry(geometry: SerializedGeometry) {
             this._geometries[geometry.id] = geometry;
         }
+		
+		public removeGeometry(id: string) {
+            delete this._geometries[id];
+        }
     }
 
     export class CollideWorker {
@@ -192,21 +200,36 @@ module BABYLON {
         }
 
         public onUpdate(payload: UpdatePayload) {
-            for (var id in payload.updatedGeometries) {
-                if (payload.updatedGeometries.hasOwnProperty(id)) {
-                    this._collisionCache.addGeometry(payload.updatedGeometries[id]);
-                }
-            }
-            for (var uniqueId in payload.updatedMeshes) {
-                if (payload.updatedMeshes.hasOwnProperty(uniqueId)) {
-                    this._collisionCache.addMesh(payload.updatedMeshes[uniqueId]);
-                }
-            }
-
-            var replay: WorkerReply = {
+			var replay: WorkerReply = {
                 error: WorkerReplyType.SUCCESS,
                 taskType: WorkerTaskType.UPDATE
             }
+			
+			try {
+				for (var id in payload.updatedGeometries) {
+					if (payload.updatedGeometries.hasOwnProperty(id)) {
+						this._collisionCache.addGeometry(payload.updatedGeometries[id]);
+					}
+				}
+				for (var uniqueId in payload.updatedMeshes) {
+					if (payload.updatedMeshes.hasOwnProperty(uniqueId)) {
+						this._collisionCache.addMesh(payload.updatedMeshes[uniqueId]);
+					}
+				}
+				
+				payload.removedGeometries.forEach((id) => {
+					this._collisionCache.removeGeometry(id);
+				});
+				
+				payload.removedMeshes.forEach((uniqueId) => {
+					this._collisionCache.removeMesh(uniqueId);
+				});
+				
+			} catch(x) {
+				replay.error = WorkerReplyType.UNKNOWN_ERROR;
+			}
+
+            
             postMessage(replay, undefined);
         }