Patch will be parallel to the XY plane, its vertex coordinates x = col*64 and y = row*64
| 14 | |
| 15 | // Patch will be parallel to the XY plane, its vertex coordinates x = col*64 and y = row*64 |
| 16 | inline IPatchNodePtr createWorldspawnPatch(std::size_t width, std::size_t height) |
| 17 | { |
| 18 | auto world = GlobalMapModule().findOrInsertWorldspawn(); |
| 19 | |
| 20 | auto sceneNode = GlobalPatchModule().createPatch(patch::PatchDefType::Def2); |
| 21 | auto patchNode = std::dynamic_pointer_cast<IPatchNode>(sceneNode); |
| 22 | |
| 23 | world->addChildNode(sceneNode); |
| 24 | |
| 25 | auto& patch = patchNode->getPatch(); |
| 26 | |
| 27 | patch.setDims(width, height); |
| 28 | |
| 29 | for (auto row = 0; row < height; ++row) |
| 30 | { |
| 31 | for (auto col = 0; col < width; ++col) |
| 32 | { |
| 33 | patch.ctrlAt(row, col).vertex.set(col * 64, row * 64, 0); |
| 34 | patch.ctrlAt(row, col).texcoord[0] = col * 1.0 / (width - 1.0); |
| 35 | patch.ctrlAt(row, col).texcoord[1] = row * 1.0 / (height - 1.0); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | patch.controlPointsChanged(); |
| 40 | |
| 41 | return patchNode; |
| 42 | } |
| 43 | |
| 44 | } |
| 45 |
no test coverage detected