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

Function createWorldspawnPatch

test/PatchIterators.cpp:16–42  ·  view source on GitHub ↗

Patch will be parallel to the XY plane, its vertex coordinates x = col*64 and y = row*64

Source from the content-addressed store, hash-verified

14
15// Patch will be parallel to the XY plane, its vertex coordinates x = col*64 and y = row*64
16inline 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

Callers 1

TEST_FFunction · 0.85

Calls 6

createPatchMethod · 0.80
addChildNodeMethod · 0.80
getPatchMethod · 0.80
setDimsMethod · 0.45
setMethod · 0.45
controlPointsChangedMethod · 0.45

Tested by

no test coverage detected