Example #1
0
        void EntityRenderer::removeEntities(const Model::EntityList& entities) {
            if (entities.empty())
                return;

            for (unsigned int i = 0; i < entities.size(); i++) {
                Model::Entity* entity = entities[i];
                m_modelRenderers.erase(entity);
                m_classnameRenderer->removeString(entity);
                m_entities.erase(entity);
            }
            m_boundsValid = false;
        }
Example #2
0
 bool MapParser::parseEntities(const BBox& worldBounds, Model::EntityList& entities) {
     size_t oldSize = entities.size();
     try {
         Model::Entity* entity = NULL;
         while ((entity = parseEntity(worldBounds, NULL)) != NULL)
             entities.push_back(entity);
         return !entities.empty();
     } catch (MapParserException e) {
         Utility::deleteAll(entities, oldSize);
         m_tokenizer.reset();
         return false;
     }
 }
Example #3
0
        void EntityRenderer::writeBounds(RenderContext& context, const Model::EntityList& entities) {
            if (entities.empty())
                return;

            Vec3f::List vertices(24);
            for (unsigned int i = 0; i < entities.size(); i++) {
                Model::Entity* entity = entities[i];
                const BBoxf& bounds = entity->bounds();
                bounds.vertices(vertices);

                for (unsigned int j = 0; j < vertices.size(); j++)
                    m_boundsVertexArray->addAttribute(vertices[j]);
            }
        }
 void SnapshotCommand::restoreSnapshots(const Model::EntityList& entities) {
     assert(m_entities.size() == entities.size());
     
     if (entities.empty())
         return;
     
     Model::EntityDefinitionManager& definitionManager = document().definitionManager();
     
     for (unsigned int i = 0; i < entities.size(); i++) {
         Model::Entity& entity = *entities[i];
         EntitySnapshot& snapshot = *m_entities[entity.uniqueId()];
         snapshot.restore(entity);
         
         const Model::PropertyValue* classname = entity.classname();
         if (classname != NULL)
             entity.setDefinition(definitionManager.definition(*classname));
     }
 }
Example #5
0
        void EntityRenderer::addEntities(const Model::EntityList& entities) {
            if (entities.empty())
                return;

            EntityModelRendererManager& modelRendererManager = m_document.sharedResources().modelRendererManager();

            for (unsigned int i = 0; i < entities.size(); i++) {
                Model::Entity* entity = entities[i];
                const String* classname = entity->classname();
                if (classname == NULL)
                    classname = &Model::Entity::NoClassnameValue;
                if (classname != NULL) {
                    EntityModelRenderer* renderer = modelRendererManager.modelRenderer(*entity, m_document.searchPaths());
                    if (renderer != NULL)
                        m_modelRenderers[entity] = CachedEntityModelRenderer(renderer, *classname);

                    m_classnameRenderer->addString(entity, *classname, Text::TextAnchor::Ptr(new EntityClassnameAnchor(*entity, renderer)));
                }
            }

            m_entities.insert(entities.begin(), entities.end());
            m_boundsValid = false;
        }