Fix collision detection issues

This commit is contained in:
schmelczerandras 2020-08-14 10:13:20 +02:00
commit 6d6284f717

View file

@ -4,22 +4,22 @@ import { ImmutableBoundingBox } from './containers/immutable-bounding-box';
import { BoundingBoxBase } from './containers/bounding-box-base';
export class Physics {
private staticBoundingBoxesWaitList = [];
private isTreeInitialized = false;
private staticBoundingBoxesWaitList = [];
private staticBoundingBoxes = new BoundingBoxTree();
private dynamicBoundingBoxes = new BoundingBoxList();
public addStaticBoundingBox(boundingBox: ImmutableBoundingBox) {
this.staticBoundingBoxesWaitList.push(boundingBox);
if (!this.isTreeInitialized) {
this.staticBoundingBoxesWaitList.push(boundingBox);
} else {
this.staticBoundingBoxes.insert(boundingBox);
}
}
public addDynamicBoundingBox(boundingBox: BoundingBoxBase) {
if (this.isTreeInitialized) {
this.staticBoundingBoxes.insert(boundingBox);
} else {
this.dynamicBoundingBoxes.insert(boundingBox);
}
this.dynamicBoundingBoxes.insert(boundingBox);
}
public findIntersecting(box: BoundingBoxBase): Array<BoundingBoxBase> {