Viewer is ready to go, I think
This commit is contained in:
@@ -176,8 +176,8 @@ int PlaneMap::total_cells() const {
|
||||
return total;
|
||||
}
|
||||
|
||||
PlaneMap::EltVec PlaneMap::scan_radius(const std::string &plane, double x, double y, double radius) const {
|
||||
PlaneMap::EltVec result;
|
||||
PlaneMap::IdVec PlaneMap::scan_radius(const std::string &plane, double x, double y, double radius) const {
|
||||
PlaneMap::IdVec result;
|
||||
auto piter = planes_.find(plane);
|
||||
if (piter != planes_.end()) {
|
||||
const Plane &p = piter->second;
|
||||
@@ -189,7 +189,7 @@ PlaneMap::EltVec PlaneMap::scan_radius(const std::string &plane, double x, doubl
|
||||
if (liter != p.end()) {
|
||||
for (PlaneItem *client : liter->second) {
|
||||
if (util::distance_squared(client->x(), client->y(), x, y) <= radsq) {
|
||||
result.push_back(client);
|
||||
result.push_back(client->id());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,6 +207,7 @@ LuaDefine(unittests_planemap, "c") {
|
||||
PlaneMap pm;
|
||||
PlaneItem pia, pib;
|
||||
PlaneMap::EltVec elts;
|
||||
PlaneMap::IdVec ids;
|
||||
|
||||
// Simple test.
|
||||
LuaAssert(L, rect_cell_range(-7*SC, -15*SC, 87*SC, 21*SC).equal(-7, -15, 87, 21));
|
||||
@@ -306,13 +307,19 @@ LuaDefine(unittests_planemap, "c") {
|
||||
|
||||
// Insert the four elements, then test the scan function.
|
||||
pm.track(&pib);
|
||||
pia.set_id(123);
|
||||
pib.set_id(456);
|
||||
pib.set_pos("bar", 1100.0, 1000.0, 0.0);
|
||||
elts = pm.scan_radius("bar", 1000.0, 1000.0, 1.0);
|
||||
LuaAssert(L, elts.size() == 1);
|
||||
elts = pm.scan_radius("bar", 1000.0, 1000.0, 99.9);
|
||||
LuaAssert(L, elts.size() == 1);
|
||||
elts = pm.scan_radius("bar", 1000.0, 1000.0, 100.0);
|
||||
LuaAssert(L, elts.size() == 2);
|
||||
|
||||
ids = pm.scan_radius("bar", 1000.0, 1000.0, 1.0);
|
||||
LuaAssert(L, ids.size() == 1);
|
||||
LuaAssert(L, ids[0] == 123);
|
||||
ids = pm.scan_radius("bar", 1000.0, 1000.0, 99.9);
|
||||
LuaAssert(L, ids.size() == 1);
|
||||
LuaAssert(L, ids[0] == 123);
|
||||
ids = pm.scan_radius("bar", 1000.0, 1000.0, 100.0);
|
||||
LuaAssert(L, ids.size() == 2);
|
||||
LuaAssert(L, ids[0] == 123);
|
||||
LuaAssert(L, ids[1] == 456);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user