mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-25 02:00:54 +00:00
Use distSqTo instead of distTo
This commit is contained in:
parent
9d3bb1c76b
commit
576e508860
2 changed files with 16 additions and 12 deletions
|
@ -310,9 +310,9 @@ void CWanderFaunaProfile::updateProfile(uint ticksSinceLastUpdate)
|
||||||
CFollowPathContext fpcWanderFaunaProfileUpdate("WanderFaunaProfileUpdate");
|
CFollowPathContext fpcWanderFaunaProfileUpdate("WanderFaunaProfileUpdate");
|
||||||
|
|
||||||
// calculate distance from bot position to magnet point (used in all the different processes)
|
// calculate distance from bot position to magnet point (used in all the different processes)
|
||||||
_magnetDist=_Bot->pos().distTo(_Bot->spawnGrp().magnetPos());
|
_magnetDistSq=_Bot->pos().distSqTo(_Bot->spawnGrp().magnetPos());
|
||||||
|
double grpMagnetRadiusFar=_Bot->spawnGrp().magnetRadiusFar();
|
||||||
if (_magnetDist>_Bot->spawnGrp().magnetRadiusFar())
|
if (_magnetDistSq>(grpMagnetRadiusFar*grpMagnetRadiusFar))
|
||||||
{
|
{
|
||||||
_Bot->setMode( MBEHAV::NORMAL );
|
_Bot->setMode( MBEHAV::NORMAL );
|
||||||
|
|
||||||
|
@ -405,11 +405,12 @@ void CGrazeFaunaProfile::updateProfile(uint ticksSinceLastUpdate)
|
||||||
CFollowPathContext fpcGrazeFaunaProfileUpdate("GrazeFaunaProfileUpdate");
|
CFollowPathContext fpcGrazeFaunaProfileUpdate("GrazeFaunaProfileUpdate");
|
||||||
|
|
||||||
// calculate distance from bot position to magnet point (used in all the different processes)
|
// calculate distance from bot position to magnet point (used in all the different processes)
|
||||||
_magnetDist=_Bot->pos().distTo(_Bot->spawnGrp().magnetPos());
|
_magnetDistSq=_Bot->pos().distSqTo(_Bot->spawnGrp().magnetPos());
|
||||||
|
|
||||||
if (!_ArrivedInZone)
|
if (!_ArrivedInZone)
|
||||||
{
|
{
|
||||||
if (_magnetDist>_Bot->spawnGrp().magnetRadiusFar())
|
float grpMagnetRadiusFar=_Bot->spawnGrp().magnetRadiusFar();
|
||||||
|
if (_magnetDistSq>(grpMagnetRadiusFar*grpMagnetRadiusFar))
|
||||||
{
|
{
|
||||||
_Bot->setMode( MBEHAV::NORMAL );
|
_Bot->setMode( MBEHAV::NORMAL );
|
||||||
|
|
||||||
|
@ -501,7 +502,8 @@ void CGrazeFaunaProfile::updateProfile(uint ticksSinceLastUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
// && _state==0 ) // means wait in movementmagnet.
|
// && _state==0 ) // means wait in movementmagnet.
|
||||||
if ( _magnetDist<=_Bot->spawnGrp().magnetRadiusNear()
|
const float grpMagnetRadiusNear=_Bot->spawnGrp().magnetRadiusNear();
|
||||||
|
if ( _magnetDistSq<=(grpMagnetRadiusNear*grpMagnetRadiusNear)
|
||||||
&& _MovementMagnet->getMovementType()==CMovementMagnet::Movement_Anim)
|
&& _MovementMagnet->getMovementType()==CMovementMagnet::Movement_Anim)
|
||||||
{
|
{
|
||||||
if (_Bot->getPersistent().grp().getType()==AITYPES::FaunaTypePredator)
|
if (_Bot->getPersistent().grp().getType()==AITYPES::FaunaTypePredator)
|
||||||
|
@ -564,11 +566,12 @@ void CRestFaunaProfile::updateProfile(uint ticksSinceLastUpdate)
|
||||||
CFollowPathContext fpcRestFaunaProfileUpdate("RestFaunaProfileUpdate");
|
CFollowPathContext fpcRestFaunaProfileUpdate("RestFaunaProfileUpdate");
|
||||||
|
|
||||||
// calculate distance from bot position to magnet point (used in all the different processes)
|
// calculate distance from bot position to magnet point (used in all the different processes)
|
||||||
_magnetDist=_Bot->pos().distTo(_Bot->spawnGrp().magnetPos());
|
_magnetDistSq=_Bot->pos().distSqTo(_Bot->spawnGrp().magnetPos());
|
||||||
|
|
||||||
if (!_ArrivedInZone)
|
if (!_ArrivedInZone)
|
||||||
{
|
{
|
||||||
if (_magnetDist>_Bot->spawnGrp().magnetRadiusFar())
|
float grpMagnetRadiusFar=_Bot->spawnGrp().magnetRadiusFar();
|
||||||
|
if (_magnetDistSq>(grpMagnetRadiusFar*grpMagnetRadiusFar))
|
||||||
{
|
{
|
||||||
if (!_OutOfMagnet)
|
if (!_OutOfMagnet)
|
||||||
{
|
{
|
||||||
|
@ -656,7 +659,8 @@ void CRestFaunaProfile::updateProfile(uint ticksSinceLastUpdate)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( _magnetDist<=_Bot->spawnGrp().magnetRadiusNear()
|
const float grpMagnetRadiusNear=_Bot->spawnGrp().magnetRadiusNear();
|
||||||
|
if ( _magnetDistSq<=(grpMagnetRadiusNear*grpMagnetRadiusNear)
|
||||||
&& _MovementMagnet->getMovementType()==CMovementMagnet::Movement_Anim)
|
&& _MovementMagnet->getMovementType()==CMovementMagnet::Movement_Anim)
|
||||||
{
|
{
|
||||||
_Bot->setMode(MBEHAV::REST);
|
_Bot->setMode(MBEHAV::REST);
|
||||||
|
|
|
@ -137,7 +137,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
|
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
|
||||||
CSpawnBotFauna* _Bot;
|
CSpawnBotFauna* _Bot;
|
||||||
double _magnetDist; ///< distance from bot to his magnet at last move
|
double _magnetDistSq; ///< square distance from bot to his magnet at last move
|
||||||
static CFaunaProfileFloodLogger _FloodLogger;
|
static CFaunaProfileFloodLogger _FloodLogger;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ private:
|
||||||
CAITimer _CycleTimer;
|
CAITimer _CycleTimer;
|
||||||
uint _CycleTimerBaseTime;
|
uint _CycleTimerBaseTime;
|
||||||
bool _ArrivedInZone;
|
bool _ArrivedInZone;
|
||||||
double _magnetDist; ///< distance from bot to his magnet at last move
|
double _magnetDistSq; ///< square distance from bot to his magnet at last move
|
||||||
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
|
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
|
||||||
static CFaunaProfileFloodLogger _FloodLogger;
|
static CFaunaProfileFloodLogger _FloodLogger;
|
||||||
};
|
};
|
||||||
|
@ -196,7 +196,7 @@ private:
|
||||||
CAITimer _CycleTimer;
|
CAITimer _CycleTimer;
|
||||||
uint _CycleTimerBaseTime;
|
uint _CycleTimerBaseTime;
|
||||||
bool _ArrivedInZone;
|
bool _ArrivedInZone;
|
||||||
double _magnetDist; // distance from bot to his magnet at last move
|
double _magnetDistSq; // square distance from bot to his magnet at last move
|
||||||
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
|
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
|
||||||
static CFaunaProfileFloodLogger _FloodLogger;
|
static CFaunaProfileFloodLogger _FloodLogger;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue