mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
followobject position caching
re-use the position of an object we're following (within reason) so we're not constantly regenning a path.
This commit is contained in:
parent
86e0e67496
commit
f97dced4a7
2 changed files with 5 additions and 0 deletions
|
|
@ -831,11 +831,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,6 +122,7 @@ 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)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue