mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[11720] Implement spline movement subsystem
Spline movement controls movements of server-side controlled units (monster movement, taxi movement, etc). Proper implementation of effects such as charge, jump, cyclic movement will rely on it. However, need improve our states system before. Technical changes: 1. Added linear, catmullrom and bezier3 splines which based on client's algorthims. They can be reused for proper transport position interpolation. 2. Precission increased. There are no more position desync issues since client's position calculation formulas used. 3. Now possible to move by paths with multiple points, send whole path to client.
This commit is contained in:
parent
e302fce513
commit
9d566398ad
52 changed files with 2471 additions and 1203 deletions
|
|
@ -20,8 +20,9 @@
|
|||
#include "TargetedMovementGenerator.h"
|
||||
#include "Errors.h"
|
||||
#include "Creature.h"
|
||||
#include "DestinationHolderImp.h"
|
||||
#include "World.h"
|
||||
#include "movement/MoveSplineInit.h"
|
||||
#include "movement/MoveSpline.h"
|
||||
|
||||
#define SMALL_ALPHA 0.05f
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T &owner)
|
|||
// prevent redundant micro-movement for pets, other followers.
|
||||
if (i_offset && i_target->IsWithinDistInMap(&owner,2*i_offset))
|
||||
{
|
||||
if (i_destinationHolder.HasDestination())
|
||||
if (!owner.movespline->Finalized())
|
||||
return;
|
||||
|
||||
owner.GetPosition(x, y, z);
|
||||
|
|
@ -74,14 +75,15 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T &owner)
|
|||
if( i_destinationHolder.HasDestination() && i_destinationHolder.GetDestinationDiff(x,y,z) < bothObjectSize )
|
||||
return;
|
||||
*/
|
||||
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->CanFly())
|
||||
((Creature&)owner).AddSplineFlag(SPLINEFLAG_FLYING);
|
||||
|
||||
|
||||
D::_addUnitStateMove(owner);
|
||||
i_targetReached = false;
|
||||
i_recalculateTravel = false;
|
||||
D::_addUnitStateMove(owner);
|
||||
Traveller<T> traveller(owner);
|
||||
i_destinationHolder.SetDestination(traveller, x, y, z);
|
||||
|
||||
Movement::MoveSplineInit init(owner);
|
||||
init.MoveTo(x,y,z);
|
||||
init.Launch();
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
@ -140,21 +142,19 @@ bool TargetedMovementGeneratorMedium<T,D>::Update(T &owner, const uint32 & time_
|
|||
return true;
|
||||
}
|
||||
|
||||
Traveller<T> traveller(owner);
|
||||
if (i_destinationHolder.UpdateTraveller(traveller, time_diff, false))
|
||||
i_recheckDistance.Update(time_diff);
|
||||
if (i_recheckDistance.Passed())
|
||||
{
|
||||
if (!IsActive(owner)) // force stop processing (movement can move out active zone with cleanup movegens list)
|
||||
return true;
|
||||
|
||||
i_destinationHolder.ResetUpdate(50);
|
||||
//More distance let have better performance, less distance let have more sensitive reaction at target move.
|
||||
float dist = i_target->GetObjectBoundingRadius() + owner.GetObjectBoundingRadius()
|
||||
float allowed_dist = i_target->GetObjectBoundingRadius() + owner.GetObjectBoundingRadius()
|
||||
+ sWorld.getConfig(CONFIG_FLOAT_RATE_TARGET_POS_RECALCULATION_RANGE);
|
||||
if (i_destinationHolder.GetDistance3dFromDestSq(*i_target.getTarget()) > dist * dist)
|
||||
float dist = (owner.movespline->FinalDestination() -
|
||||
G3D::Vector3(i_target->GetPositionX(),i_target->GetPositionY(),i_target->GetPositionZ())).squaredLength();
|
||||
if (dist >= allowed_dist * allowed_dist)
|
||||
_setTargetLocation(owner);
|
||||
}
|
||||
|
||||
if (i_destinationHolder.HasArrived())
|
||||
if (owner.movespline->Finalized())
|
||||
{
|
||||
if (i_angle == 0.f && !owner.HasInArc(0.01f, i_target.getTarget()))
|
||||
owner.SetInFront(i_target.getTarget());
|
||||
|
|
@ -191,12 +191,8 @@ void ChaseMovementGenerator<Player>::Initialize(Player &owner)
|
|||
template<>
|
||||
void ChaseMovementGenerator<Creature>::Initialize(Creature &owner)
|
||||
{
|
||||
owner.SetWalk(false);
|
||||
owner.addUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE);
|
||||
owner.RemoveSplineFlag(SPLINEFLAG_WALKMODE);
|
||||
|
||||
if (((Creature*)&owner)->CanFly())
|
||||
owner.AddSplineFlag(SPLINEFLAG_FLYING);
|
||||
|
||||
_setTargetLocation(owner);
|
||||
}
|
||||
|
||||
|
|
@ -264,10 +260,6 @@ void FollowMovementGenerator<Creature>::Initialize(Creature &owner)
|
|||
owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||
_updateWalkMode(owner);
|
||||
_updateSpeed(owner);
|
||||
|
||||
if (((Creature*)&owner)->CanFly())
|
||||
owner.AddSplineFlag(SPLINEFLAG_FLYING);
|
||||
|
||||
_setTargetLocation(owner);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue