mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[11912] Use mmaps for MovementGenerators
This commit is contained in:
parent
e738c27714
commit
2f0ed05566
15 changed files with 130 additions and 744 deletions
|
|
@ -25,8 +25,6 @@
|
|||
#include "movement/MoveSplineInit.h"
|
||||
#include "movement/MoveSpline.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
//-----------------------------------------------//
|
||||
template<class T, typename D>
|
||||
void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T &owner)
|
||||
|
|
@ -75,13 +73,22 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T &owner)
|
|||
return;
|
||||
*/
|
||||
|
||||
if(!i_path)
|
||||
i_path = new PathFinder(&owner);
|
||||
|
||||
// allow pets following their master to cheat while generating paths
|
||||
bool forceDest = (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->IsPet()
|
||||
&& owner.hasUnitState(UNIT_STAT_FOLLOW));
|
||||
i_path->calculate(x, y, z, forceDest);
|
||||
if(i_path->getPathType() & PATHFIND_NOPATH)
|
||||
return;
|
||||
|
||||
D::_addUnitStateMove(owner);
|
||||
i_targetReached = false;
|
||||
i_recalculateTravel = false;
|
||||
|
||||
Movement::MoveSplineInit init(owner);
|
||||
init.MoveTo(x,y,z);
|
||||
init.MovebyPath(i_path->getPath());
|
||||
init.SetWalk(((D*)this)->EnableWalking());
|
||||
init.Launch();
|
||||
}
|
||||
|
|
@ -145,13 +152,19 @@ bool TargetedMovementGeneratorMedium<T,D>::Update(T &owner, const uint32 & time_
|
|||
i_recheckDistance.Update(time_diff);
|
||||
if (i_recheckDistance.Passed())
|
||||
{
|
||||
i_recheckDistance.Reset(50);
|
||||
i_recheckDistance.Reset(100);
|
||||
|
||||
//More distance let have better performance, less distance let have more sensitive reaction at target move.
|
||||
float allowed_dist = i_target->GetObjectBoundingRadius() + owner.GetObjectBoundingRadius()
|
||||
+ sWorld.getConfig(CONFIG_FLOAT_RATE_TARGET_POS_RECALCULATION_RANGE);
|
||||
float dist = (owner.movespline->FinalDestination() -
|
||||
G3D::Vector3(i_target->GetPositionX(),i_target->GetPositionY(),i_target->GetPositionZ())).squaredLength();
|
||||
if (dist >= allowed_dist * allowed_dist)
|
||||
float allowed_dist = owner.GetObjectBoundingRadius() + sWorld.getConfig(CONFIG_FLOAT_RATE_TARGET_POS_RECALCULATION_RANGE);
|
||||
G3D::Vector3 dest = owner.movespline->FinalDestination();
|
||||
|
||||
bool targetMoved = false;
|
||||
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->CanFly())
|
||||
targetMoved = !i_target->IsWithinDist3d(dest.x, dest.y, dest.z, allowed_dist);
|
||||
else
|
||||
targetMoved = !i_target->IsWithinDist2d(dest.x, dest.y, allowed_dist);
|
||||
|
||||
if (targetMoved)
|
||||
_setTargetLocation(owner);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue