added very simple particle-trap detection
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "../../Grid.h"
|
||||
#include "../../../math/DrawList.h"
|
||||
#include "modules/WalkModule.h"
|
||||
#include "../../../math/Distributions.h"
|
||||
|
||||
/**
|
||||
* modular grid-walker that takes various sub-components to determine
|
||||
@@ -27,10 +28,10 @@ public:
|
||||
}
|
||||
|
||||
/** perform the walk based on the configured setup */
|
||||
WalkState getDestination(Grid<Node>& grid, const WalkState& _startState, float dist_m, double& probability) {
|
||||
WalkState getDestination(Grid<Node>& grid, const WalkState& _startState, const float _dist_m, double& probability) {
|
||||
|
||||
Assert::isTrue(dist_m >= 0, "walk distance must not be negative!");
|
||||
Assert::isTrue(dist_m < 10.0, "walking more than 10.0 meters at once does not make sense!");
|
||||
Assert::isTrue(_dist_m >= 0, "walk distance must not be negative!");
|
||||
Assert::isTrue(_dist_m < 10.0, "walking more than 10.0 meters at once does not make sense!");
|
||||
|
||||
// keep the starting state for reference
|
||||
//const WalkState startState = _startState;
|
||||
@@ -50,7 +51,7 @@ public:
|
||||
|
||||
|
||||
// add the previous walked-distance-error to the desired distance (is usually negative, thus dist_m is reduced)
|
||||
dist_m += _startState.distance.error_m;
|
||||
float dist_m = _dist_m + _startState.distance.error_m;
|
||||
|
||||
probability = 1.0;
|
||||
int cnt = 0;
|
||||
@@ -90,7 +91,7 @@ public:
|
||||
}
|
||||
|
||||
//if (cnt != 0) {probability /= cnt;} else {probability = 1.0;}
|
||||
probability = curNode->getWalkImportance();
|
||||
probability = curNode->getWalkImportance() < 0.4f ? (1e-5) : (1.0); // "kill" particles that walk near walls (most probably trapped ones)
|
||||
|
||||
// update after
|
||||
updateAfter(currentState, *startNode, *curNode);
|
||||
|
||||
Reference in New Issue
Block a user