MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / performFaceVertexManipulationTest

Function performFaceVertexManipulationTest

test/TextureTool.cpp:1411–1446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1409}
1410
1411void performFaceVertexManipulationTest(bool cancelOperation, std::vector<std::size_t> vertexIndicesToManipulate,
1412 std::function<void(IFace&, const std::vector<Vector2>&, const std::vector<Vector2>&)> assertionFunc)
1413{
1414 auto brush = setupBrushNodeForTextureTool();
1415 auto faceUp = algorithm::findBrushFaceWithNormal(Node_getIBrush(brush), Vector3(0, 0, 1));
1416
1417 // Remember the texcoords before manipulation
1418 std::vector<Vector2> oldTexcoords;
1419 for (const auto& vertex : faceUp->getWinding()) { oldTexcoords.push_back(vertex.texcoord); }
1420
1421 // Get the texture space bounds of this face
1422 auto bounds = algorithm::getTextureSpaceBounds(*faceUp);
1423 bounds.extents *= 1.2f;
1424
1425 render::TextureToolView view;
1426 view.constructFromTextureSpaceBounds(bounds, TEXTOOL_WIDTH, TEXTOOL_HEIGHT);
1427
1428 GlobalTextureToolSelectionSystem().setSelectionMode(textool::SelectionMode::Vertex);
1429
1430 // Select a certain number of vertices
1431 for (auto index : vertexIndicesToManipulate)
1432 {
1433 performPointSelection(oldTexcoords[index], view);
1434 }
1435
1436 EXPECT_EQ(getAllSelectedComponentNodes().size(), 1) << "No component node selected";
1437
1438 // Drag-manipulate the first odd vertex
1439 auto firstIndex = vertexIndicesToManipulate.front();
1440 dragManipulateSelectionTowardsLowerRight(oldTexcoords[firstIndex], view, cancelOperation); // optionally cancel the operation
1441
1442 std::vector<Vector2> changedTexcoords;
1443 for (const auto& vertex : faceUp->getWinding()) { changedTexcoords.push_back(vertex.texcoord); }
1444
1445 assertionFunc(*faceUp, oldTexcoords, changedTexcoords);
1446}
1447
1448inline void assertAllCoordsUnchanged(IFace&, const std::vector<Vector2>& oldTexcoords, const std::vector<Vector2>& changedTexcoords)
1449{

Callers 1

TEST_FFunction · 0.85

Calls 11

findBrushFaceWithNormalFunction · 0.85
Node_getIBrushFunction · 0.85
getTextureSpaceBoundsFunction · 0.85
performPointSelectionFunction · 0.85
push_backMethod · 0.45
setSelectionModeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected