diff options
Diffstat (limited to 'engine/components/BoundingBox.ts')
-rw-r--r-- | engine/components/BoundingBox.ts | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/engine/components/BoundingBox.ts b/engine/components/BoundingBox.ts index dbe083e..921feb9 100644 --- a/engine/components/BoundingBox.ts +++ b/engine/components/BoundingBox.ts @@ -15,7 +15,6 @@ export class BoundingBox extends Component { this.rotation = rotation ?? 0; } - // https://en.wikipedia.org/wiki/Hyperplane_separation_theorem public isCollidingWith(box: BoundingBox): boolean { if (this.rotation == 0 && box.rotation == 0) { const thisTopLeft = this.getTopLeft(); @@ -36,6 +35,7 @@ export class BoundingBox extends Component { return true; } + // https://en.wikipedia.org/wiki/Hyperplane_separation_theorem const boxes = [this.getVertices(), box.getVertices()]; for (const poly of boxes) { for (let i = 0; i < poly.length; i++) { @@ -89,6 +89,8 @@ export class BoundingBox extends Component { let rads = this.getRotationInPiOfUnitCircle(); const { width, height } = this.dimension; + if (rads == 0) return this.dimension; + if (rads <= Math.PI / 2) { return { width: Math.abs(height * Math.sin(rads) + width * Math.cos(rads)), |