Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 26, 2005, 5:00:05 PM (19 years ago)
Author:
bensch
Message:

world_entities: simple interface in objectManager

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/world_entities/src/util/object_manager.cc

    r5629 r5782  
    1717
    1818#include "object_manager.h"
     19#include "class_list.h"
     20
     21#include "p_node.h"
     22#include "world_entity.h"
     23#include "list.h"
    1924
    2025using namespace std;
     
    2833   this->setClassID(CL_OBJECT_MANAGER, "ObjectManager");
    2934   this->setName("ObjectManager");
     35
     36   pNodeList = NULL;
    3037}
    3138
     
    4249  ObjectManager::singletonRef = NULL;
    4350}
     51
     52/**
     53 * returns a new List with a list of WorldEntities of distance Radius from center
     54 */
     55const std::list<WorldEntity*>* ObjectManager::distanceFromObject(const PNode& center, float radius, ClassID classID)
     56{
     57  const tList<BaseObject>* objectList = ClassList::getList(classID);
     58  if (objectList != NULL)
     59  {
     60    std::list<WorldEntity*>* newList = new  std::list<WorldEntity*>;
     61
     62    tIterator<BaseObject>* iter = objectList->getIterator();
     63    PNode* tmp = dynamic_cast<PNode*>(iter->firstElement());
     64    while (tmp != NULL)
     65    {
     66      if ((tmp->getAbsCoor() - center.getAbsCoor()).len() < radius)
     67        newList->push_back(dynamic_cast<WorldEntity*>(tmp));
     68
     69      tmp = dynamic_cast<PNode*>(iter->nextElement());
     70    }
     71    delete iter;
     72    return newList;
     73
     74  }
     75  return NULL;
     76}
Note: See TracChangeset for help on using the changeset viewer.