Changed: Try to implement better pos correct from gpms (using deceleration + acceleration)

--HG--
branch : compatibility-develop
hg/compatibility-develop
ulukyn@gmail.com 7 years ago
parent c440e9fc40
commit f7a3e6a4ee

@ -1406,7 +1406,7 @@ void impulseCorrectPos(NLMISC::CBitMemStream &impulse)
{ {
if (x == 0) // Get SpeedAdjustement if (x == 0) // Get SpeedAdjustement
{ {
UserEntity->setSpeedServerAdjust((float)y/1000.0f); UserEntity->setSpeedServerAdjust(-0.2f);
} }
else else
{ {

@ -144,6 +144,8 @@ CUserEntity::CUserEntity()
_FrontVelocity = 0.0f; _FrontVelocity = 0.0f;
_LateralVelocity = 0.0f; _LateralVelocity = 0.0f;
_SpeedServerAdjust = 1.0f;
// \todo GUIGUI : do it more generic. // \todo GUIGUI : do it more generic.
_First_Pos = false; _First_Pos = false;
@ -1205,7 +1207,11 @@ void CUserEntity::applyMotion(CEntityCL *target)
speed = CVectorD::Null; speed = CVectorD::Null;
} }
else else
{
speed = getVelocity()*_SpeedFactor.getValue(); speed = getVelocity()*_SpeedFactor.getValue();
_SpeedFactor.addFactorValue(0.005f);
}
// SPEED VECTOR NULL -> NO MOVE // SPEED VECTOR NULL -> NO MOVE
if(speed == CVectorD::Null) if(speed == CVectorD::Null)
return; return;
@ -1218,7 +1224,6 @@ void CUserEntity::applyMotion(CEntityCL *target)
// don't increase speed // don't increase speed
clamp(modif, 0.0, 1.0); clamp(modif, 0.0, 1.0);
speed *= modif; speed *= modif;
speed *= _SpeedServerAdjust;
// Move // Move
_HasMoved = true; _HasMoved = true;
_Primitive->move(speed, dynamicWI); _Primitive->move(speed, dynamicWI);
@ -1228,7 +1233,9 @@ void CUserEntity::applyMotion(CEntityCL *target)
// Third Person View // Third Person View
else else
{ {
speed *= _SpeedServerAdjust; double modif = (100.0f/(float)NetMngr.getMsPerTick());
clamp(modif, 0.0, 1.0);
speed *= modif;
speed += pos(); speed += pos();
sint64 x = (sint64)((sint32)(speed.x * 1000.0)); sint64 x = (sint64)((sint32)(speed.x * 1000.0));
sint64 y = (sint64)((sint32)(speed.y * 1000.0)); sint64 y = (sint64)((sint32)(speed.y * 1000.0));
@ -1246,8 +1253,7 @@ void CUserEntity::applyMotion(CEntityCL *target)
} }
} }
_SpeedServerAdjust += 0.05;
clamp(_SpeedServerAdjust, 0.8, 1.0);
}// applyMotion // }// applyMotion //
@ -3484,6 +3490,7 @@ void CUserEntity::light()
void CUserEntity::CSpeedFactor::init() void CUserEntity::CSpeedFactor::init()
{ {
_Value = 1.0f; // Default speed factor is 1. _Value = 1.0f; // Default speed factor is 1.
_ServerFactor = 1.0f;
CInterfaceManager *IM = CInterfaceManager::getInstance (); CInterfaceManager *IM = CInterfaceManager::getInstance ();
CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:SPEED_FACTOR", false); CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:SPEED_FACTOR", false);
if(pNodeLeaf) if(pNodeLeaf)

@ -297,7 +297,7 @@ public:
// get the velocity vector of the entity // get the velocity vector of the entity
NLMISC::CVector getVelocity() const; NLMISC::CVector getVelocity() const;
inline void setSpeedServerAdjust(float speed) {_SpeedServerAdjust = speed;} inline void setSpeedServerAdjust(float speed) {_SpeedFactor.addFactorValue(speed);}
/// Check if the mount is able to run, and force walking mode if not /// Check if the mount is able to run, and force walking mode if not
void checkMountAbleToRun(); void checkMountAbleToRun();
@ -499,13 +499,23 @@ protected:
/// Release /// Release
void release(); void release();
/// Return the speed factor. /// Return the speed factor.
float getValue() const {return _Value;} float getValue() const { return _Value * _ServerFactor; }
void setFactorValue(float value) {_ServerFactor = value;}
void addFactorValue(float value) {
_ServerFactor += value;
if (_ServerFactor > 1.0)
_ServerFactor = 1.0;
if (_ServerFactor < 0.1)
_ServerFactor = 0.1;
}
virtual void serial(class NLMISC::IStream &f) throw(NLMISC::EStream) {f.serial(_Value);} virtual void serial(class NLMISC::IStream &f) throw(NLMISC::EStream) {f.serial(_Value);}
protected: protected:
/// Method called when the ping message is back. /// Method called when the ping message is back.
virtual void update(NLMISC::ICDBNode* leaf); virtual void update(NLMISC::ICDBNode* leaf);
private: private:
float _Value; float _Value;
float _ServerFactor;
}; };
class CMountHunger class CMountHunger

Loading…
Cancel
Save