Region quadtree for 2D AABB broad-phase / map culling. Items are stored in the smallest node that fully contains them; spanning items stay at the parent. Scripts use insert/remove/query* + getResult*. 更多...
#include <QuadTree.h>
Public 成员函数 | |
| QuadTree (float minX, float minY, float maxX, float maxY, int maxDepth=8, int maxPerNode=8) | |
| Creates a quadtree covering the given 2D bounds. | |
| ~QuadTree ()=default | |
| Releases tree nodes. | |
| QuadTree (const QuadTree &)=delete | |
| QuadTree & | operator= (const QuadTree &)=delete |
| void | clear () |
| Removes all stored entries. | |
| bool | insert (int id, float minX, float minY, float maxX, float maxY) |
| Inserts an item AABB; false if out of bounds or id already present. | |
| bool | remove (int id) |
| Removes an item by id; false if unknown. | |
| bool | update (int id, float minX, float minY, float maxX, float maxY) |
| Moves an existing item to a new AABB; false if unknown or out of bounds. | |
| bool | contains (int id) const |
| True if the id is currently stored. | |
| int | getCount () const |
| Number of stored ids. | |
| int | queryPoint (float x, float y) |
| Finds items overlapping a point; fills the result buffer. | |
| int | queryRect (float minX, float minY, float maxX, float maxY) |
| Finds items overlapping an AABB; fills the result buffer. | |
| int | queryCircle (float cx, float cy, float radius) |
| Finds items overlapping a circle; fills the result buffer. | |
| int | getResultCount () const |
| Number of hits from the last query*. | |
| int | getResultId (int index) const |
| Hit id at dense index from the last query*, or -1. | |
| float | getMinX () const |
| Root/world minimum X. | |
| float | getMinY () const |
| Root/world minimum Y. | |
| float | getMaxX () const |
| Root/world maximum X. | |
| float | getMaxY () const |
| Root/world maximum Y. | |
| int | getMaxDepth () const |
| Maximum subdivision depth. | |
| int | getMaxPerNode () const |
| Item capacity before a node splits. | |
详细描述
Region quadtree for 2D AABB broad-phase / map culling. Items are stored in the smallest node that fully contains them; spanning items stay at the parent. Scripts use insert/remove/query* + getResult*.
在文件 QuadTree.h 第 19 行定义.
构造及析构函数说明
◆ QuadTree() [1/2]
| eve::spatial::QuadTree::QuadTree | ( | float | minX, |
| float | minY, | ||
| float | maxX, | ||
| float | maxY, | ||
| int | maxDepth = 8, |
||
| int | maxPerNode = 8 |
||
| ) |
Creates a quadtree covering the given 2D bounds.
在文件 QuadTree.cpp 第 7 行定义.
引用了 eve::spatial::AABB2::height(), eve::spatial::AABB2::valid() , 以及 eve::spatial::AABB2::width().
◆ ~QuadTree()
|
default |
Releases tree nodes.
◆ QuadTree() [2/2]
|
delete |
成员函数说明
◆ clear()
| void eve::spatial::QuadTree::clear | ( | ) |
◆ contains()
| bool eve::spatial::QuadTree::contains | ( | int | id | ) | const |
True if the id is currently stored.
在文件 QuadTree.cpp 第 33 行定义.
◆ getCount()
|
inline |
Number of stored ids.
在文件 QuadTree.h 第 41 行定义.
◆ getMaxDepth()
|
inline |
Maximum subdivision depth.
在文件 QuadTree.h 第 64 行定义.
◆ getMaxPerNode()
|
inline |
Item capacity before a node splits.
在文件 QuadTree.h 第 66 行定义.
◆ getMaxX()
|
inline |
Root/world maximum X.
在文件 QuadTree.h 第 60 行定义.
◆ getMaxY()
|
inline |
Root/world maximum Y.
在文件 QuadTree.h 第 62 行定义.
◆ getMinX()
|
inline |
Root/world minimum X.
在文件 QuadTree.h 第 56 行定义.
◆ getMinY()
|
inline |
Root/world minimum Y.
在文件 QuadTree.h 第 58 行定义.
◆ getResultCount()
|
inline |
Number of hits from the last query*.
在文件 QuadTree.h 第 51 行定义.
◆ getResultId()
|
inline |
◆ insert()
| bool eve::spatial::QuadTree::insert | ( | int | id, |
| float | minX, | ||
| float | minY, | ||
| float | maxX, | ||
| float | maxY | ||
| ) |
Inserts an item AABB; false if out of bounds or id already present.
在文件 QuadTree.cpp 第 35 行定义.
引用了 b, contains(), id, eve::spatial::makeAABB2() , 以及 remove().
被这些函数引用 update().
◆ operator=()
◆ queryCircle()
| int eve::spatial::QuadTree::queryCircle | ( | float | cx, |
| float | cy, | ||
| float | radius | ||
| ) |
Finds items overlapping a circle; fills the result buffer.
- 返回
- Hit count.
在文件 QuadTree.cpp 第 170 行定义.
引用了 eve::spatial::QueryIds::clear(), cx, cy, eve::spatial::QueryIds::getCount() , 以及 radius.
◆ queryPoint()
| int eve::spatial::QuadTree::queryPoint | ( | float | x, |
| float | y | ||
| ) |
Finds items overlapping a point; fills the result buffer.
- 返回
- Hit count.
在文件 QuadTree.cpp 第 157 行定义.
引用了 eve::spatial::QueryIds::clear(), eve::spatial::QueryIds::getCount(), x , 以及 y.
◆ queryRect()
| int eve::spatial::QuadTree::queryRect | ( | float | minX, |
| float | minY, | ||
| float | maxX, | ||
| float | maxY | ||
| ) |
Finds items overlapping an AABB; fills the result buffer.
- 返回
- Hit count.
在文件 QuadTree.cpp 第 163 行定义.
引用了 eve::spatial::QueryIds::clear(), eve::spatial::QueryIds::getCount() , 以及 eve::spatial::makeAABB2().
◆ remove()
| bool eve::spatial::QuadTree::remove | ( | int | id | ) |
Removes an item by id; false if unknown.
在文件 QuadTree.cpp 第 49 行定义.
引用了 contains().
被这些函数引用 insert().
◆ update()
| bool eve::spatial::QuadTree::update | ( | int | id, |
| float | minX, | ||
| float | minY, | ||
| float | maxX, | ||
| float | maxY | ||
| ) |
Moves an existing item to a new AABB; false if unknown or out of bounds.
在文件 QuadTree.cpp 第 56 行定义.
引用了 contains() , 以及 insert().
该类的文档由以下文件生成:
- src/modules/spatial/QuadTree.h
- src/modules/spatial/QuadTree.cpp