void SnapshotCommand::restoreSnapshots(const Model::BrushList& brushes) {
     assert(m_brushes.size() == brushes.size());
     
     for (unsigned int i = 0; i < brushes.size(); i++) {
         Model::Brush& brush = *brushes[i];
         BrushSnapshot& snapshot = *m_brushes[brush.uniqueId()];
         snapshot.restore(brush);
     }
 }
예제 #2
0
 bool MapParser::parseBrushes(const BBox& worldBounds, Model::BrushList& brushes) {
     size_t oldSize = brushes.size();
     try {
         Model::Brush* brush = NULL;
         while ((brush = parseBrush(worldBounds, NULL)) != NULL)
             brushes.push_back(brush);
         return !brushes.empty();
     } catch (MapParserException e) {
         Utility::deleteAll(brushes, oldSize);
         m_tokenizer.reset();
         return false;
     }
 }
예제 #3
0
        void MapWriter::writeObjectsToStream(const Model::EntityList& pointEntities, const Model::BrushList& brushes, std::ostream& stream) {
            assert(stream.good());
            stream.unsetf(std::ios::floatfield);

            Model::Entity* worldspawn = NULL;
            
            // group the brushes by their containing entities
            typedef std::map<Model::Entity*, Model::BrushList> EntityBrushMap;
            EntityBrushMap entityToBrushes;
            
            Model::BrushList::const_iterator brushIt, brushEnd;
            for (brushIt = brushes.begin(), brushEnd = brushes.end(); brushIt != brushEnd; ++brushIt) {
                Model::Brush& brush = **brushIt;
                Model::Entity& entity = *brush.entity();
                entityToBrushes[&entity].push_back(&brush);
                if (entity.worldspawn())
                    worldspawn = &entity;
            }
            
            // write worldspawn first
            if (worldspawn != NULL) {
                Model::BrushList& brushList = entityToBrushes[worldspawn];
                writeEntityHeader(*worldspawn, stream);
                for (brushIt = brushList.begin(), brushEnd = brushList.end(); brushIt != brushEnd; ++brushIt) {
                    writeBrush(**brushIt, stream);
                }
                writeEntityFooter(stream);
            }
            
            // now write the point entities
            Model::EntityList::const_iterator entityIt, entityEnd;
            for (entityIt = pointEntities.begin(), entityEnd = pointEntities.end(); entityIt != entityEnd; ++entityIt) {
                Model::Entity& entity = **entityIt;
                writeEntity(entity, stream);
            }

            // finally write the brush entities
            EntityBrushMap::iterator it, end;
            for (it = entityToBrushes.begin(), end = entityToBrushes.end(); it != end; ++it) {
                Model::Entity* entity = it->first;
                if (entity != worldspawn) {
                    Model::BrushList& brushList = it->second;
                    writeEntityHeader(*entity, stream);
                    for (brushIt = brushList.begin(), brushEnd = brushList.end(); brushIt != brushEnd; ++brushIt) {
                        writeBrush(**brushIt, stream);
                    }
                    writeEntityFooter(stream);
                }
            }
        }
 SnapBrushVerticesCommand::Ptr SnapBrushVerticesCommand::snap(const Model::BrushList& brushes, const size_t snapTo) {
     Model::BrushVerticesMap brushVertices;
     Vec3::List vertexPositions;
     
     Model::BrushList::const_iterator bIt, bEnd;
     Model::Brush::VertexList::const_iterator vIt, vEnd;
     
     for (bIt = brushes.begin(), bEnd = brushes.end(); bIt != bEnd; ++bIt) {
         Model::Brush* brush = *bIt;
         const Model::Brush::VertexList vertices = brush->vertices();
         for (vIt = vertices.begin(), vEnd = vertices.end(); vIt != vEnd; ++vIt) {
             const Model::BrushVertex* vertex = *vIt;
             brushVertices[brush].push_back(vertex->position());
             vertexPositions.push_back(vertex->position());
         }
     }
     
     return Ptr(new SnapBrushVerticesCommand(brushes, brushVertices, vertexPositions, snapTo));
 }
 void SnapBrushVerticesCommand::doSelectNewHandlePositions(VertexHandleManager& manager, const Model::BrushList& brushes) {
     const Model::BrushSet brushSet(brushes.begin(), brushes.end());
     manager.reselectVertexHandles(brushSet, m_newVertexPositions, 0.01);
 }
 ChangeEditStateCommand* ChangeEditStateCommand::select(Model::MapDocument& document, Model::Brush& brush) {
     Model::BrushList brushes;
     brushes.push_back(&brush);
     return select(document, brushes);
 }
 void SnapshotCommand::makeSnapshots(const Model::BrushList& brushes) {
     for (unsigned int i = 0; i < brushes.size(); i++) {
         Model::Brush& brush = *brushes[i];
         m_brushes[brush.uniqueId()] = new BrushSnapshot(brush);
     }
 }