dijkstra is now bleching fast
deleting from the grid is now bleaching fast added new helper methods many new test-cases many new methods for geo classes and others added a bunch of new grid-walkers
This commit is contained in:
@@ -52,6 +52,9 @@ public:
|
||||
// process each node
|
||||
for (T& n1 : g) {
|
||||
|
||||
// skip nodes on other than the requested floor-level
|
||||
if (n1.z_cm != z_cm) {continue;}
|
||||
|
||||
// get the 10 nearest neighbors and their distance
|
||||
size_t indices[numNeighbors];
|
||||
float squaredDist[numNeighbors];
|
||||
@@ -64,7 +67,9 @@ public:
|
||||
neighbors.push_back(&inv[indices[i]]);
|
||||
}
|
||||
|
||||
addImportance(n1, Units::cmToM(std::sqrt(squaredDist[0])) );
|
||||
n1.imp = 1.0f;
|
||||
|
||||
n1.imp += getWallImportance(n1, Units::cmToM(std::sqrt(squaredDist[0])) );
|
||||
//addDoor(n1, neighbors);
|
||||
|
||||
// is the current node a door?
|
||||
@@ -81,20 +86,16 @@ public:
|
||||
// process each node again
|
||||
for (T& n1 : g) {
|
||||
|
||||
static K::NormalDistribution favorDoors(0.0, 0.6);
|
||||
static K::NormalDistribution favorDoors(0.0, 1.0);
|
||||
|
||||
// get the distance to the nearest door
|
||||
const float dist_m = Units::cmToM(knnDoors.getNearestDistance( {n1.x_cm, n1.y_cm, n1.z_cm} ));
|
||||
|
||||
// importance for this node (based on the distance from the next door)
|
||||
const float imp = 1.0 + favorDoors.getProbability(dist_m) * 0.35;
|
||||
|
||||
// adjust
|
||||
n1.imp *= imp;
|
||||
n1.imp += favorDoors.getProbability(dist_m) * 0.30;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/** is the given node connected to a staircase? */
|
||||
@@ -190,10 +191,10 @@ public:
|
||||
}
|
||||
|
||||
/** get the importance of the given node depending on its nearest wall */
|
||||
template <typename T> void addImportance(T& nSrc, float dist_m) {
|
||||
template <typename T> float getWallImportance(T& nSrc, float dist_m) {
|
||||
|
||||
// avoid sticking too close to walls (unlikely)
|
||||
static K::NormalDistribution avoidWalls(0.0, 0.3);
|
||||
static K::NormalDistribution avoidWalls(0.0, 0.4);
|
||||
|
||||
// favour walking near walls (likely)
|
||||
static K::NormalDistribution sticToWalls(0.9, 0.5);
|
||||
@@ -203,10 +204,9 @@ public:
|
||||
if (dist_m > 2.0) {dist_m = 2.0;}
|
||||
|
||||
// overall importance
|
||||
nSrc.imp *= 1.0
|
||||
- avoidWalls.getProbability(dist_m) * 0.35 // avoid walls
|
||||
return - avoidWalls.getProbability(dist_m) * 0.30 // avoid walls
|
||||
+ sticToWalls.getProbability(dist_m) * 0.15 // walk near walls
|
||||
+ farAway.getProbability(dist_m) * 0.20 // walk in the middle
|
||||
+ farAway.getProbability(dist_m) * 0.15 // walk in the middle
|
||||
;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user