bool ReparentBrushesCommand::performUndo() {
     Model::EntityList entities;
     if (!m_newParent.worldspawn())
         entities.push_back(&m_newParent);
     
     Model::BrushList::const_iterator it, end;
     for (it = m_brushes.begin(), end = m_brushes.end(); it != end; ++it) {
         Model::Brush* brush = *it;
         Model::Entity* oldParent = m_oldParents[brush];
         if (oldParent != NULL &&
             !oldParent->worldspawn() &&
             std::find(entities.begin(), entities.end(), oldParent) == entities.end())
             entities.push_back(oldParent);
     }
     
     document().entitiesWillChange(entities);
     for (it = m_brushes.begin(), end = m_brushes.end(); it != end; ++it) {
         Model::Brush& brush = **it;
         Model::Entity* oldParent = m_oldParents[&brush];
         m_newParent.removeBrush(brush);
         if (oldParent != NULL)
             oldParent->addBrush(brush);
     }
     document().entitiesDidChange(entities);
     
     return true;
 }
Exemplo n.º 2
0
        void EntityRenderer::validateBounds(RenderContext& context) {
            delete m_boundsVertexArray;
            m_boundsVertexArray = NULL;

            Model::EntityList entities;
            Model::EntitySet::iterator entityIt, entityEnd;
            for (entityIt = m_entities.begin(), entityEnd = m_entities.end(); entityIt != entityEnd; ++entityIt) {
                Model::Entity* entity = *entityIt;
                if (context.filter().entityVisible(*entity))
                    entities.push_back(entity);
            }

            if (entities.empty())
                return;

            SetVboState mapVbo(m_boundsVbo, Vbo::VboMapped);

            if (m_overrideBoundsColor) {
                unsigned int vertexCount = 2 * 4 * 6 * static_cast<unsigned int>(entities.size());
                m_boundsVertexArray = new VertexArray(m_boundsVbo, GL_LINES, vertexCount,
                                                      Attribute::position3f());
                writeBounds(context, entities);
            } else {
                unsigned int vertexCount = 2 * 4 * 6 * static_cast<unsigned int>(entities.size());
                m_boundsVertexArray = new VertexArray(m_boundsVbo, GL_LINES, vertexCount,
                                                      Attribute::position3f(),
                                                      Attribute::color4f());
                writeColoredBounds(context, entities);
            }

            m_boundsValid = true;
        }
Exemplo n.º 3
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;
     }
 }
 ChangeEditStateCommand* ChangeEditStateCommand::select(Model::MapDocument& document, Model::Entity& entity) {
     Model::EntityList entities;
     entities.push_back(&entity);
     return select(document, entities);
 }
 MoveObjectsCommand* MoveObjectsCommand::moveEntity(Model::MapDocument& document, Model::Entity& entity, const Vec3f& delta, bool lockTextures) {
     Model::EntityList entities;
     entities.push_back(&entity);
     return moveObjects(document, entities, Model::EmptyBrushList, delta, lockTextures);
 }