Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
optimized mesh chunking
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Dec 12, 2023
1 parent 2c7e996 commit ad6e5ce
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion doodads/ores/aether.doodad
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ radius = 40
buildable = true

[starting]
distance = 500, 500
distance = 600, 600
count = 0, 0

[preview]
Expand Down
6 changes: 3 additions & 3 deletions doodads/ores/crystals.doodad
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package = unnatural/base/ores/ores.pack
prototype = unnatural/base/ores/crystals_deposit.proto

[generating]
count = 10
count = 5
priority = 14

[requirements]
radius = 40
buildable = true

[starting]
distance = 500, 500
count = 0, 0
distance = 400, 500
count = 1, 1

[preview]
height = 100
4 changes: 2 additions & 2 deletions doodads/ores/metal.doodad
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ radius = 40
buildable = true

[starting]
distance = 200, 300
count = 2, 3
distance = 150, 250
count = 2, 2

[preview]
height = 50
2 changes: 1 addition & 1 deletion doodads/ores/oil.doodad
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ radius = 40
buildable = true

[starting]
distance = 300, 500
distance = 300, 400
count = 1, 1

[preview]
Expand Down
1 change: 1 addition & 0 deletions sources/meshGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ namespace unnatural
{
MeshChunkingConfig cfg;
cfg.maxSurfaceArea = 800000;
cfg.parallelize = true;
auto r = meshChunking(+mesh, cfg);
//for (auto &it : r)
// meshMergePlanar(+it, {});
Expand Down
11 changes: 6 additions & 5 deletions sources/startingPositions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ namespace unnatural

namespace
{
Real minimumDistance(const std::vector<uint32> &candidates)
Real minimumDistance(PointerRange<const uint32> positions)
{
const uint32 n = candidates.size();
CAGE_ASSERT(n > 0);
const uint32 n = positions.size();
if (n < 2)
return 0;
Real score = Real::Infinity();
for (uint32 i = 0; i < n - 1; i++)
for (uint32 j = i + 1; j < n; j++)
score = min(score, distance(tiles[candidates[i]].position, tiles[candidates[j]].position));
score = min(score, distance(tiles[positions[i]].position, tiles[positions[j]].position));
return score;
}

Expand Down Expand Up @@ -54,7 +55,7 @@ namespace unnatural
if (it->buildable)
candidates.push_back(it.index);
filterPositionsByBuildableRadius(candidates);
CAGE_LOG(SeverityEnum::Info, "generator", Stringizer() + "starting position candidates: " + candidates.size() + " (after eliminating due to insufficient builable neighbors)");
CAGE_LOG(SeverityEnum::Info, "generator", Stringizer() + "starting position candidates: " + candidates.size() + " (after eliminating due to insufficient buildable neighbors)");
return candidates;
}

Expand Down

0 comments on commit ad6e5ce

Please sign in to comment.