From f84bf058c98b968ca4b5e7fa50e5fc31e629eed5 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 17 Apr 2025 17:51:31 -0500 Subject: [PATCH] navigation: setPathdestination now takes a replace bool to preserve the goal also killed a few now extraneous clearfollow calls --- Engine/source/T3D/AI/AINavigation.cpp | 11 ++++------- Engine/source/T3D/AI/AINavigation.h | 2 +- Engine/source/navigation/guiNavEditorCtrl.cpp | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Engine/source/T3D/AI/AINavigation.cpp b/Engine/source/T3D/AI/AINavigation.cpp index 0eb5e48d4..57d2be27a 100644 --- a/Engine/source/T3D/AI/AINavigation.cpp +++ b/Engine/source/T3D/AI/AINavigation.cpp @@ -174,15 +174,14 @@ void AINavigation::onReachDestination() } } -bool AINavigation::setPathDestination(const Point3F& pos) +bool AINavigation::setPathDestination(const Point3F& pos, bool replace) { - AIGoal* curgoal = getCtrl()->getGoal(); - - if (!curgoal || !curgoal->mObj.isValid()) + if (replace) getCtrl()->setGoal(pos, getCtrl()->mControllerData->mMoveTolerance); if (!mNavMesh) updateNavMesh(); + // If we can't find a mesh, just move regularly. if (!mNavMesh) { @@ -213,7 +212,6 @@ bool AINavigation::setPathDestination(const Point3F& pos) // Clear any current path we might have. clearPath(); getCtrl()->clearCover(); - clearFollow(); // Store new path. mPathData.path = path; mPathData.owned = true; @@ -260,7 +258,6 @@ void AINavigation::followNavPath(NavPath* path) // Get rid of our current path. clearPath(); getCtrl()->clearCover(); - clearFollow(); // Follow new path. mPathData.path = path; @@ -316,7 +313,7 @@ DefineEngineMethod(AIController, setPathDestination, bool, (Point3F goal), , "@see getPathDestination()\n" "@see setMoveDestination()\n") { - return object->getNav()->setPathDestination(goal); + return object->getNav()->setPathDestination(goal,true); } diff --git a/Engine/source/T3D/AI/AINavigation.h b/Engine/source/T3D/AI/AINavigation.h index 2efcbe536..ad9ae6a70 100644 --- a/Engine/source/T3D/AI/AINavigation.h +++ b/Engine/source/T3D/AI/AINavigation.h @@ -82,7 +82,7 @@ struct AINavigation /// Clear out the current path. void clearPath(); - bool setPathDestination(const Point3F& pos); + bool setPathDestination(const Point3F& pos, bool replace = false); Point3F getPathDestination() const; void repath(); diff --git a/Engine/source/navigation/guiNavEditorCtrl.cpp b/Engine/source/navigation/guiNavEditorCtrl.cpp index b67272aff..3237816bd 100644 --- a/Engine/source/navigation/guiNavEditorCtrl.cpp +++ b/Engine/source/navigation/guiNavEditorCtrl.cpp @@ -418,7 +418,7 @@ void GuiNavEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event) if (po->getAIController()) { if (po->getAIController()->mControllerData) - po->getAIController()->getNav()->setPathDestination(ri.point); + po->getAIController()->getNav()->setPathDestination(ri.point,true); } } }