Skip to content

Octree gives various clojure.lang level errors  #75

@charlieb

Description

@charlieb

First let me apologise for the poor title of this issue and then apologise again for not having narrowed down the exact cases that cause these problems.

I have this piece of code

(defn new-rand-point [xyz-range]
  (vec3 (- (rand xyz-range) (/ xyz-range 2))
        (- (rand xyz-range) (/ xyz-range 2))
        (- (rand xyz-range) (/ xyz-range 2))))
(defn dla-points
  "I don't do a whole lot."
  [npoints start-range]
  (let [tree (st/octree 0 0 0 100 100 100)]
    (g/add-point tree (vec3 0 0 0) (vec3 0 0 0))
    (loop [tree tree
           i npoints
           p (new-rand-point start-range)]
      (println i p)
      (cond (zero? i)
            (st/select-with-sphere tree (vec3 0 0 0) 50)

            (st/points-in-sphere? tree p 5) 
            (recur (g/add-point tree p p)
                   (dec i)
                   (new-rand-point start-range))

            (not (st/points-in-sphere? tree p 10))
            (recur tree i (new-rand-point start-range))

            :otherwise 
            (recur tree i (.+ p (new-rand-point 1.)))))))
(dla-points 100 50)

Which when run sometimes succeeds, sometimes gets to the last point and fails with

StackOverflowError   clojure.lang.Symbol.hashCode (Symbol.java:84)

and sometimes freezes, waits and then gives this:

OutOfMemoryError Java heap space  clojure.lang.PersistentVector.assocN (PersistentVector.java:181)

I'm probably breaking some (unwritten) rules in the way I'm using this but please let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions