insertRecursive( thing, mHead, 0 );
}
private void insertRecursive( T thing, Node< T > node, int depth ) {
if( node.mTopLeft != null ) {
Box thingBox = thing.getBox()[ 0 ];
if( thingBox.intersectingWith( node.mTopLeft.mNodeLoc ) )
insertRecursive( thing, node.mTopLeft, depth + 1 );
if( thingBox.intersectingWith( node.mTopRight.mNodeLoc ) )
insertRecursive( thing, node.mTopRight, depth + 1 );
if( thingBox.intersectingWith( node.mBottomLeft.mNodeLoc ) )
insertRecursive( thing, node.mBottomLeft, depth + 1 );
if( thingBox.intersectingWith( node.mBottomRight.mNodeLoc ) )
insertRecursive( thing, node.mBottomRight, depth + 1 );
}
else {
node.mStoredItems.add( thing );
if( node.mStoredItems.size() >= mItemsToSplit && depth < mMaxDepth ) {