MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / determineLiquidLevel

Method determineLiquidLevel

source/game/StarWorldGeneration.cpp:1449–1474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1447}
1448
1449Map<Vec2I, float> WorldGenerator::determineLiquidLevel(Set<Vec2I> const& spots, Set<Vec2I> const& filled) {
1450 Set<Vec2I> openSet(spots);
1451 Map<Vec2I, float> results;
1452
1453 auto geometry = m_worldServer->geometry();
1454
1455 while (openSet.size() > 0) {
1456 Set<Vec2I> cluster;
1457 Set<Vec2I> openCluster;
1458 openCluster.add(*(openSet.begin()));
1459 while (openCluster.size() > 0) {
1460 Vec2I node = *(openCluster.begin());
1461 openCluster.remove(node);
1462 if (openSet.contains(node)) {
1463 openSet.remove(node);
1464 cluster.add(node);
1465 openCluster.add(geometry.xwrap(Vec2I(node.x(), node.y() + 1)));
1466 openCluster.add(geometry.xwrap(Vec2I(node.x(), node.y() - 1)));
1467 openCluster.add(geometry.xwrap(Vec2I(node.x() + 1, node.y())));
1468 openCluster.add(geometry.xwrap(Vec2I(node.x() - 1, node.y())));
1469 }
1470 }
1471 levelCluster(cluster, filled, results);
1472 }
1473 return results;
1474}
1475
1476void WorldGenerator::levelCluster(Set<Vec2I>& cluster, Set<Vec2I> const& filled, Map<Vec2I, float>& results) {
1477 int maxY = std::numeric_limits<int>::min();

Callers

nothing calls this directly

Calls 9

xMethod · 0.80
yMethod · 0.80
geometryMethod · 0.45
sizeMethod · 0.45
addMethod · 0.45
beginMethod · 0.45
removeMethod · 0.45
containsMethod · 0.45
xwrapMethod · 0.45

Tested by

no test coverage detected