bool SetBrushFaceAttributesTool::performCopy(const InputState& inputState, const bool applyToBrush) {
     if (!applies(inputState))
         return false;
     
     MapDocumentSPtr document = lock(m_document);
     
     const Model::BrushFaceList& selectedFaces = document->selectedBrushFaces();
     if (selectedFaces.size() != 1)
         return false;
     
     const Model::Hit& hit = inputState.pickResult().query().pickable().type(Model::Brush::BrushHit).occluded().first();
     if (!hit.isMatch())
         return false;
     
     Model::BrushFace* source = selectedFaces.front();
     Model::BrushFace* targetFace = Model::hitToFace(hit);
     Model::Brush* targetBrush = targetFace->brush();
     const Model::BrushFaceList targetList = applyToBrush ? targetBrush->faces() : Model::BrushFaceList(1, targetFace);
     
     const Transaction transaction(document);
     document->deselectAll();
     document->select(targetList);
     if (copyAttributes(inputState))
         document->setFaceAttributes(source->attribs());
     else
         document->setTexture(source->texture());
     document->deselectAll();
     document->select(source);
     return true;
 }
예제 #2
0
 void MapWriter::writeBrush(const Model::Brush& brush, std::ostream& stream) {
     stream << "{\n";
     const Model::FaceList& faces = brush.faces();
     Model::FaceList::const_iterator faceIt, faceEnd;
     for (faceIt = faces.begin(), faceEnd = faces.end(); faceIt != faceEnd; ++faceIt)
         writeFace(**faceIt, stream);
     stream << "}\n";
 }
 BrushSnapshot::BrushSnapshot(const Model::Brush& brush) {
     m_uniqueId = brush.uniqueId();
     const Model::FaceList& brushFaces = brush.faces();
     for (unsigned int i = 0; i < brushFaces.size(); i++) {
         Model::Face* snapshot = new Model::Face(*brushFaces[i]);
         m_faces.push_back(snapshot);
     }
 }
예제 #4
0
 size_t MapWriter::writeBrush(Model::Brush& brush, const size_t lineNumber, FILE* stream) {
     size_t lineCount = 0;
     std::fprintf(stream, "{\n"); lineCount++;
     const Model::FaceList& faces = brush.faces();
     Model::FaceList::const_iterator faceIt, faceEnd;
     for (faceIt = faces.begin(), faceEnd = faces.end(); faceIt != faceEnd; ++faceIt) {
         lineCount += writeFace(**faceIt, lineNumber + lineCount, stream);
     }
     std::fprintf(stream, "}\n"); lineCount++;
     brush.setFilePosition(lineNumber, lineCount);
     return lineCount;
 }