mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 17:43:09 +02:00
make factories an array instead of map
This commit is contained in:
parent
720f60b99e
commit
99d44ce945
3 changed files with 19 additions and 12 deletions
|
@ -23,7 +23,8 @@
|
|||
|
||||
QMap<EntityTypes::EntityType_t, QString> EntityTypes::_typeToNameMap;
|
||||
QMap<QString, EntityTypes::EntityType_t> EntityTypes::_nameToTypeMap;
|
||||
QMap<EntityTypes::EntityType_t, EntityTypeFactory> EntityTypes::_typeToFactoryMap;
|
||||
EntityTypeFactory EntityTypes::_factories[EntityTypes::LAST];
|
||||
bool EntityTypes::_factoriesInitialized = false;
|
||||
EntityTypeRenderer EntityTypes::_renderers[EntityTypes::LAST];
|
||||
bool EntityTypes::_renderersInitialized = false;
|
||||
|
||||
|
@ -62,7 +63,11 @@ bool EntityTypes::registerEntityType(EntityType_t entityType, const char* name,
|
|||
|
||||
_typeToNameMap[entityType] = name;
|
||||
_nameToTypeMap[name] = entityType;
|
||||
_typeToFactoryMap[entityType] = factoryMethod;
|
||||
if (!_factoriesInitialized) {
|
||||
memset(&_factories,0,sizeof(_factories));
|
||||
_factoriesInitialized = true;
|
||||
}
|
||||
_factories[entityType] = factoryMethod;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -72,11 +77,8 @@ EntityItem* EntityTypes::constructEntityItem(EntityType_t entityType, const Enti
|
|||
qDebug() << " entityID=" << entityID;
|
||||
|
||||
EntityItem* newEntityItem = NULL;
|
||||
|
||||
QMap<EntityTypes::EntityType_t, EntityTypeFactory>::iterator matchedType = _typeToFactoryMap.find(entityType);
|
||||
if (matchedType != _typeToFactoryMap.end()) {
|
||||
EntityTypeFactory factory = matchedType.value();
|
||||
|
||||
EntityTypeFactory factory = _factories[entityType];
|
||||
if (factory) {
|
||||
newEntityItem = factory(entityID, properties);
|
||||
}
|
||||
return newEntityItem;
|
||||
|
|
|
@ -54,7 +54,8 @@ public:
|
|||
private:
|
||||
static QMap<EntityType_t, QString> _typeToNameMap;
|
||||
static QMap<QString, EntityTypes::EntityType_t> _nameToTypeMap;
|
||||
static QMap<EntityType_t, EntityTypeFactory> _typeToFactoryMap;
|
||||
static EntityTypeFactory _factories[LAST];
|
||||
static bool _factoriesInitialized;
|
||||
static EntityTypeRenderer _renderers[LAST];
|
||||
static bool _renderersInitialized;
|
||||
};
|
||||
|
|
|
@ -43,8 +43,10 @@ Model properties:
|
|||
// TODO:
|
||||
|
||||
|
||||
// a) crash in entity server on add entity?
|
||||
// b) entities have same ID? unknown???
|
||||
// c) why does is the Box entity not drawn in it's bounds
|
||||
// d) make the rotated model bounds work for other entity types?
|
||||
// e) maybe make "hasGeometry" be a property of EntityItem base class??
|
||||
|
||||
|
||||
// 0) handle subclass properties?
|
||||
|
||||
|
@ -150,7 +152,8 @@ Model properties:
|
|||
|
||||
|
||||
// 25) consider moving the EntityTypes static Maps to be inside a singleton instance of EntityTypes to ensure initialization order
|
||||
// 26) Why can't we call REGISTER_ENTITY_TYPE() in BoxEntityType.cpp
|
||||
// 26) Why can't we call REGISTER_ENTITY_TYPE() in BoxEntityType.cpp or the CPP of the implementation?
|
||||
// 27) Consider making properties of the entities be registered... and handle their streaming in a more automatice fashion
|
||||
|
||||
|
||||
|
||||
|
@ -209,4 +212,5 @@ Model properties:
|
|||
// SOLVED - 16) duplicate copies of entity references in the elements... this appears to be caused when "viewing" while editing...
|
||||
// SOLVED - 17) Handle the newer on client vs changed on server problem properly for entities
|
||||
// SOLVED - 20) Verified that multiple machines viewing real time edits works - fixed bugs in lastEdited.
|
||||
|
||||
// SOLVED - b) entities have same ID? unknown??? - wasn't setting ID on read from buffer...
|
||||
// SOLVED - a) crash in entity server on add entity?
|
||||
|
|
Loading…
Reference in a new issue