56 G3D::AABox bounds = G3D::AABox::empty();
57 BoundsFunc::getBounds(value, bounds);
58 Cell low = Cell::ComputeCell(bounds.low().x, bounds.low().y);
59 Cell high = Cell::ComputeCell(bounds.high().x, bounds.high().y);
60 for (
int x = low.
x; x <= high.
x; ++x)
62 for (
int y = low.
y; y <= high.
y; ++y)
64 Node& node = getGrid(x, y);
66 memberTable.emplace(&value, &node);
119 void intersectRay(G3D::Ray
const& ray, RayCallback& intersectCallback,
float& max_dist, G3D::Vector3
const& end)
121 Cell cell = Cell::ComputeCell(ray.origin().x, ray.origin().y);
125 Cell last_cell = Cell::ComputeCell(end.x, end.y);
127 if (cell == last_cell)
129 if (Node* node = nodes[cell.
x][cell.
y].get())
130 node->intersectRay(ray, intersectCallback, max_dist);
135 float kx_inv = ray.invDirection().x, bx = ray.origin().x;
136 float ky_inv = ray.invDirection().y, by = ray.origin().y;
143 float x_border = (cell.
x+1) * voxel;
144 tMaxX = (x_border - bx) * kx_inv;
149 float x_border = (cell.
x-1) * voxel;
150 tMaxX = (x_border - bx) * kx_inv;
156 float y_border = (cell.
y+1) * voxel;
157 tMaxY = (y_border - by) * ky_inv;
162 float y_border = (cell.
y-1) * voxel;
163 tMaxY = (y_border - by) * ky_inv;
169 float tDeltaX = voxel * std::fabs(kx_inv);
170 float tDeltaY = voxel * std::fabs(ky_inv);
173 if (Node* node = nodes[cell.
x][cell.
y].get())
176 node->intersectRay(ray, intersectCallback, max_dist);
178 if (cell == last_cell)
197 Cell cell = Cell::ComputeCell(point.x, point.y);
200 if (Node* node = nodes[cell.
x][cell.
y].get())
201 node->intersectPoint(point, intersectCallback);
208 Cell cell = Cell::ComputeCell(ray.origin().x, ray.origin().y);
211 if (Node* node = nodes[cell.
x][cell.
y].get())
212 node->intersectRay(ray, intersectCallback, max_dist);