Quadtree vs Red-Black tree for a game in C++?

后端 未结 6 849
小鲜肉
小鲜肉 2021-02-02 03:33

I have been looking for a quadtree/quadtree node implementation on the net for ages. There is some basic stuff but nothing that I would be able to really use it a game.

6条回答
  •  情歌与酒
    2021-02-02 03:59

    Trees in general are problematic for this in that any item inserted can lie on a boundary, and all the methods of dealing with that situation are fairly unsatisfactory.

    You'll most likely want to sort your objects into moveable and static, and check anything that moved on a given frame against the static objects.

    BSP Trees are the accepted solution for static geometry (boundary cases handled by splitting the object into two pieces), for dynamic try something like Sort and Sweep (also known as Sweep and Prune).

提交回复
热议问题