Mercurial > fife-parpg
diff engine/core/model/structures/layer.cpp @ 99:64e7fe3d4288
- added possibility to change instance ids
- speedup instances by removing uniqueness check for ids, that means the client has to provide unique ids or live with on unique ids
- added possibility to list all instances with a given id
author | spq@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 22 Jul 2008 10:04:16 +0000 |
parents | 746df66978da |
children | 56ac89189bc4 |
line wrap: on
line diff
--- a/engine/core/model/structures/layer.cpp Mon Jul 21 13:46:15 2008 +0000 +++ b/engine/core/model/structures/layer.cpp Tue Jul 22 10:04:16 2008 +0000 @@ -71,14 +71,6 @@ l.setLayer(this); l.setExactLayerCoordinates(p); - if(id != "") { - std::vector<Instance*>::iterator it = m_instances.begin(); - for(; it != m_instances.end(); ++it) { - if((*it)->getId() == id) - throw NameClash(id); - } - } - Instance* instance = new Instance(object, l, id); m_instances.push_back(instance); m_instanceTree->addInstance(instance); @@ -101,15 +93,6 @@ Location l; l.setLayer(this); l.setExactLayerCoordinates(p); - std::string id = instance->getId(); - - if(id != "") { - std::vector<Instance*>::iterator it = m_instances.begin(); - for(; it != m_instances.end(); ++it) { - if((*it)->getId() == id) - throw NameClash(id); - } - } m_instances.push_back(instance); m_instanceTree->addInstance(instance); @@ -152,6 +135,16 @@ throw NotFound(id); } + std::vector<Instance*> Layer::getInstances(const std::string& id) { + std::vector<Instance*> matching_instances; + std::vector<Instance*>::iterator it = m_instances.begin(); + for(; it != m_instances.end(); ++it) { + if((*it)->getId() == id) + matching_instances.push_back(*it); + } + return matching_instances; + } + void Layer::getMinMaxCoordinates(ModelCoordinate& min, ModelCoordinate& max, const Layer* layer) const { if (!layer) { layer = this;