MCPcopy Create free account
hub / github.com/chrxh/alien / correctConnections

Method correctConnections

source/EngineInterface/DescriptionEditService.cpp:390–419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390void DescriptionEditService::correctConnections(ClusteredDataDescription& data, IntVector2D const& worldSize)
391{
392 auto threshold = std::min(worldSize.x, worldSize.y) /3;
393 std::unordered_map<uint64_t, CellDescription&> cellById;
394 for (auto& cluster : data.clusters) {
395 for (auto& cell : cluster.cells) {
396 cellById.emplace(cell.id, cell);
397 }
398 }
399 for (auto& cluster : data.clusters) {
400 for (auto& cell: cluster.cells) {
401 std::vector<ConnectionDescription> newConnections;
402 float angleToAdd = 0;
403 for (auto connection : cell.connections) {
404 auto& connectingCell = cellById.at(connection.cellId);
405 if (/*spaceCalculator.distance*/Math::length(cell.pos - connectingCell.pos) > threshold) {
406 angleToAdd += connection.angleFromPrevious;
407 } else {
408 connection.angleFromPrevious += angleToAdd;
409 angleToAdd = 0;
410 newConnections.emplace_back(connection);
411 }
412 }
413 if (angleToAdd > NEAR_ZERO && !newConnections.empty()) {
414 newConnections.front().angleFromPrevious += angleToAdd;
415 }
416 cell.connections = newConnections;
417 }
418 }
419}
420
421void DescriptionEditService::randomizeCellColors(ClusteredDataDescription& data, std::vector<int> const& colorCodes)
422{

Callers 2

TEST_FFunction · 0.80
onResizingMethod · 0.80

Calls

no outgoing calls

Tested by 1

TEST_FFunction · 0.64