Remove not too useful angle calculation
Fix a bug in reverse position returned
This commit is contained in:
parent
f83407f661
commit
c66df6082d
@ -212,7 +212,6 @@ Vec3 SoccerAI::determineBallAimingPosition()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_chasing_ball = true;
|
|
||||||
const Vec3& ball_aim_pos = m_world->getBallAimPosition(m_opp_team);
|
const Vec3& ball_aim_pos = m_world->getBallAimPosition(m_opp_team);
|
||||||
const Vec3& orig_pos = m_world->getBallPosition();
|
const Vec3& orig_pos = m_world->getBallPosition();
|
||||||
|
|
||||||
@ -261,23 +260,11 @@ Vec3 SoccerAI::determineBallAimingPosition()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_chasing_ball = true;
|
||||||
// Check if reached aim point, which is behind aiming position and
|
// Check if reached aim point, which is behind aiming position and
|
||||||
// in front of the ball, if so use another aiming method
|
// in front of the ball, if so use another aiming method
|
||||||
if (aim_lc.z() < 0 && ball_lc.z() > 0)
|
if (aim_lc.z() < 0 && ball_lc.z() > 0)
|
||||||
{
|
{
|
||||||
// Find the angle between the ball to kart and the aim position
|
|
||||||
// to kart, if it's not almost 180 or 0 degree, we need to
|
|
||||||
// apply brake
|
|
||||||
const float c = sqrtf(pow(ball_lc.z() - aim_lc.z(), 2) +
|
|
||||||
pow(ball_lc.x() - aim_lc.x(), 2));
|
|
||||||
const float angle = findAngleFrom3Edges(aim_lc.length_2d(),
|
|
||||||
ball_lc.length_2d(), c);
|
|
||||||
|
|
||||||
if (angle > 1 && angle < 179)
|
|
||||||
{
|
|
||||||
m_force_brake = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the behind version of aim position, allow pushing to
|
// Return the behind version of aim position, allow pushing to
|
||||||
// ball towards the it
|
// ball towards the it
|
||||||
return m_world->getBallAimPosition(m_opp_team, true/*reverse*/);
|
return m_world->getBallAimPosition(m_opp_team, true/*reverse*/);
|
||||||
|
@ -69,7 +69,7 @@ private:
|
|||||||
virtual bool forceBraking() OVERRIDE
|
virtual bool forceBraking() OVERRIDE
|
||||||
{ return m_avoiding_banana || m_force_brake; }
|
{ return m_avoiding_banana || m_force_brake; }
|
||||||
virtual bool ignorePathFinding() OVERRIDE
|
virtual bool ignorePathFinding() OVERRIDE
|
||||||
{ return m_chasing_ball; }
|
{ return m_overtake_ball || m_chasing_ball; }
|
||||||
public:
|
public:
|
||||||
SoccerAI(AbstractKart *kart);
|
SoccerAI(AbstractKart *kart);
|
||||||
~SoccerAI();
|
~SoccerAI();
|
||||||
|
@ -202,7 +202,7 @@ private:
|
|||||||
// If it's likely to goal already, aim the ball straight behind
|
// If it's likely to goal already, aim the ball straight behind
|
||||||
// should do the job
|
// should do the job
|
||||||
if (isApproachingGoal(team))
|
if (isApproachingGoal(team))
|
||||||
return m_trans(Vec3(0, 0, -m_radius*2));
|
return m_trans(Vec3(0, 0, reverse ? m_radius*2 : -m_radius*2));
|
||||||
|
|
||||||
// Otherwise do the below:
|
// Otherwise do the below:
|
||||||
// This is done by using Pythagorean Theorem and solving the
|
// This is done by using Pythagorean Theorem and solving the
|
||||||
|
Loading…
Reference in New Issue
Block a user