70 BoundsFunc::getBounds(value, bounds);
71 Cell low = Cell::ComputeCell(bounds.low().x, bounds.low().y);
72 Cell high = Cell::ComputeCell(bounds.high().x, bounds.high().y);
73 for (
int x = low.
x; x <= high.
x; ++x)
75 for (
int y = low.
y; y <= high.
y; ++y)
77 Node& node = getGrid(x, y);
79 memberTable.emplace(&value, &node);
135 void intersectRay(
const G3D::Ray& ray, RayCallback& intersectCallback,
float& max_dist,
const G3D::Vector3& end)
137 Cell cell = Cell::ComputeCell(ray.origin().x, ray.origin().y);
141 Cell last_cell = Cell::ComputeCell(end.x, end.y);
143 if (cell == last_cell)
145 if (Node* node = nodes[cell.
x][cell.
y])
146 node->intersectRay(ray, intersectCallback, max_dist);
151 float kx_inv = ray.invDirection().x, bx = ray.origin().x;
152 float ky_inv = ray.invDirection().y, by = ray.origin().y;
159 float x_border = (cell.
x+1) * voxel;
160 tMaxX = (x_border - bx) * kx_inv;
165 float x_border = (cell.
x-1) * voxel;
166 tMaxX = (x_border - bx) * kx_inv;
172 float y_border = (cell.
y+1) * voxel;
173 tMaxY = (y_border - by) * ky_inv;
178 float y_border = (cell.
y-1) * voxel;
179 tMaxY = (y_border - by) * ky_inv;
185 float tDeltaX = voxel * std::fabs(kx_inv);
186 float tDeltaY = voxel * std::fabs(ky_inv);
189 if (Node* node = nodes[cell.
x][cell.
y])
192 node->intersectRay(ray, intersectCallback, max_dist);
194 if (cell == last_cell)
213 Cell cell = Cell::ComputeCell(point.x, point.y);
216 if (Node* node = nodes[cell.
x][cell.
y])
217 node->intersectPoint(point, intersectCallback);
224 Cell cell = Cell::ComputeCell(ray.origin().x, ray.origin().y);
227 if (Node* node = nodes[cell.
x][cell.
y])
228 node->intersectRay(ray, intersectCallback, max_dist);