Raven_Bot* Raven_Projectile::GetClosestIntersectingBot(Vector2D    From,
                                                       Vector2D    To)const
{
  Raven_Bot* ClosestIntersectingBot = 0;
  double ClosestSoFar = MaxDouble;

  //iterate through all entities checking against the line segment FromTo
  std::list<Raven_Bot*>::const_iterator curBot;
  for (curBot =  m_pWorld->GetAllBots().begin();
       curBot != m_pWorld->GetAllBots().end();
       ++curBot)
  {
    //make sure we don't check against the shooter of the projectile
    if ( ((*curBot)->ID() != m_iShooterID))
    {
      //if the distance to FromTo is less than the entity's bounding radius then
      //there is an intersection
      if (DistToLineSegment(From, To, (*curBot)->Pos()) < (*curBot)->BRadius())
      {
        //test to see if this is the closest so far
        double Dist = Vec2DDistanceSq((*curBot)->Pos(), m_vOrigin);

        if (Dist < ClosestSoFar)
        {
          Dist = ClosestSoFar;
          ClosestIntersectingBot = *curBot;
        }
      }
    }

  }

  return ClosestIntersectingBot;
}
Пример #2
0
std::list<Entity*> Projectile::GetListOfIntersectingEntities(Vector2D From, Vector2D To)const
{

	//list to hold all entites who are intersecting with the given line segment
	std::list<Entity*> hits;

	//iterate through all game entites
	std::list<Entity*>::const_iterator curEntity;
	for(curEntity = m_pWorld->GetAllEntities.begin();curEntity != m_pWorld->GetAllEntities.end();++curEntity)
	{

		//don't check the entity who shot the projectile
		if(((*curEntity)->ID() != m_iShooterID))
		{

			//if the distasnce to the segment between From and To is less than the entities bounding
			//radius then add this entity the the hit list
			if(DistToLineSegment(From, To, (*curEntity)->Pos()) < (*curEntity)->BRadius())
			{

				hits.push_back(*curEntity);
			}

		}

	}

	return hits;

}
//---------------------- GetListOfIntersectingBots ----------------------------
std::list<Raven_Bot*> Raven_Projectile::GetListOfIntersectingBots(Vector2D From,
                                                                  Vector2D To)const
{
  //this will hold any bots that are intersecting with the line segment
  std::list<Raven_Bot*> hits;

  //iterate through all entities checking against the line segment FromTo
  std::list<Raven_Bot*>::const_iterator curBot;
  for (curBot =  m_pWorld->GetAllBots().begin();
       curBot != m_pWorld->GetAllBots().end();
       ++curBot)
  {
    //make sure we don't check against the shooter of the projectile
    if ( ((*curBot)->ID() != m_iShooterID))
    {
      //if the distance to FromTo is less than the entities bounding radius then
      //there is an intersection so add it to hits
      if (DistToLineSegment(From, To, (*curBot)->Pos()) < (*curBot)->BRadius())
      {
        hits.push_back(*curBot);
      }
    }

  }

  return hits;
}
Пример #4
0
Entity* Projectile::GetClosestIntersectingEntity(Vector2D From, Vector2D To)const
{

	Entity* ClosestIntersectingEntity = 0;
	double ClosestSoFar = MaxDouble;

	//iterate through all game entities
	std::list<Entity*>::const_iterator curEntity;
	for(curEntity = m_pWorld->GetAllEntities().begin();
		curEntity != m_pWorld->GetAllEntities().end();
		++curEntity)
	{

		//don't check the entity who shot the projectile
		if(((*curEntity)->ID() != m_iShooterID))
		{

			//if the distasnce to the segment between From and To is less than the entities bounding
			//radius then thre is an intersection
			if(DistToLineSegment(From, To, (*curEntity)->Pos()) < (*curEntity)->BRadius())
			{

				//check if this the closest intersecting entity so far
				double Dist = Vec2DDistanceSq((*curEntity)->Pos(), m_vOrigin);

				//if so then set this to be the new closest entity
				if(Dist < ClosestSoFar)
				{

					Dist = ClosestSoFar;
					ClosestIntersectingEntity = *curEntity;

				}

			}

		}

	}

	return ClosestIntersectingEntity;

}