Pārlūkot izejas kodu

navigation: setPathdestination now takes a replace bool to preserve the goal
also killed a few now extraneous clearfollow calls

AzaezelX 5 mēneši atpakaļ
vecāks
revīzija
f84bf058c9

+ 4 - 7
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);
       getCtrl()->setGoal(pos, getCtrl()->mControllerData->mMoveTolerance);
 
 
    if (!mNavMesh)
    if (!mNavMesh)
       updateNavMesh();
       updateNavMesh();
+
    // If we can't find a mesh, just move regularly.
    // If we can't find a mesh, just move regularly.
    if (!mNavMesh)
    if (!mNavMesh)
    {
    {
@@ -213,7 +212,6 @@ bool AINavigation::setPathDestination(const Point3F& pos)
       // Clear any current path we might have.
       // Clear any current path we might have.
       clearPath();
       clearPath();
       getCtrl()->clearCover();
       getCtrl()->clearCover();
-      clearFollow();
       // Store new path.
       // Store new path.
       mPathData.path = path;
       mPathData.path = path;
       mPathData.owned = true;
       mPathData.owned = true;
@@ -260,7 +258,6 @@ void AINavigation::followNavPath(NavPath* path)
    // Get rid of our current path.
    // Get rid of our current path.
    clearPath();
    clearPath();
    getCtrl()->clearCover();
    getCtrl()->clearCover();
-   clearFollow();
 
 
    // Follow new path.
    // Follow new path.
    mPathData.path = path;
    mPathData.path = path;
@@ -316,7 +313,7 @@ DefineEngineMethod(AIController, setPathDestination, bool, (Point3F goal), ,
    "@see getPathDestination()\n"
    "@see getPathDestination()\n"
    "@see setMoveDestination()\n")
    "@see setMoveDestination()\n")
 {
 {
-   return object->getNav()->setPathDestination(goal);
+   return object->getNav()->setPathDestination(goal,true);
 }
 }
 
 
 
 

+ 1 - 1
Engine/source/T3D/AI/AINavigation.h

@@ -82,7 +82,7 @@ struct AINavigation
 
 
    /// Clear out the current path.
    /// Clear out the current path.
    void clearPath();
    void clearPath();
-   bool setPathDestination(const Point3F& pos);
+   bool setPathDestination(const Point3F& pos, bool replace = false);
    Point3F getPathDestination() const;
    Point3F getPathDestination() const;
    void repath();
    void repath();
 
 

+ 1 - 1
Engine/source/navigation/guiNavEditorCtrl.cpp

@@ -418,7 +418,7 @@ void GuiNavEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
             if (po->getAIController())
             if (po->getAIController())
             {
             {
                if (po->getAIController()->mControllerData)
                if (po->getAIController()->mControllerData)
-                  po->getAIController()->getNav()->setPathDestination(ri.point);
+                  po->getAIController()->getNav()->setPathDestination(ri.point,true);
             }
             }
          }
          }
       }
       }