#1 - ClientWorldController refactoring
This commit is contained in:
@@ -7,28 +7,6 @@
|
||||
|
||||
namespace tw::net::im {
|
||||
|
||||
/**
|
||||
* Bounded-world spatial grid backend.
|
||||
*
|
||||
* World area bounds are supplied at construction time so the same grid type
|
||||
* can be reused for differently-sized zones without recompiling.
|
||||
* CELL_SIZE and VIEW_RADIUS remain template parameters so kNeighborRadius
|
||||
* can be computed at compile time, keeping the hot-path loop bounds constant.
|
||||
*
|
||||
* Template parameters:
|
||||
* CELL_SIZE: size of each cell (meters). Recommended: CELL_SIZE == VIEW_RADIUS
|
||||
* for maximum efficiency (no distance checks needed).
|
||||
* VIEW_RADIUS: the subscription radius around a player (meters).
|
||||
*
|
||||
* Constructor parameters:
|
||||
* min_x, max_x, min_z, max_z — world area bounds (meters).
|
||||
*
|
||||
* Complexity:
|
||||
* begin_frame(): O(cols × rows) clearing
|
||||
* insert(): O(1)
|
||||
* query_neighbors(): O(kNeighborRadius²) cells × avg entities per cell
|
||||
* query_area(): O(cells overlapping AABB) × avg entities per cell
|
||||
*/
|
||||
template<uint32_t CELL_SIZE, uint32_t VIEW_RADIUS>
|
||||
class FixedGrid {
|
||||
public:
|
||||
@@ -45,9 +23,6 @@ private:
|
||||
int32_t m_world_min_z, m_world_max_z;
|
||||
uint32_t m_cols, m_rows;
|
||||
|
||||
// Flat 2D vector of cell vectors indexed as [cz * m_cols + cx].
|
||||
// Outer vector is allocated once at construction; inner vectors retain
|
||||
// capacity across frames so no heap allocations occur in steady state.
|
||||
std::vector<std::vector<entt::entity>> m_cells;
|
||||
|
||||
[[nodiscard]] inline std::pair<uint32_t, uint32_t> world_to_cell(
|
||||
|
||||
Reference in New Issue
Block a user