Skip to content

Line segment tests return all objects? #8

@ayebear

Description

@ayebear

For some reason, when dealing with line segments using get(), all objects are returned. I'm thinking maybe I am misunderstanding what using a line segment actually does, but it definitely is not what I would expect.

Code example (es6):

import QuadTree from 'simple-quadtree'

let quadTree = QuadTree(0, 0, 100000, 100000)

// This should be the only collision
quadTree.put({x: 10, y: 10, w: 4, h: 4, obj: 'Yay'})

// Far away objects
quadTree.put({x: 200, y: 200, w: 4, h: 4, obj: 'Boo 1'})
quadTree.put({x: 300, y: 100, w: 4, h: 4, obj: 'Boo 2'})

// Here is where my confusion lies: all objects are returned instead of just the first one
let collisions = quadTree.get({x: 1, y: 11, dx: 1, dy: 0})
console.log('Quadtree Tests:')
console.log(collisions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions