Skip to content

Commit 2b4cc79

Browse files
author
phishman3579
committed
Using a slightly move efficient insert method for rectangle quadtree
git-svn-id: https://java-algorithms-implementation.googlecode.com/svn/trunk@394 032fbc0f-8cab-eb90-e552-f08422b9a96a
1 parent 009be3b commit 2b4cc79

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/com/jwetherell/algorithms/data_structures/QuadTree.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,10 @@ private void subdivide() {
362362

363363
private boolean insertIntoChildren(AABB b) {
364364
//Try to insert into all children
365-
if (northWest.insert(b)) return true;
366-
if (northEast.insert(b)) return true;
367-
if (southWest.insert(b)) return true;
368-
if (southEast.insert(b)) return true;
365+
if (northWest.aabb.insideThis(b) && northWest.insert(b)) return true;
366+
if (northEast.aabb.insideThis(b) && northEast.insert(b)) return true;
367+
if (southWest.aabb.insideThis(b) && southWest.insert(b)) return true;
368+
if (southEast.aabb.insideThis(b) && southEast.insert(b)) return true;
369369
return false;
370370
}
371371

0 commit comments

Comments
 (0)