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

Function weldPatchPool

radiantcore/patch/algorithm/General.cpp:379–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377}
378
379void weldPatchPool()
380{
381 auto selectedPatches = selection::algorithm::getSelectedPatches();
382
383 // Sort these patches into buckets according to their parents
384 // This step may not be strictly necessary as weldPatches() checks the parents
385 // but we might save a bit of unnecessary comparison work
386 std::map<scene::INodePtr, std::vector<PatchNodePtr>> patchesByEntity;
387
388 for (const auto& patch : selectedPatches)
389 {
390 patchesByEntity[patch->getParent()].push_back(patch);
391 }
392
393 std::size_t numPatchesCreated = 0;
394
395 for (const auto& pair : patchesByEntity)
396 {
397 // Try to combine each patch of this list with the rest of them O(2n)
398 for (auto p1 = pair.second.begin(); p1 != pair.second.end(); ++p1)
399 {
400 if (!(*p1)->getParent()) continue; // patch has been merged already
401
402 for (auto p2 = p1 + 1; p2 != pair.second.end(); ++p2)
403 {
404 if (!(*p2)->getParent()) continue;// patch has been merged already
405
406 try
407 {
408 weldPatches(*p1, *p2);
409 ++numPatchesCreated;
410 }
411 catch (const cmd::ExecutionFailure&)
412 {
413 continue; // failed to merge these two
414 }
415 }
416 }
417 }
418
419 if (numPatchesCreated == 0)
420 {
421 throw cmd::ExecutionFailure(_("Cannot weld, patches need have the same parent entity."));
422 }
423}
424
425void weldSelectedPatches(const cmd::ArgumentList& args)
426{

Callers 1

weldSelectedPatchesFunction · 0.85

Calls 8

getSelectedPatchesFunction · 0.85
weldPatchesFunction · 0.85
ExecutionFailureClass · 0.85
_Function · 0.50
push_backMethod · 0.45
getParentMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected