Exemplo n.º 1
0
    private void SubDivide()
    {
        float xo = aABB.extents.x * 0.5f;
        float yo = aABB.extents.y * 0.5f;

        northeast = new QuadTreeNodes(new AABB(new Vector2(aABB.center.x - xo, aABB.center.y + yo), aABB.extents), capacity);
        northwest = new QuadTreeNodes(new AABB(new Vector2(aABB.center.x + xo, aABB.center.y + yo), aABB.extents), capacity);
        southeast = new QuadTreeNodes(new AABB(new Vector2(aABB.center.x - xo, aABB.center.y - yo), aABB.extents), capacity);
        southwest = new QuadTreeNodes(new AABB(new Vector2(aABB.center.x + xo, aABB.center.y - yo), aABB.extents), capacity);

        subDivided = true;
    }
Exemplo n.º 2
0
 public override void Build(AABB aabb, List <Body> bodies)
 {
     potientialCollisionCount = 0;
     rootNode = new QuadTreeNodes(aabb, capacity);
     bodies.ForEach(body => rootNode.Insert(body));
 }