Checks that snapping a single selected patch vertex is working
| 38 | |
| 39 | // Checks that snapping a single selected patch vertex is working |
| 40 | TEST_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 |
| 69 | TEST_F(PatchTest, VertexSnappingIsUndoable) |
nothing calls this directly
no test coverage detected