From be1b1d3d486499e4a7488747fdc1fbd31f7a5a36 Mon Sep 17 00:00:00 2001 From: hanemile Date: Wed, 23 Jan 2019 16:23:17 +0100 Subject: added the recursion limit again --- quadtree.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/quadtree.go b/quadtree.go index ca62afc..ebab528 100644 --- a/quadtree.go +++ b/quadtree.go @@ -62,6 +62,10 @@ func (n *Node) Subdivide() { // Insert inserts the given star into the Node or the tree it is called on func (n *Node) Insert(star Star2D) error { + if n.Boundry.Width < 1e-20 { + return fmt.Errorf("%s", "Max Recursion depth reached!") + } + // if the subtree does not contain a node, insert the star if n.Star == (Star2D{}) { @@ -105,7 +109,7 @@ func (n *Node) Insert(star Star2D) error { star = Star2D{} } - // fmt.Println("Done inserting %v, the tree noe looks like this: %v", star, n) + // fmt.Println("Done inserting %v, the tree looks like this: %v", star, n) return nil } -- cgit 1.4.1