bool SnapVerticesCommand::performDo() {
     
     makeSnapshots(m_brushes);
     document().brushesWillChange(m_brushes);
     
     Model::BrushList::const_iterator it, end;
     for (it = m_brushes.begin(), end = m_brushes.end(); it != end; ++it) {
         Model::Brush& brush = **it;
         brush.snap(m_snapTo);
     }
     
     document().brushesDidChange(m_brushes);
     return true;
 }
        bool SplitEdgesCommand::performDo() {
            if (!canDo())
                return false;
            
            m_vertices.clear();
            makeSnapshots(m_brushes);
            document().brushesWillChange(m_brushes);

            BrushEdgeMap::const_iterator it, end;
            for (it = m_brushEdges.begin(), end = m_brushEdges.end(); it != end; ++it) {
                Model::Brush* brush = it->first;
                const Model::EdgeInfo& edgeInfo = it->second;
                Vec3f newVertexPosition = brush->splitEdge(edgeInfo, m_delta);
                m_vertices.insert(newVertexPosition);
            }

            document().brushesDidChange(m_brushes);
            return true;
        }
        bool MoveEdgesCommand::performDo() {
            if (!canDo())
                return false;
            
            m_edges.clear();
            makeSnapshots(m_brushes);
            document().brushesWillChange(m_brushes);
            
            BrushEdgesMap::const_iterator it, end;
            for (it = m_brushEdges.begin(), end = m_brushEdges.end(); it != end; ++it) {
                Model::Brush* brush = it->first;
                const Model::EdgeList& edges = it->second;
                const Model::EdgeList newEdges = brush->moveEdges(edges, m_delta);
                m_edges.insert(m_edges.end(), newEdges.begin(), newEdges.end());
            }

            document().brushesDidChange(m_brushes);
            return true;
        }
        bool SplitEdgesCommand::performDo() {
            if (!canDo())
                return false;
            
            m_vertices.clear();
            makeSnapshots(m_brushes);
            document().brushesWillChange(m_brushes);

            Model::EdgeList::const_iterator eIt, eEnd;
            for (eIt = m_edges.begin(), eEnd = m_edges.end(); eIt != eEnd; ++eIt) {
                Model::Edge* edge = *eIt;
                Model::Brush* brush = edge->left->face->brush();
                Vec3f newVertexPosition = brush->splitEdge(edge, m_delta);
                m_vertices.insert(newVertexPosition);
            }

            document().brushesDidChange(m_brushes);
            return true;
        }
        bool MoveVerticesCommand::performDo() {
            if (!canDo())
                return false;
            
            m_vertices.clear();
            makeSnapshots(m_brushes);
            document().brushesWillChange(m_brushes);

            BrushVerticesMap::const_iterator it, end;
            for (it = m_brushVertices.begin(), end = m_brushVertices.end(); it != end; ++it) {
                Model::Brush* brush = it->first;
                const Vec3f::List& oldVertexPositions = it->second;
                Vec3f::List newVertexPositions = brush->moveVertices(oldVertexPositions, m_delta);
                m_vertices.insert(newVertexPositions.begin(), newVertexPositions.end());
            }
            
            document().brushesDidChange(m_brushes);
            return true;
        }
Example #6
0
        bool MoveFacesCommand::performDo() {
            if (!canDo())
                return false;

            m_handleManager.remove(m_brushes);
            makeSnapshots(m_brushes);
            document().brushesWillChange(m_brushes);
            m_facesAfter.clear();

            Model::BrushFacesMap::const_iterator it, end;
            for (it = m_brushFaces.begin(), end = m_brushFaces.end(); it != end; ++it) {
                Model::Brush* brush = it->first;
                const Model::FaceInfoList& faceInfos = it->second;
                const Model::FaceInfoList newFaces = brush->moveFaces(faceInfos, m_delta);
                m_facesAfter.insert(m_facesAfter.end(), newFaces.begin(), newFaces.end());
            }

            document().brushesDidChange(m_brushes);
            m_handleManager.add(m_brushes);
            m_handleManager.selectFaceHandles(m_facesAfter);

            return true;
        }