Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions AStarDLL/Traveler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,38 @@ void Traveler::onArrival(bool isAtZeroSpeed)
double atTravelDist = updateLocation(true);
updateSpeedMarkers();
cullExpiredAllocations();

if (activeState == Active && !isNavigatingAroundDeadlock && destNode && objectexists(te->activetask)) {
Task* task = te->activetask->objectAs(Task);
treenode tsNode = te->activetask->up;
Task* nextTask = (objectexists(tsNode) && te->activetask->rank < content(tsNode))
? rank(tsNode, te->activetask->rank + 1)->objectAs(Task) : nullptr;
bool isTravelHome = task->type == TASKTYPE_TRAVEL
Comment thread
Shivi-lab marked this conversation as resolved.
&& nextTask
&& nextTask->type == TASKTYPE_DELAY
&& nextTask->var1 == 0.0;
if (isTravelHome) {
Vec3 teLoc = te->getLocation(0.5, 0.5, 0).project(te->holder->up, model());
double threshold = objectexists(gettenetnode(te->holder))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If picklist tolerance changes in FlexSim content files, A* corrective behavior can drift unless manually updated.
Please centralize threshold computation in one shared function used by both picklist generation/runtime and A* corrective logic.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also agreed the formula is duplicated from the picklist. Full centralization would need a shared FlexScript/C++ API and picklist changes, which is more than this bugfix should carry. Happy to open a follow-up for a shared threshold helper if you think that should be prioritized.

? 0.5 * xsize(te->holder)
: xsize(te->holder) + 0.2 * std::max(xsize(destNode), ysize(destNode));
double approachDist = (destLoc - teLoc).magnitude;
if (distancetotravel(te->holder, destNode) > threshold && approachDist > navigator->minNodeSize.x * 0.001) {
TravelPath finalPath;
Cell curCell = navigator->getCell(teLoc);
AStarPathEntry startEntry(curCell, -1);
startEntry.modelLoc = teLoc;
startEntry.atTravelDist = atTravelDist;
finalPath.push_back(startEntry);
AStarPathEntry destEntry(curCell, -1);
destEntry.modelLoc = destLoc;
finalPath.push_back(destEntry);
Comment thread
Shivi-lab marked this conversation as resolved.
finalPath.startZRot = te->b_spatialrz;
navigatePath(std::move(finalPath));
return;
}
}
}

if (isAtZeroSpeed) {
finalizeAtLocation(atTravelDist);
Expand Down