Files
esengine/source/src/Physics/Physics.ts

26 lines
844 B
TypeScript
Raw Normal View History

class Physics {
private static _spatialHash: SpatialHash;
public static readonly allLayers: number = -1;
public static overlapCircleAll(center: Vector2, randius: number, results: any[], layerMask = -1){
return this._spatialHash.overlapCircle(center, randius, results, layerMask);
}
2020-06-15 08:46:38 +08:00
public static boxcastBroadphase(rect: Rectangle, layerMask: number = this.allLayers){
return this._spatialHash.aabbBroadphase(rect, null, layerMask);
}
2020-06-15 10:42:06 +08:00
public static addCollider(collider: Collider){
Physics._spatialHash.register(collider);
}
public static removeCollider(collider: Collider){
Physics._spatialHash.remove(collider);
}
2020-06-15 10:42:06 +08:00
public static updateCollider(collider: Collider){
this._spatialHash.remove(collider);
this._spatialHash.register(collider);
}
}