Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6121 in orxonox.OLD


Ignore:
Timestamp:
Dec 15, 2005, 1:34:32 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: packing the first entities into their lists

Location:
branches/objectmanager/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/objectmanager/src/story_entities/world.cc

    r6120 r6121  
    141141  SoundEngine::getInstance()->flushAllSources();
    142142
    143   delete ObjectManager::getInstance();
     143  if (State::getObjectManager() == &this->objectManager)
     144    State::setObjectManager(NULL);
    144145  // erease everything that is left.
    145146  delete PNode::getNullParent();
     
    214215ErrorMessage World::preLoad()
    215216{
     217  State::setObjectManager(&this->objectManager);
    216218  State::setWorldEntityList(this->entities = new tList<WorldEntity>());
    217219  this->cycle = 0;
  • branches/objectmanager/src/story_entities/world.h

    r6048 r6121  
    1111#include "story_entity.h"
    1212#include "p_node.h"
     13#include "object_manager.h"
    1314
    14 class World;
     15
    1516class WorldEntity;
    1617class Camera;
     
    1819class GLMenuImageScreen;
    1920class Terrain;
    20 class GarbageCollector;
    21 class Text;
    2221class TiXmlElement;
    2322
    2423class Shell;
    2524class OggPlayer;
     25
    2626template<class T> class tList;
    2727
     
    104104    bool bPause;                        //!< pause mode
    105105
     106    ObjectManager      objectManager;   //!< The ObjectManager of this World.
     107
    106108    GLMenuImageScreen* glmis;           //!< The Level-Loader Display
    107109
  • branches/objectmanager/src/util/object_manager.cc

    r6120 r6121  
    2222
    2323#include "shell_command.h"
     24
     25#include <assert.h>
     26
    2427using namespace std;
    2528SHELL_COMMAND(debug, ObjectManager, debug)
     
    3740}
    3841
    39 /**
    40  *  the singleton reference to this class
    41  */
    42 ObjectManager* ObjectManager::singletonRef = NULL;
    4342
    4443/**
     
    5049{
    5150  this->flush();
    52   ObjectManager::singletonRef = NULL;
    5351}
    5452
     
    7876void ObjectManager::toList (WorldEntity* entity, OM_LIST omList)
    7977{
     78  assert (omList != OM_SIZE);
     79
    8080  if (likely(entity->getOMListNumber() != OM_INIT))
    8181    this->objectLists[entity->getOMListNumber()].erase(entity->getEntityIterator());
     
    127127 * @brief print out nice debug information about Elements in the list OM_LIST
    128128 * @param omList the List to debug.
    129  */
    130 void ObjectManager::debug(OM_LIST omList) const
     129 * @param level: level 0: only show list info; level 1: also show entities and their names.
     130 */
     131void ObjectManager::debug(OM_LIST omList, unsigned int level) const
    131132{
    132133  if (omList != OM_INIT || omList == OM_SIZE)
    133134  {
    134135    PRINT(0)(" +ObjectManager-LIST: '%s'-size='%d'-----\n", ObjectManager::OMListToString((OM_LIST) omList), this->objectLists[omList].size());
    135     std::list<WorldEntity*>::const_iterator entity;
    136     for (entity = this->objectLists[omList].begin(); entity != this->objectLists[omList].end(); entity++)
     136    if (level > 1)
    137137    {
    138       PRINT(0)(" | %s::%s\n",(*entity)->getClassName(), (*entity)->getName());
     138      std::list<WorldEntity*>::const_iterator entity;
     139      for (entity = this->objectLists[omList].begin(); entity != this->objectLists[omList].end(); entity++)
     140      {
     141        PRINT(0)(" | %s::%s\n",(*entity)->getClassName(), (*entity)->getName());
     142      }
    139143    }
    140144  }
     
    147151 * @brief prints out very nice debug information
    148152 * @param listName the Name of the list to get Debug information from
    149  */
    150 void ObjectManager::debug(const char* listName)
    151 {
     153 * @param level: level 0: only show list info; level 1: also show entities and their names.
     154 */
     155void ObjectManager::debug(const char* listName, unsigned int level)
     156{
     157  PRINT(0)("=================================\n");
    152158  PRINT(0)("=ObjectManager-DEBUG=============\n");
     159  PRINT(0)("=================================\n");
    153160  if (listName == NULL || listName[0] == '\0')
    154161    for (unsigned int i = 0; i < OM_SIZE; ++i)
    155       debug((OM_LIST) i);
     162      debug((OM_LIST) i, level);
    156163  else
    157164    debug(ObjectManager::StringToOMList(listName));
     
    198205    "null",
    199206    "dead",
     207    "dead-tick"
    200208    "environ-notick",
    201209    "environ",
  • branches/objectmanager/src/util/object_manager.h

    r6120 r6121  
    11/*!
    22 * @file object_manager.h
    3  * @brief Definition of the ... singleton Class
    4 */
     3 * @brief Definition of the ObjectManager.
     4 */
    55
    66#ifndef _OBJECT_MANAGER_H
     
    1515  OM_NULL             =  0,
    1616  OM_DEAD,
     17  OM_DEAD_TICK,
    1718  OM_ENVIRON_NOTICK,
    1819  OM_ENVIRON,
     
    6566class WorldEntity;
    6667
    67 //! A default singleton class.
     68//! A powerfull handler for the Object (WorldEntities) in the World.
    6869class ObjectManager : public BaseObject {
    6970
    7071 public:
    71   virtual ~ObjectManager(void);
    72   /** @returns a Pointer to the only object of this Class */
    73   inline static ObjectManager* getInstance(void) { if (!ObjectManager::singletonRef) ObjectManager::singletonRef = new ObjectManager();  return ObjectManager::singletonRef; }
     72   ObjectManager();
     73   virtual ~ObjectManager();
    7474
    7575  void flush();
     
    8484  static std::list<WorldEntity*>* distanceFromObject(const PNode& center, float radius, ClassID classID);
    8585
    86   void debug(OM_LIST omList) const;
    87   void debug(const char* listName = NULL);
     86  void debug(OM_LIST omList, unsigned int level = 0) const;
     87  void debug(const char* listName = NULL, unsigned int level = 0);
    8888
    8989  static OM_LIST StringToOMList(const char* listName);
     
    9191
    9292 private:
    93   ObjectManager(void);
    94   static ObjectManager* singletonRef;
    95 
    9693  const std::list<BaseObject>*            pNodeList;
    9794
  • branches/objectmanager/src/util/state.cc

    r4836 r6121  
    2929const PNode* State::cameraTarget = NULL;
    3030
     31ObjectManager* State::objectManager = NULL;
    3132tList<WorldEntity>* State::worldEntityList = NULL;
    3233
  • branches/objectmanager/src/util/state.h

    r5405 r6121  
    1111class WorldEntity;
    1212template<class T> class tList;
    13 //template<class T> class tStack;
     13class ObjectManager;
    1414
    1515//! handles states about orxonox's most importatn objects
     
    2222
    2323 public:
    24   // CAMERA //
     24   //////////////
     25   /// CAMERA ///
     26   //////////////
    2527  /** @param camera the PNode to the Camera, @param cameraTarget the PNode to the Camera's target */
    2628  static void setCamera(const PNode* camera, const PNode* cameraTarget);
     
    3032  static inline const PNode* getCameraTarget() { return State::cameraTarget; };
    3133
    32   // WORLD_ENTITY_LIST //
     34  //////////////////////
     35  /// OBJECT-MANAGER ///
     36  //////////////////////
     37  /** @param objectManager the new Current ObjectManager */
     38  static inline void setObjectManager(ObjectManager* objectManager) { State::objectManager = objectManager; };
     39  /** @returns the current ObjectManager. */
     40  static inline ObjectManager* getObjectManager() { return State::objectManager; };
     41
     42  /////////////////////////
     43  /// WORLD_ENTITY_LIST ///
     44  /////////////////////////
    3345  /** @param worldEntityList The World's List of WorldEntities */
    3446  static inline void setWorldEntityList(tList<WorldEntity>* worldEntityList) { State::worldEntityList = worldEntityList; };
     
    4254  static const PNode*           cameraTarget;       //!< A reference to the cameraTarget
    4355  static PNode*                 nullParent;         //!< A reference to the Null-PNode.
     56  static ObjectManager*         objectManager;      //!< A referenct to the current ObjectManager
    4457
    4558  static tList<WorldEntity>*    worldEntityList;    //!< The List of the worldEntities
  • branches/objectmanager/src/world_entities/npcs/npc.cc

    r6054 r6121  
    3333{
    3434  this->setClassID(CL_NPC, "NPC");
    35 
     35  this->toList(OM_GROUP_00);
    3636}
    3737
  • branches/objectmanager/src/world_entities/playable.cc

    r5915 r6121  
    4646  PRINTF(4)("PLAYABLE INIT\n");
    4747
     48  this->toList(OM_GROUP_01);
    4849  this->weaponMan = new WeaponManager(this);
    4950
  • branches/objectmanager/src/world_entities/power_ups/power_up.cc

    r5439 r6121  
    2727{
    2828  this->setClassID(CL_POWER_UP, "PowerUp");
     29  this->toList(OM_COMMON);
    2930
    3031}
  • branches/objectmanager/src/world_entities/skybox.cc

    r6022 r6121  
    6565{
    6666  this->setClassID(CL_SKYBOX, "SkyBox");
    67 
     67  this->toList(OM_ENVIRON_NOTICK);
    6868  this->size = 100.0;
    6969
  • branches/objectmanager/src/world_entities/world_entity.cc

    r6089 r6121  
    5757  this->objectListIterator = NULL;
    5858
    59   ObjectManager::getInstance()->toList(this, OM_NULL);
     59  this->toList(OM_NULL);
    6060}
    6161
     
    7373    this->setModel(NULL, i);
    7474
    75   ObjectManager::getInstance()->toList(this, OM_INIT);
     75  State::getObjectManager()->toList(this, OM_INIT);
    7676}
    7777
     
    106106    if (strchr(fileName, '#') != NULL)
    107107      {
    108         PRINTF(4)("Found # in %s... searching for LOD's\n", fileName);
    109         char* lodFile = new char[strlen(fileName)+1];
    110         strcpy(lodFile, fileName);
    111         char* depth = strchr(lodFile, '#');
    112         for (unsigned int i = 0; i < 5; i++)
    113           {
    114             *depth = 48+(int)i;
    115             printf("-------%s\n", lodFile);
    116             if (ResourceManager::isInDataDir(lodFile))
    117               this->loadModel(lodFile, scaling, i);
    118           }
    119         return;
     108        PRINTF(4)("Found # in %s... searching for LOD's\n", fileName);
     109        char* lodFile = new char[strlen(fileName)+1];
     110        strcpy(lodFile, fileName);
     111        char* depth = strchr(lodFile, '#');
     112        for (unsigned int i = 0; i < 5; i++)
     113          {
     114            *depth = 48+(int)i;
     115            printf("-------%s\n", lodFile);
     116            if (ResourceManager::isInDataDir(lodFile))
     117              this->loadModel(lodFile, scaling, i);
     118          }
     119        return;
    120120      }
    121121
     
    181181  }
    182182}
     183
     184/**
     185 * @brief moves this entity to the List OM_List
     186 * @param list the list to set this Entity to.
     187 *
     188 * this is the same as a call to State::getObjectManager()->toList(entity , list);
     189 * directly, but with an easier interface.
     190 */
     191void WorldEntity::toList(OM_LIST list)
     192{
     193  State::getObjectManager()->toList(this, list);
     194}
     195
    183196
    184197
  • branches/objectmanager/src/world_entities/world_entity.h

    r6089 r6121  
    6666  //  CharacterAttributes* getCharacterAttributes();
    6767
     68  void toList(OM_LIST list);
     69
    6870  /** @returns a Reference to the objectListNumber to set. */
    6971  OM_LIST& getOMListNumber() { return this->objectListNumber; }
Note: See TracChangeset for help on using the changeset viewer.