Skip to content

Commit

Permalink
Fix issue where a partial path search that's expected to create an in…
Browse files Browse the repository at this point in the history
…complete path would reject the search instead. Now the rejection shouldn't happen unless the path really should be rejected.
  • Loading branch information
marcushutchings committed Jan 2, 2024
1 parent c2faff3 commit 7ab9326
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 13 additions & 5 deletions rts/Sim/Path/QTPFS/PathSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void QTPFS::PathSearch::Initialize(
rejectPartialSearch = false;

fwdNodesSearched = 0;
bwdNodesSearched = 0;
}

void QTPFS::PathSearch::InitializeThread(SearchThreadData* threadData) {
Expand Down Expand Up @@ -437,13 +438,21 @@ bool QTPFS::PathSearch::ExecutePathSearch() {
RemoveOutdatedOpenNodesFromQueue(SearchThreadData::SEARCH_FORWARD);

// We're done with the forward path and we expect the reverse path to fail so stop it right there.
if ((*fwd.openNodes).empty() && expectIncompletePartialSearch)
searchThreadData->ResetQueue(SearchThreadData::SEARCH_BACKWARD);
if ((*fwd.openNodes).empty() && expectIncompletePartialSearch){
SetForwardSearchLimit();
// searchEarlyDrop = true;
// //bwd.tgtSearchNode = curSearchNode; - nearest node not saved currently.
// searchThreadData->ResetQueue(SearchThreadData::SEARCH_BACKWARD);
}
}

if (!(*bwd.openNodes).empty()) {
bwdNodesSearched++;
IterateNodes(SearchThreadData::SEARCH_BACKWARD);

if (bwdNodesSearched >= fwdNodeSearchLimit)
searchThreadData->ResetQueue(SearchThreadData::SEARCH_BACKWARD);

assert(curSearchNode->GetNeighborEdgeTransitionPoint().x != 0.f
|| curSearchNode->GetNeighborEdgeTransitionPoint().y != 0.f);

Expand Down Expand Up @@ -520,15 +529,15 @@ bool QTPFS::PathSearch::ExecutePathSearch() {
if (!isFullSearch) {
if (fwdStepIndex > bwdStepIndex){
rejectPartialSearch = true;
// LOG("%s: rejecting partial path.", __func__);
// LOG("%s: rejecting partial path 1 (search %x)", __func__, this->GetID());
return false;
}
}
} else {
// if the partial path could not connect the reverse path, then we need to reject.
if (fwdPathConnected && !bwdPathConnected) {
rejectPartialSearch = true;
// LOG("%s: rejecting partial path.", __func__);
// LOG("%s: rejecting partial path 2 (search %x)", __func__, this->GetID());
return false;
}
}
Expand Down Expand Up @@ -584,7 +593,6 @@ void QTPFS::PathSearch::ResetState(SearchNode* node, struct DirectionalSearchDat
hCosts[i] = 0.0f;
}

// searchThreadData->ResetQueue();
(*searchData.openNodes).emplace(node->GetIndex(), 0.f);
}

Expand Down
1 change: 1 addition & 0 deletions rts/Sim/Path/QTPFS/PathSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ namespace QTPFS {
int fwdNodeSearchLimit = 0;

size_t fwdNodesSearched = 0;
size_t bwdNodesSearched = 0;

bool haveFullPath;
bool havePartPath;
Expand Down

0 comments on commit 7ab9326

Please sign in to comment.