Skip to content

Commit

Permalink
Collision workers fix
Browse files Browse the repository at this point in the history
Fixing BabylonJS#3819
Worker collisions are not enabled in the playground , it will only be enabled if the worker is available from now on.
  • Loading branch information
RaananW committed Feb 26, 2018
1 parent 325b361 commit 6a70f78
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions dist/preview release/what's new.md
Expand Up @@ -94,6 +94,7 @@
- (Viewer) Fixed a bug where loading another mesh positioned it incorrectly ([RaananW](https://github.com/RaananW))
- (Viewer) Disabling templates now work correctly ([RaananW](https://github.com/RaananW))
- AMD "define" declaration is no longer anonymous ([RaananW](https://github.com/RaananW))
- Collision worker didn't initialize instanced meshes correctly - [#3819](https://github.com/BabylonJS/Babylon.js/issues/3819) ([RaananW](https://github.com/RaananW))

## Breaking changes

Expand Down
6 changes: 3 additions & 3 deletions src/Collisions/babylon.collisionCoordinator.ts
Expand Up @@ -58,11 +58,11 @@ module BABYLON {
positions: Float32Array;
/**
* Defines the array containing the indices
*/
*/
indices: Uint32Array;
/**
* Defines the array containing the normals
*/
*/
normals: Float32Array;
}

Expand Down Expand Up @@ -173,7 +173,7 @@ module BABYLON {
let geometry = (<Mesh>mesh).geometry;
geometryId = geometry ? geometry.id : null;
} else if (mesh instanceof InstancedMesh) {
let geometry = (<InstancedMesh>mesh).sourceMesh.geometry;
let geometry = (<InstancedMesh>mesh).sourceMesh && (<InstancedMesh>mesh).sourceMesh.geometry;
geometryId = geometry ? geometry.id : null;
}

Expand Down
16 changes: 8 additions & 8 deletions src/babylon.scene.ts
Expand Up @@ -934,7 +934,7 @@

private _debugLayer: DebugLayer;

private _depthRenderer: {[id:string]:DepthRenderer} = {};
private _depthRenderer: { [id: string]: DepthRenderer } = {};
private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;

/**
Expand Down Expand Up @@ -1008,7 +1008,7 @@
return;
}

enabled = (enabled && !!Worker);
enabled = (enabled && !!Worker && !!CollisionWorker);

this._workerCollisions = enabled;
if (this.collisionCoordinator) {
Expand Down Expand Up @@ -3420,7 +3420,7 @@
this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
}

if (this.renderTargetsEnabled && this._renderTargets.length > 0) {
if (this.renderTargetsEnabled && this._renderTargets.length > 0) {
this._intermediateRendering = true;
Tools.StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
Expand Down Expand Up @@ -3573,7 +3573,7 @@
}

this.activeCamera = camera;
this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
}

private _checkIntersections(): void {
Expand Down Expand Up @@ -3803,7 +3803,7 @@
}

// Depth renderer
for(var key in this._depthRenderer){
for (var key in this._depthRenderer) {
this._renderTargets.push(this._depthRenderer[key].getDepthMap());
}

Expand Down Expand Up @@ -3998,12 +3998,12 @@
*/
public enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer {
camera = camera || this.activeCamera;
if(!camera){
if (!camera) {
throw "No camera available to enable depth renderer";
}
if (!this._depthRenderer[camera.id]) {
this._depthRenderer[camera.id] = new DepthRenderer(this, Engine.TEXTURETYPE_FLOAT, camera);
}
}

return this._depthRenderer[camera.id];
}
Expand Down Expand Up @@ -4069,7 +4069,7 @@

this.resetCachedMaterial();

for(var key in this._depthRenderer){
for (var key in this._depthRenderer) {
this._depthRenderer[key].dispose();
}

Expand Down

0 comments on commit 6a70f78

Please sign in to comment.