29 namespace OpenSkyNet {
43 enum UPDATER_TYPE { BASE, AI, CAMERA, PATH_FINDER,
PATH, TRANSFORM_INTERPOLATOR, PHYSICS, ANIMATION, COLLISION_DETECTOR, PHYS_VIS, TRANSFORM_CHANGE_DETECTOR, CORE_MAX, MAX=32 };
46 enum UPDATER_PRIORITY { UPD_DISABLED, UPD_1, UPD_2, UPD_3, UPD_4, UPD_5, UPD_6, UPD_7, UPD_8, UPD_NUM_PRIORITIES };
59 _prevPrio(prio_), _prevUpdateTimeAfterReset(0), _isOneShot(isOneShot_) {}
63 typedef std::map<Object*, UpdateInfo*>
ObjMap;
67 std::list<Object*> _objLists[OBJ_NUM_PRIORITIES];
85 virtual bool removeObject(
Object* obj_);
87 virtual void removeAllObjects();
89 int getNumToUpdate(
float dt_);
90 void allObjectsUpdated();
93 Updater() : _type(BASE), _typeName(
"BASE"), _prio(UPD_1), _interval(0),
94 _dtSinceAllWereUpdated(0), _prevTotalTimeForAllUpdates(0), _partialUpdate(0),
95 _currPrio(OBJ_NUM_PRIORITIES-1), _currObj(_objLists[OBJ_NUM_PRIORITIES-1].begin()) {}
97 _typeName(typeName_), _prio(prio_), _interval(interval_),
98 _dtSinceAllWereUpdated(0), _prevTotalTimeForAllUpdates(0), _partialUpdate(0),
99 _currPrio(OBJ_NUM_PRIORITIES-1), _currObj(_objLists[OBJ_NUM_PRIORITIES-1].begin()) {}
103 inline const std::string&
getTypeName()
const {
return _typeName; }
110 virtual bool update(
float dt_);
116 inline void setInterval(
float interval_) { _interval = interval_; }
124 for (ObjMap::const_iterator i = _objMap.begin(); i != _objMap.end(); i++)
125 if (i->second->_prio > OBJ_DISABLED)
126 ++numObjectsThatCanUpdate;
127 return numObjectsThatCanUpdate;
131 if (_objMap.find(obj_) != _objMap.end())
139 OBJECT_PRIORITY getPriority(
Object* obj_)
const;
141 virtual bool setPriority(
Object* obj_, OBJECT_PRIORITY prio_);
146 #define UPDATE_METHOD_COMMON_VARS \
147 _dtSinceAllWereUpdated += dt_; \
149 int numToUpdate = getNumToUpdate(dt_); \
150 int numUpdated = 0; \
151 std::list<Object*>::iterator initObj = _currObj; \
152 std::list<Object*>::iterator j(initObj); \
153 std::list<Object*>::iterator k(j);
float _prevUpdateTimeAfterReset
Definition: CUpdater.h:56
bool _isOneShot
Definition: CUpdater.h:57
ObjMap _objMap
Definition: CUpdater.h:68
std::list< Object * >::iterator _currObj
Definition: CUpdater.h:79
float _interval
Definition: CUpdater.h:73
virtual ~UpdateInfo()
Definition: CUpdater.h:60
UPDATER_PRIORITY getPriority() const
Definition: CUpdater.h:136
bool find(Object *obj_) const
Definition: CUpdater.h:130
void setInterval(float interval_)
Definition: CUpdater.h:116
Utils::uint getNumObjects() const
Definition: CUpdater.h:119
UPDATER_PRIORITY
Definition: CUpdater.h:46
float getInterval() const
Definition: CUpdater.h:112
UPDATER_TYPE _type
Definition: CUpdater.h:70
UPDATER_TYPE getType() const
Definition: CUpdater.h:102
void setPriority(UPDATER_PRIORITY prio_)
Definition: CUpdater.h:91
Updater()
Definition: CUpdater.h:93
virtual ~Updater()
Definition: CUpdater.h:100
UPDATER_TYPE
Definition: CUpdater.h:43
Definition: CUpdater.h:40
int _currPrio
Definition: CUpdater.h:78
UPDATER_PRIORITY _prio
Definition: CUpdater.h:72
Utils::uint getNumObjectsThatCanUpdate() const
Definition: CUpdater.h:122
const std::string & getTypeName() const
Definition: CUpdater.h:103
float _dtSinceAllWereUpdated
Definition: CUpdater.h:74
unsigned int uint
Definition: UTypes.h:39
OBJECT_PRIORITY
Definition: CUpdater.h:49
float _prevTotalTimeForAllUpdates
Definition: CUpdater.h:75
#define CORE_DLL
Definition: CCoreDLL.h:57
float _partialUpdate
Definition: CUpdater.h:76
OBJECT_PRIORITY _prio
Definition: CUpdater.h:55
UpdateInfo(OBJECT_PRIORITY prio_=OBJ_DISABLED, bool isOneShot_=false)
Definition: CUpdater.h:58
std::map< Object *, UpdateInfo * > ObjMap
Definition: CUpdater.h:63
std::string _typeName
Definition: CUpdater.h:71
Updater(UPDATER_TYPE type_, const char *typeName_, UPDATER_PRIORITY prio_, float interval_)
Definition: CUpdater.h:96
Definition: CUpdater.h:54
Definition: CUpdateManager.h:34