Core: Continued cleanup

If and for whitespaces.
This commit is contained in:
kaelima
2011-06-12 02:30:32 +02:00
parent da03bbbdab
commit b9e8694540
46 changed files with 219 additions and 222 deletions
+1 -1
View File
@@ -1520,7 +1520,7 @@ bool Position::HasInArc(float arc, const Position *obj) const
// move angle to range -pi ... +pi
angle = MapManager::NormalizeOrientation(angle);
if(angle > M_PI)
if (angle > M_PI)
angle -= 2.0f*M_PI;
float lborder = -1 * (arc/2.0f); // in range -pi..0
@@ -39,12 +39,12 @@ ObjectPosSelector::ObjectPosSelector(float x, float y, float size, float dist)
ObjectPosSelector::UsedPosList::value_type const* ObjectPosSelector::nextUsedPos(UsedPosType uptype)
{
UsedPosList::const_iterator itr = m_nextUsedPos[uptype];
if(itr!=m_UsedPosLists[uptype].end())
if (itr!=m_UsedPosLists[uptype].end())
++itr;
if(itr==m_UsedPosLists[uptype].end())
if (itr==m_UsedPosLists[uptype].end())
{
if(!m_UsedPosLists[~uptype].empty())
if (!m_UsedPosLists[~uptype].empty())
return &*m_UsedPosLists[~uptype].rbegin();
else
return NULL;
@@ -55,7 +55,7 @@ ObjectPosSelector::UsedPosList::value_type const* ObjectPosSelector::nextUsedPos
void ObjectPosSelector::AddUsedPos(float size, float angle, float dist)
{
if(angle>=0)
if (angle>=0)
m_UsedPosLists[USED_POS_PLUS].insert(UsedPosList::value_type(angle, UsedPos(1.0, size, dist)));
else
m_UsedPosLists[USED_POS_MINUS].insert(UsedPosList::value_type(-angle, UsedPos(-1.0, size, dist)));
@@ -75,9 +75,9 @@ void ObjectPosSelector::InitializeAngle()
bool ObjectPosSelector::FirstAngle(float& angle)
{
if(m_UsedPosLists[USED_POS_PLUS].empty() && !m_UsedPosLists[USED_POS_MINUS].empty() )
if (m_UsedPosLists[USED_POS_PLUS].empty() && !m_UsedPosLists[USED_POS_MINUS].empty() )
return NextAngleFor(*m_UsedPosLists[USED_POS_MINUS].begin(), 1.0, USED_POS_PLUS, angle);
else if(m_UsedPosLists[USED_POS_MINUS].empty() && !m_UsedPosLists[USED_POS_PLUS].empty() )
else if (m_UsedPosLists[USED_POS_MINUS].empty() && !m_UsedPosLists[USED_POS_PLUS].empty() )
return NextAngleFor(*m_UsedPosLists[USED_POS_PLUS].begin(), -1.0, USED_POS_MINUS, angle);
return false;
@@ -90,7 +90,7 @@ bool ObjectPosSelector::NextAngle(float& angle)
m_smallStepOk[USED_POS_PLUS] || m_smallStepOk[USED_POS_MINUS] )
{
// calculate next possible angle
if(NextPosibleAngle(angle))
if (NextPosibleAngle(angle))
return true;
}
@@ -103,53 +103,49 @@ bool ObjectPosSelector::NextUsedAngle(float& angle)
m_nextUsedPos[USED_POS_MINUS]!=m_UsedPosLists[USED_POS_MINUS].end() )
{
// calculate next possible angle
if(!NextPosibleAngle(angle))
if (!NextPosibleAngle(angle))
return true;
}
return false;
}
bool ObjectPosSelector::NextPosibleAngle( float& angle )
bool ObjectPosSelector::NextPosibleAngle(float& angle)
{
// ++ direction less updated
if( m_nextUsedPos[USED_POS_PLUS]!=m_UsedPosLists[USED_POS_PLUS].end() &&
if (m_nextUsedPos[USED_POS_PLUS]!=m_UsedPosLists[USED_POS_PLUS].end() &&
(m_nextUsedPos[USED_POS_MINUS]==m_UsedPosLists[USED_POS_MINUS].end() || m_nextUsedPos[USED_POS_PLUS]->first <= m_nextUsedPos[USED_POS_MINUS]->first) )
{
bool ok;
if(m_smallStepOk[USED_POS_PLUS])
if (m_smallStepOk[USED_POS_PLUS])
ok = NextSmallStepAngle(1.0, USED_POS_PLUS, angle);
else
ok = NextAngleFor(*m_nextUsedPos[USED_POS_PLUS], 1.0, USED_POS_PLUS, angle);
if(!ok)
if (!ok)
++m_nextUsedPos[USED_POS_PLUS]; // increase. only at fail (original or checked)
return ok;
}
// -- direction less updated
else if( m_nextUsedPos[USED_POS_MINUS]!=m_UsedPosLists[USED_POS_MINUS].end())
else if (m_nextUsedPos[USED_POS_MINUS]!=m_UsedPosLists[USED_POS_MINUS].end())
{
bool ok;
if(m_smallStepOk[USED_POS_MINUS])
if (m_smallStepOk[USED_POS_MINUS])
ok = NextSmallStepAngle(-1.0, USED_POS_MINUS, angle);
else
ok = NextAngleFor(*m_nextUsedPos[USED_POS_MINUS], -1.0, USED_POS_MINUS, angle);
if(!ok)
if (!ok)
++m_nextUsedPos[USED_POS_MINUS];
return ok;
}
else // both list empty
{
if( m_smallStepOk[USED_POS_PLUS] && (!m_smallStepOk[USED_POS_MINUS] || m_smallStepAngle[USED_POS_PLUS] <= m_smallStepAngle[USED_POS_MINUS]) )
{
if (m_smallStepOk[USED_POS_PLUS] && (!m_smallStepOk[USED_POS_MINUS] || m_smallStepAngle[USED_POS_PLUS] <= m_smallStepAngle[USED_POS_MINUS]))
return NextSmallStepAngle(1.0, USED_POS_PLUS, angle);
}
// -- direction less updated
else if( m_smallStepOk[USED_POS_MINUS] )
{
else if (m_smallStepOk[USED_POS_MINUS])
return NextSmallStepAngle(-1.0, USED_POS_MINUS, angle);
}
}
// no angles
@@ -53,14 +53,14 @@ struct ObjectPosSelector
bool NextAngle(float& angle);
bool NextUsedAngle(float& angle);
bool NextPosibleAngle( float& angle );
bool NextPosibleAngle(float& angle);
bool CheckAngle(UsedPosList::value_type const& nextUsedPos, float sign, float angle ) const
{
float angle_step2 = GetAngle(nextUsedPos.second);
float next_angle = nextUsedPos.first;
if(nextUsedPos.second.sign * sign < 0) // last node from diff. list (-pi+alpha)
if (nextUsedPos.second.sign * sign < 0) // last node from diff. list (-pi+alpha)
next_angle = 2*M_PI-next_angle; // move to positive
return fabs(angle)+angle_step2 <= next_angle;
@@ -68,13 +68,13 @@ struct ObjectPosSelector
bool CheckOriginal() const
{
return (m_UsedPosLists[USED_POS_PLUS].empty() || CheckAngle( *m_UsedPosLists[USED_POS_PLUS].begin(), 1.0, 0)) &&
(m_UsedPosLists[USED_POS_MINUS].empty() || CheckAngle( *m_UsedPosLists[USED_POS_MINUS].begin(), -1.0, 0));
return (m_UsedPosLists[USED_POS_PLUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_PLUS].begin(), 1.0, 0)) &&
(m_UsedPosLists[USED_POS_MINUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_MINUS].begin(), -1.0, 0));
}
bool IsNonBalanced() const { return m_UsedPosLists[USED_POS_PLUS].empty() != m_UsedPosLists[USED_POS_MINUS].empty(); }
bool NextAngleFor( UsedPosList::value_type const& usedPos, float sign, UsedPosType uptype, float &angle )
bool NextAngleFor(UsedPosList::value_type const& usedPos, float sign, UsedPosType uptype, float &angle)
{
float angle_step = GetAngle(usedPos.second);
@@ -82,10 +82,10 @@ struct ObjectPosSelector
angle = usedPos.first * usedPos.second.sign + angle_step * sign;
UsedPosList::value_type const* nextNode = nextUsedPos(uptype);
if(nextNode)
if (nextNode)
{
// if next node permit use selected angle, then do it
if(!CheckAngle(*nextNode, sign, angle))
if (!CheckAngle(*nextNode, sign, angle))
{
m_smallStepOk[uptype] = false;
return false;
@@ -100,27 +100,27 @@ struct ObjectPosSelector
return true;
}
bool NextSmallStepAngle( float sign, UsedPosType uptype, float &angle )
bool NextSmallStepAngle(float sign, UsedPosType uptype, float &angle)
{
// next possible angle
angle = m_smallStepAngle[uptype] + m_anglestep * sign;
if(fabs(angle) > M_PI)
if (fabs(angle) > M_PI)
{
m_smallStepOk[uptype] = false;
return false;
}
if(m_smallStepNextUsedPos[uptype])
if (m_smallStepNextUsedPos[uptype])
{
if(fabs(angle) >= m_smallStepNextUsedPos[uptype]->first)
if (fabs(angle) >= m_smallStepNextUsedPos[uptype]->first)
{
m_smallStepOk[uptype] = false;
return false;
}
// if next node permit use selected angle, then do it
if(!CheckAngle(*m_smallStepNextUsedPos[uptype], sign, angle))
if (!CheckAngle(*m_smallStepNextUsedPos[uptype], sign, angle))
{
m_smallStepOk[uptype] = false;
return false;