Quellcode durchsuchen

followobject position caching
re-use the position of an object we're following (within reason) so we're not constantly regenning a path.

Azaezel vor 10 Jahren
Ursprung
Commit
f97dced4a7
2 geänderte Dateien mit 5 neuen und 0 gelöschten Zeilen
  1. 4 0
      Engine/source/T3D/aiPlayer.cpp
  2. 1 0
      Engine/source/T3D/aiPlayer.h

+ 4 - 0
Engine/source/T3D/aiPlayer.cpp

@@ -831,11 +831,15 @@ void AIPlayer::followObject(SceneObject *obj, F32 radius)
    if(!isServerObject())
       return;
 
+   if ((mFollowData.lastPos - obj->getPosition()).len()<mMoveTolerance)
+      return;
+
    if(setPathDestination(obj->getPosition()))
    {
       clearCover();
       mFollowData.object = obj;
       mFollowData.radius = radius;
+      mFollowData.lastPos = obj->getPosition();
    }
 }
 

+ 1 - 0
Engine/source/T3D/aiPlayer.h

@@ -122,6 +122,7 @@ private:
       SimObjectPtr<SceneObject> object;
       /// Distance at whcih to follow.
       F32 radius;
+      Point3F lastPos;
       /// Default constructor.
       FollowData() : object(NULL)
       {