8#include <unordered_map>
9#include <unordered_set>
31 void setCellSize(
float cellSize);
36 bool insert(
int id,
float minX,
float minY,
float maxX,
float maxY);
40 bool update(
int id,
float minX,
float minY,
float maxX,
float maxY);
42 bool contains(
int id)
const;
44 int getCount()
const {
return static_cast<int>(items_.size()); }
47 int queryPoint(
float x,
float y);
49 int queryRect(
float minX,
float minY,
float maxX,
float maxY);
51 int queryCircle(
float cx,
float cy,
float radius);
59 void cellRange(
const AABB2 &
b,
int &minCX,
int &minCY,
int &maxCX,
int &maxCY)
const;
60 void insertCells(
int id,
const AABB2 &
b);
61 void eraseCells(
int id,
const AABB2 &
b);
62 void queryCells(
int minCX,
int minCY,
int maxCX,
int maxCY,
const AABB2 *rect,
float cx,
63 float cy,
float radius,
bool useCircle,
bool usePoint);
65 float cellSize_ = 64.f;
66 std::unordered_map<int, AABB2> items_;
67 std::unordered_map<uint64_t, std::vector<int>> cells_;
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Last-query hit buffer shared by spatial indexes. Script pattern: call query* → getResultCount / getRe...
Uniform-grid spatial hash for 2D AABB queries (map / particle / entity culling). Items are registered...
int getResultId(int index) const
Hit id at dense index from the last query*, or -1.
SpatialHash2D & operator=(const SpatialHash2D &)=delete
~SpatialHash2D()=default
Releases hash buckets.
int getCount() const
Number of stored ids.
SpatialHash2D(const SpatialHash2D &)=delete
float getCellSize() const
Current uniform cell size.
int getResultCount() const
Number of hits from the last query*.
Axis-aligned 2D bounding box (min/max inclusive).