mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 22:14:33 +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<EntityTypes::EntityType_t, QString> EntityTypes::_typeToNameMap;
|
||||||
QMap<QString, EntityTypes::EntityType_t> EntityTypes::_nameToTypeMap;
|
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];
|
EntityTypeRenderer EntityTypes::_renderers[EntityTypes::LAST];
|
||||||
bool EntityTypes::_renderersInitialized = false;
|
bool EntityTypes::_renderersInitialized = false;
|
||||||
|
|
||||||
|
@ -62,7 +63,11 @@ bool EntityTypes::registerEntityType(EntityType_t entityType, const char* name,
|
||||||
|
|
||||||
_typeToNameMap[entityType] = name;
|
_typeToNameMap[entityType] = name;
|
||||||
_nameToTypeMap[name] = entityType;
|
_nameToTypeMap[name] = entityType;
|
||||||
_typeToFactoryMap[entityType] = factoryMethod;
|
if (!_factoriesInitialized) {
|
||||||
|
memset(&_factories,0,sizeof(_factories));
|
||||||
|
_factoriesInitialized = true;
|
||||||
|
}
|
||||||
|
_factories[entityType] = factoryMethod;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,11 +77,8 @@ EntityItem* EntityTypes::constructEntityItem(EntityType_t entityType, const Enti
|
||||||
qDebug() << " entityID=" << entityID;
|
qDebug() << " entityID=" << entityID;
|
||||||
|
|
||||||
EntityItem* newEntityItem = NULL;
|
EntityItem* newEntityItem = NULL;
|
||||||
|
EntityTypeFactory factory = _factories[entityType];
|
||||||
QMap<EntityTypes::EntityType_t, EntityTypeFactory>::iterator matchedType = _typeToFactoryMap.find(entityType);
|
if (factory) {
|
||||||
if (matchedType != _typeToFactoryMap.end()) {
|
|
||||||
EntityTypeFactory factory = matchedType.value();
|
|
||||||
|
|
||||||
newEntityItem = factory(entityID, properties);
|
newEntityItem = factory(entityID, properties);
|
||||||
}
|
}
|
||||||
return newEntityItem;
|
return newEntityItem;
|
||||||
|
|
|
@ -54,7 +54,8 @@ public:
|
||||||
private:
|
private:
|
||||||
static QMap<EntityType_t, QString> _typeToNameMap;
|
static QMap<EntityType_t, QString> _typeToNameMap;
|
||||||
static QMap<QString, EntityTypes::EntityType_t> _nameToTypeMap;
|
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 EntityTypeRenderer _renderers[LAST];
|
||||||
static bool _renderersInitialized;
|
static bool _renderersInitialized;
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,8 +43,10 @@ Model properties:
|
||||||
// TODO:
|
// TODO:
|
||||||
|
|
||||||
|
|
||||||
// a) crash in entity server on add entity?
|
// c) why does is the Box entity not drawn in it's bounds
|
||||||
// b) entities have same ID? unknown???
|
// 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?
|
// 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
|
// 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 - 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 - 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 - 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