-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7af7ae0
commit 9c76c6c
Showing
4 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
class BlackHoleQuadtree extends \Quadtree\QuadtreeAbstract | ||
{ | ||
public function __construct(\Quadtree\Geometry\Bounds $bounds, $leafCapacity) | ||
{ | ||
$detector = new \DummyCollisionDetector(); | ||
parent::__construct($detector, $bounds, $leafCapacity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
class DummyCollisionDetector implements \Quadtree\ICollisionDetector | ||
{ | ||
public function collide(array $insertedItems, \Quadtree\Insertable $item) | ||
{ | ||
return FALSE; | ||
} | ||
|
||
public function intersects(\Quadtree\Geometry\Bounds $bounds, \Quadtree\Insertable $item) | ||
{ | ||
return $bounds->intersects($item->getBounds()); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
require './DummyCollistionDetector.php'; | ||
require './BlackHoleQuadtree.php'; | ||
|
||
use Tester\Assert; | ||
use Quadtree\Quadtree; | ||
use Quadtree\Geometry\Bounds; | ||
|
||
$qt = new BlackHoleQuadtree(new Bounds(100, 100), 2); | ||
Assert::true($qt->insert(new Bounds(100, 100))); | ||
Assert::true($qt->insert(new Bounds(100, 100))); | ||
Assert::true($qt->insert(new Bounds(100, 100))); | ||
|
||
Assert::true($qt->insert(new Bounds(10, 10))); | ||
Assert::true($qt->insert(new Bounds(10, 10))); | ||
Assert::true($qt->insert(new Bounds(10, 10))); |