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

Function TEST_F

test/Patch.cpp:40–66  ·  view source on GitHub ↗

Checks that snapping a single selected patch vertex is working

Source from the content-addressed store, hash-verified

38
39// Checks that snapping a single selected patch vertex is working
40TEST_F(PatchTest, SnapVertexToGrid)
41{
42 auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
43
44 // Use some off-grid bounds to generate the patch
45 auto patchNode = algorithm::createPatchFromBounds(worldspawn, AABB({ 0,0,0 }, { 11.5, 13, 15 }));
46 Node_setSelected(patchNode, true);
47
48 GlobalGrid().setGridSize(GRID_4);
49
50 // Switch to vertex component mode and select a single patch vertex
51 GlobalSelectionSystem().setSelectionMode(selection::SelectionMode::Component);
52 GlobalSelectionSystem().SetComponentMode(selection::ComponentSelectionMode::Vertex);
53
54 // Pick a vertex from the patch
55 const auto& ctrl = Node_getIPatch(patchNode)->getTransformedCtrlAt(0, 2);
56
57 auto vertexAfterSnapping = ctrl.vertex.getSnapped(GlobalGrid().getGridSize());
58 EXPECT_FALSE(math::isNear(ctrl.vertex, vertexAfterSnapping, 0.01)) << "Vertex should be off-grid";
59
60 selectSinglePatchVertexAt(ctrl.vertex);
61
62 // Snap selection to grid
63 GlobalCommandSystem().executeCommand("SnapToGrid");
64
65 EXPECT_TRUE(math::isNear(ctrl.vertex, vertexAfterSnapping, 0.01)) << "Vertex should be snapped to grid now";
66}
67
68// Checks that snapping a single vertex to grid is undoable
69TEST_F(PatchTest, VertexSnappingIsUndoable)

Callers

nothing calls this directly

Calls 15

createPatchFromBoundsFunction · 0.85
Node_setSelectedFunction · 0.85
Node_getIPatchFunction · 0.85
findFirstPatchFunction · 0.85
findFirstNodeFunction · 0.85
findNodeInLayerFunction · 0.85
comparePatchesFunction · 0.85
SetComponentModeMethod · 0.80
getSnappedMethod · 0.80
xMethod · 0.80

Tested by

no test coverage detected