Uniform-grid spatial hash for 2D AABB queries (map / particle / entity culling). Items are registered in every overlapped cell. 更多...
#include <SpatialHash2D.h>
Public 成员函数 | |
| SpatialHash2D (float cellSize=64.f) | |
| Creates a 2D spatial hash with the given cell size. | |
| ~SpatialHash2D ()=default | |
| Releases hash buckets. | |
| SpatialHash2D (const SpatialHash2D &)=delete | |
| SpatialHash2D & | operator= (const SpatialHash2D &)=delete |
| void | clear () |
| Removes all stored entries. | |
| void | setCellSize (float cellSize) |
| Sets cell size and clears existing entries. | |
| float | getCellSize () const |
| Current uniform cell size. | |
| 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. | |
详细描述
Uniform-grid spatial hash for 2D AABB queries (map / particle / entity culling). Items are registered in every overlapped cell.
在文件 SpatialHash2D.h 第 18 行定义.
构造及析构函数说明
◆ SpatialHash2D() [1/2]
|
explicit |
Creates a 2D spatial hash with the given cell size.
在文件 SpatialHash2D.cpp 第 10 行定义.
引用了 setCellSize().
◆ ~SpatialHash2D()
|
default |
Releases hash buckets.
◆ SpatialHash2D() [2/2]
|
delete |
成员函数说明
◆ clear()
| void eve::spatial::SpatialHash2D::clear | ( | ) |
Removes all stored entries.
在文件 SpatialHash2D.cpp 第 29 行定义.
引用了 eve::spatial::QueryIds::clear().
被这些函数引用 setCellSize().
◆ contains()
| bool eve::spatial::SpatialHash2D::contains | ( | int | id | ) | const |
◆ getCellSize()
|
inline |
Current uniform cell size.
在文件 SpatialHash2D.h 第 33 行定义.
◆ getCount()
|
inline |
Number of stored ids.
在文件 SpatialHash2D.h 第 44 行定义.
◆ getResultCount()
|
inline |
Number of hits from the last query*.
在文件 SpatialHash2D.h 第 54 行定义.
◆ getResultId()
|
inline |
◆ insert()
| bool eve::spatial::SpatialHash2D::insert | ( | int | id, |
| float | minX, | ||
| float | minY, | ||
| float | maxX, | ||
| float | maxY | ||
| ) |
Inserts an item AABB; false if out of bounds or id already present.
在文件 SpatialHash2D.cpp 第 69 行定义.
引用了 b, contains(), id, eve::spatial::makeAABB2() , 以及 remove().
被这些函数引用 setCellSize() , 以及 update().
◆ operator=()
|
delete |
◆ queryCircle()
| int eve::spatial::SpatialHash2D::queryCircle | ( | float | cx, |
| float | cy, | ||
| float | radius | ||
| ) |
Finds items overlapping a circle; fills the result buffer.
- 返回
- Hit count.
在文件 SpatialHash2D.cpp 第 133 行定义.
引用了 cx, cy, eve::spatial::QueryIds::getCount(), eve::spatial::makeAABB2() , 以及 radius.
◆ queryPoint()
| int eve::spatial::SpatialHash2D::queryPoint | ( | float | x, |
| float | y | ||
| ) |
Finds items overlapping a point; fills the result buffer.
- 返回
- Hit count.
在文件 SpatialHash2D.cpp 第 118 行定义.
引用了 cx, cy, eve::spatial::QueryIds::getCount(), x , 以及 y.
◆ queryRect()
| int eve::spatial::SpatialHash2D::queryRect | ( | float | minX, |
| float | minY, | ||
| float | maxX, | ||
| float | maxY | ||
| ) |
Finds items overlapping an AABB; fills the result buffer.
- 返回
- Hit count.
在文件 SpatialHash2D.cpp 第 125 行定义.
引用了 eve::spatial::QueryIds::getCount() , 以及 eve::spatial::makeAABB2().
◆ remove()
| bool eve::spatial::SpatialHash2D::remove | ( | int | id | ) |
◆ setCellSize()
| void eve::spatial::SpatialHash2D::setCellSize | ( | float | cellSize | ) |
Sets cell size and clears existing entries.
在文件 SpatialHash2D.cpp 第 12 行定义.
被这些函数引用 SpatialHash2D().
◆ update()
| bool eve::spatial::SpatialHash2D::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.
在文件 SpatialHash2D.cpp 第 86 行定义.
引用了 contains() , 以及 insert().
该类的文档由以下文件生成:
- src/modules/spatial/SpatialHash2D.h
- src/modules/spatial/SpatialHash2D.cpp