started testing a new grid-builder
minor fixes worked on walkers
This commit is contained in:
18
grid/Grid.h
18
grid/Grid.h
@@ -177,10 +177,11 @@ public:
|
||||
}
|
||||
|
||||
/** get the center-node the given Point belongs to */
|
||||
const T& getNodeFor(const GridPoint& p) {
|
||||
const UID uid = getUID(p);
|
||||
Assert::isTrue(hashes.find(uid) != hashes.end(), "element not found!");
|
||||
return nodes[hashes[uid]];
|
||||
const T& getNodeFor(const GridPoint& p) const {
|
||||
//const UID uid = getUID(p);
|
||||
auto it = hashes.find(getUID(p));
|
||||
Assert::isTrue(it != hashes.end(), "element not found!");
|
||||
return nodes[it->second];
|
||||
}
|
||||
|
||||
/** get the center-node the given Point belongs to. or nullptr if not present */
|
||||
@@ -249,11 +250,11 @@ public:
|
||||
|
||||
inline int idxX(const int x_cm) const {return std::round(x_cm / (float)gridSize_cm);}
|
||||
inline int idxY(const int y_cm) const {return std::round(y_cm / (float)gridSize_cm);}
|
||||
inline int idxZ(const int z_cm) const {return std::round(z_cm / (float)gridSize_cm);} // * 5?? // z is usually much lower and not always aligned -> allow more room for hashes
|
||||
inline int idxZ(const int z_cm) const {return std::round(z_cm / 20.0f);} // * 5?? // z is usually much lower and not always aligned -> allow more room for hashes
|
||||
|
||||
inline int snapX(const int x_cm) const {return std::round(x_cm / (float)gridSize_cm) * gridSize_cm;}
|
||||
inline int snapY(const int y_cm) const {return std::round(y_cm / (float)gridSize_cm) * gridSize_cm;}
|
||||
inline int snapZ(const int z_cm) const {return std::round(z_cm / (float)gridSize_cm) * gridSize_cm;} // * 5?? // z is usually much lower and not always aligned -> allow more room for hashes
|
||||
inline int snapZ(const int z_cm) const {return std::round(z_cm / 20.0f) * 20;} // * 5?? // z is usually much lower and not always aligned -> allow more room for hashes
|
||||
|
||||
|
||||
/** array access */
|
||||
@@ -295,6 +296,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/** convert to a GridPoint coordinate (in cm) */
|
||||
GridPoint toGridPoint(const Point3 pos_m) const {
|
||||
return GridPoint( snapX(pos_m.x*100), snapY(pos_m.y*100), snapZ(pos_m.z*100) );
|
||||
}
|
||||
|
||||
/** remove the given array-index by moving all follwing elements down by one */
|
||||
template <typename X> void arrayRemove(X* arr, const int idxToRemove, const int arrayLen) {
|
||||
for (int i = idxToRemove+1; i < arrayLen; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user