 
   update: ->
     @emitter.update()
+
+    @space.update(this)
 
     particles = @particles
 

  # The particle emitter
  emitter: null

  springIterations: 1

  constructor: ->
    @clear()

  clear: ->
    @particles = []
    @behaviours = []
    @constraints = []
    @emitter = new Emitter(this)

  # polymorphic add
  add: ->

  size: -> @particles.length


###
  Spatial Search

  Simple brute force spatial searches.
  Subclasses may override this to organise particles so they can be found quicker later
###
class Space
  physics = null

  constructor: ->

  update: (physics_) -> physics = physics_

  search: (center, radius) ->
    result = []
    radiusSq = radius * radius

    for particle in physics.particles
      if center.distanceSquared(particle.position) < radiusSq
        result.push particle

    result


###
  Particle Emitter
###
class Emitter
  rate: 1
