From 4a0442f511ccd89cb97ffd73b87582116d3f1012 Mon Sep 17 00:00:00 2001 From: kazu Date: Thu, 29 Sep 2016 21:39:19 +0200 Subject: [PATCH] added very simple particle-trap detection --- grid/walk/v2/GridWalker.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/grid/walk/v2/GridWalker.h b/grid/walk/v2/GridWalker.h index a737daf..d266433 100644 --- a/grid/walk/v2/GridWalker.h +++ b/grid/walk/v2/GridWalker.h @@ -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& grid, const WalkState& _startState, float dist_m, double& probability) { + WalkState getDestination(Grid& 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);