Skip to content

Instantly share code, notes, and snippets.

@IQAndreas
Last active November 14, 2016 18:52
Show Gist options
  • Save IQAndreas/5036465 to your computer and use it in GitHub Desktop.
Save IQAndreas/5036465 to your computer and use it in GitHub Desktop.
Their bracket placement and indentation is like some sick, twisted joke meant to confuse and torment me. (from http://opensteer.svn.sourceforge.net/viewvc/opensteer/trunk/plugins/Soccer.cpp?revision=181&view=markup ) It looks like the only problem is the "else" on line 14. Wrong, keep looking and it will start hurting your eyes.
if(collisionAvoidance != Vec3::zero)
applySteeringForce (collisionAvoidance, elapsedTime);
else
{
float distHomeToBall = Vec3::distance (m_home, m_Ball->position());
if( distHomeToBall < 12.0f)
{
// go for ball if I'm on the 'right' side of the ball
if( b_ImTeamA ? position().x > m_Ball->position().x : position().x < m_Ball->position().x)
{
Vec3 seekTarget = xxxsteerForSeek(m_Ball->position());
applySteeringForce (seekTarget, elapsedTime);
}
else
{
if( distHomeToBall < 12.0f)
{
float Z = m_Ball->position().z - position().z > 0 ? -1.0f : 1.0f;
Vec3 behindBall = m_Ball->position() + (b_ImTeamA ? Vec3(2.0f,0.0f,Z) : Vec3(-2.0f,0.0f,Z));
Vec3 behindBallForce = xxxsteerForSeek(behindBall);
annotationLine (position(), behindBall , Color(0.0f,1.0f,0.0f));
Vec3 evadeTarget = xxxsteerForFlee(m_Ball->position());
applySteeringForce (behindBallForce*10.0f + evadeTarget, elapsedTime);
}
}
}
else // Go home
{
Vec3 seekTarget = xxxsteerForSeek(m_home);
Vec3 seekHome = xxxsteerForSeek(m_home);
applySteeringForce (seekTarget+seekHome, elapsedTime);
}
}
@cwreynolds
Copy link

For what its worth, the OpenSteer soccer demo was contributed user code. Not to say that the “official” OpenSteer code is perfect, and certainly not well-maintained.

Craig
http://www.red3d.com/cwr/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment