Refactor
This commit is contained in:
parent
1ce961d6c2
commit
99cdb62928
5 changed files with 338 additions and 431 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
|
||||
export class BoundingBoxBase {
|
||||
// axes aligned
|
||||
export abstract class BoundingBoxBase {
|
||||
constructor(
|
||||
protected _xMin: number = 0,
|
||||
protected _xMax: number = 0,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { BoundingBoxBase } from '../bounding-boxes/bounding-box-base';
|
||||
import { StaticPhysical } from '../physicals/static-physical';
|
||||
// source: https://github.com/ubilabs/kd-tree-javascript/blob/master/kdTree.js
|
||||
|
||||
// source: https://github.com/ubilabs/kd-tree-javascript/blob/master/kdTree.js
|
||||
class Node {
|
||||
public left: Node | null = null;
|
||||
public right: Node | null = null;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { Circle } from 'shared';
|
||||
import { BoundingBoxBase } from '../bounding-boxes/bounding-box-base';
|
||||
import { ImmutableBoundingBox } from '../bounding-boxes/immutable-bounding-box';
|
||||
|
||||
export const getBoundingBoxOfCircle = (circle: Circle): BoundingBoxBase =>
|
||||
new BoundingBoxBase(
|
||||
new ImmutableBoundingBox(
|
||||
circle.center.x - circle.radius,
|
||||
circle.center.x + circle.radius,
|
||||
circle.center.y - circle.radius,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { Circle, GameObject, rotate90Deg } from 'shared';
|
||||
import { CirclePhysical } from '../../objects/circle-physical';
|
||||
import { reactsToCollision } from '../physicals/reacts-to-collision';
|
||||
import { reactsToCollision } from './reacts-to-collision';
|
||||
import { evaluateSdf } from './evaluate-sdf';
|
||||
import { Physical } from '../physicals/physical';
|
||||
|
||||
|
|
|
|||
8
backend/src/physics/functions/reacts-to-collision.ts
Normal file
8
backend/src/physics/functions/reacts-to-collision.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import { GameObject } from 'shared';
|
||||
|
||||
export interface ReactsToCollision {
|
||||
onCollision(other: GameObject): void;
|
||||
}
|
||||
|
||||
export const reactsToCollision = (a: any): a is ReactsToCollision =>
|
||||
a && 'onCollision' in a;
|
||||
Loading…
Reference in a new issue