From 98e795029bcc404463ed151ff5255a72498bc641 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 13 Aug 2023 16:47:58 -0600 Subject: Create network component and system --- engine/structures/QuadTree.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engine/structures/QuadTree.ts') diff --git a/engine/structures/QuadTree.ts b/engine/structures/QuadTree.ts index d1ff3b1..a57c6e7 100644 --- a/engine/structures/QuadTree.ts +++ b/engine/structures/QuadTree.ts @@ -41,17 +41,16 @@ export class QuadTree { this.dimension = dimension; } - public insert(id: number, dimension: Dimension2D, center: Coord2D): void { - const box: BoxedEntry = { id, center, dimension }; + public insert(boxedEntry: BoxedEntry): void { if (this.hasChildren()) { - this.getQuadrants(box).forEach((quadrant) => { + this.getQuadrants(boxedEntry).forEach((quadrant) => { const quadrantBox = this.children.get(quadrant); - quadrantBox?.insert(id, dimension, center); + quadrantBox?.insert(boxedEntry); }); return; } - this.objects.push({ id, dimension, center }); + this.objects.push(boxedEntry); if ( this.objects.length > this.splitThreshold && @@ -66,6 +65,7 @@ export class QuadTree { public clear(): void { this.objects = []; + if (this.hasChildren()) { this.children.forEach((child) => child.clear()); this.children.clear(); -- cgit v1.2.3-70-g09d2