refactor: change pointer parameters to references for Level and Content in various classes

This commit is contained in:
MihailRis
2024-12-25 18:53:53 +03:00
parent ef2c0b2370
commit c1b311f3c4
41 changed files with 258 additions and 251 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ std::unique_ptr<VoxelFragment> VoxelFragment::create(
std::vector<std::string> blockNames {CORE_AIR};
std::unordered_map<blockid_t, blockid_t> blocksRegistered {{0, 0}};
auto contentIndices = level.content->getIndices();
auto contentIndices = level.content.getIndices();
for (size_t i = 0 ; i < voxels.size(); i++) {
blockid_t id = volVoxels[i].id;
blockid_t index;
+6 -6
View File
@@ -24,7 +24,7 @@ static inline constexpr uint MAX_PARAMETERS = 4;
static inline constexpr uint BASIC_PROTOTYPE_LAYERS = 5;
WorldGenerator::WorldGenerator(
const GeneratorDef& def, const Content* content, uint64_t seed
const GeneratorDef& def, const Content& content, uint64_t seed
)
: def(def),
content(content),
@@ -66,10 +66,10 @@ WorldGenerator::WorldGenerator(
});
for (int i = 0; i < def.structures.size(); i++) {
// pre-calculate rotated structure variants
def.structures[i]->fragments[0]->prepare(*content);
def.structures[i]->fragments[0]->prepare(content);
for (int j = 1; j < 4; j++) {
def.structures[i]->fragments[j] =
def.structures[i]->fragments[j-1]->rotated(*content);
def.structures[i]->fragments[j-1]->rotated(content);
}
}
}
@@ -367,7 +367,7 @@ void WorldGenerator::generatePlants(
int chunkZ,
const Biome** biomes
) {
const auto& indices = content->getIndices()->blocks;
const auto& indices = content.getIndices()->blocks;
util::PseudoRandom plantsRand;
plantsRand.setSeed(chunkX, chunkZ);
@@ -431,7 +431,7 @@ void WorldGenerator::generate(voxel* voxels, int chunkX, int chunkZ) {
std::memset(voxels, 0, sizeof(voxel) * CHUNK_VOL);
const auto& indices = content->getIndices()->blocks;
const auto& indices = content.getIndices()->blocks;
const auto& biomes = prototype.biomes.get();
for (uint z = 0; z < CHUNK_D; z++) {
for (uint x = 0; x < CHUNK_W; x++) {
@@ -531,7 +531,7 @@ void WorldGenerator::generateLine(
voxel* voxels,
int chunkX, int chunkZ
) {
const auto& indices = content->getIndices()->blocks;
const auto& indices = content.getIndices()->blocks;
int cgx = chunkX * CHUNK_W;
int cgz = chunkZ * CHUNK_D;
+2 -2
View File
@@ -50,7 +50,7 @@ class WorldGenerator {
/// @param def generator definition
const GeneratorDef& def;
/// @param content world content
const Content* content;
const Content& content;
/// @param seed world seed
uint64_t seed;
/// @brief Chunk prototypes main storage
@@ -120,7 +120,7 @@ class WorldGenerator {
public:
WorldGenerator(
const GeneratorDef& def,
const Content* content,
const Content& content,
uint64_t seed
);
~WorldGenerator();