mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Merge pull request #1357 from Azaezel/ChaseCache
followobject position caching
This commit is contained in:
commit
807aad826f
2 changed files with 6 additions and 0 deletions
|
|
@ -827,11 +827,15 @@ void AIPlayer::followObject(SceneObject *obj, F32 radius)
|
||||||
if(!isServerObject())
|
if(!isServerObject())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ((mFollowData.lastPos - obj->getPosition()).len()<mMoveTolerance)
|
||||||
|
return;
|
||||||
|
|
||||||
if(setPathDestination(obj->getPosition()))
|
if(setPathDestination(obj->getPosition()))
|
||||||
{
|
{
|
||||||
clearCover();
|
clearCover();
|
||||||
mFollowData.object = obj;
|
mFollowData.object = obj;
|
||||||
mFollowData.radius = radius;
|
mFollowData.radius = radius;
|
||||||
|
mFollowData.lastPos = obj->getPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -122,10 +122,12 @@ private:
|
||||||
SimObjectPtr<SceneObject> object;
|
SimObjectPtr<SceneObject> object;
|
||||||
/// Distance at whcih to follow.
|
/// Distance at whcih to follow.
|
||||||
F32 radius;
|
F32 radius;
|
||||||
|
Point3F lastPos;
|
||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
FollowData() : object(NULL)
|
FollowData() : object(NULL)
|
||||||
{
|
{
|
||||||
radius = 5.0f;
|
radius = 5.0f;
|
||||||
|
lastPos = Point3F::Zero;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue