Skip to content

Commit

Permalink
Filter static items
Browse files Browse the repository at this point in the history
  • Loading branch information
DrA1ex committed Oct 8, 2023
1 parent 4554d3e commit 1c59542
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/physics/common/boundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ export class BoundaryBox {
*/
static isEqual(b1, b2) {
return b1.left === b2.left && b1.right === b2.right
&& b1.top === b1.top && b2.bottom === b2.bottom;
&& b1.top === b2.top && b1.bottom === b2.bottom;
}
}
6 changes: 4 additions & 2 deletions lib/physics/common/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ export class SpatialTree {

this.#savedStackPosition = BoundaryBoxPool.save();

const boundary = BoundaryBox.fromBodies(items, BoundaryBoxPool);
const filteredItems = items.filter(b => !b.static)

const boundary = BoundaryBox.fromBodies(filteredItems, BoundaryBoxPool);
const segmentBoundary = this.#createLevelBoundary(boundary);

this.root = new SpatialLeaf(this.#leafId++, items, boundary, segmentBoundary, true);
this.root = new SpatialLeaf(this.#leafId++, filteredItems, boundary, segmentBoundary, true);

this.#fillLeaf(this.root);
}
Expand Down

0 comments on commit 1c59542

Please sign in to comment.