Optimize more imports
parent
72d0b8d697
commit
ad169fbb1e
|
@ -7,7 +7,12 @@
|
|||
|
||||
#include "MapGen.h"
|
||||
|
||||
#include "BiomeAtlas.h"
|
||||
#include "MapGenJob.h"
|
||||
#include "MapGenProps.h"
|
||||
#include "NoiseSample.h"
|
||||
#include "../DefinitionAtlas.h"
|
||||
#include "../../world/chunk/Chunk.h"
|
||||
|
||||
MapGen::MapGen(unsigned int seed, DefinitionAtlas& defs, BiomeAtlas& biomes, std::shared_ptr<MapGenProps> props) :
|
||||
seed(seed),
|
||||
|
|
|
@ -5,11 +5,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
class Chunk;
|
||||
class MapGenJob;
|
||||
class BiomeAtlas;
|
||||
class MapGenProps;
|
||||
class DefinitionAtlas;
|
||||
|
||||
#include "MapGenJob.h"
|
||||
#include "MapGenProps.h"
|
||||
#include "../../util/Vec.h"
|
||||
#include "../../world/chunk/Chunk.h"
|
||||
|
||||
class MapGen {
|
||||
public:
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
//
|
||||
#include "NoiseSample.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include "../../util/Interp.h"
|
||||
|
||||
void NoiseSample::fill(const NoiseSample::fill_function &fun, float precision) {
|
||||
fill(fun, {precision, 1});
|
||||
}
|
||||
|
|
|
@ -5,12 +5,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <noise/noise.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/common.hpp>
|
||||
#include <functional>
|
||||
#include "../../util/Interp.h"
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
class NoiseSample {
|
||||
public:
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "Player.h"
|
||||
#include "WorldInterpolationStream.h"
|
||||
#include "../../../world/chunk/Chunk.h"
|
||||
#include "../../entity/engine/ParticleEntity.h"
|
||||
#include "../../entity/engine/BlockCrackEntity.h"
|
||||
|
||||
|
|
|
@ -5,13 +5,16 @@
|
|||
#include "WorldInterpolationStream.h"
|
||||
|
||||
#include "../../../def/ClientGame.h"
|
||||
#include "../../../def/gen/MapGen.h"
|
||||
#include "../../../world/chunk/Chunk.h"
|
||||
#include "../../../util/net/PacketView.h"
|
||||
|
||||
WorldInterpolationStream::WorldInterpolationStream(unsigned int seed, ClientGame& game) :
|
||||
props(std::make_shared<MapGenProps>(seed)),
|
||||
gen(seed, game.defs, game.biomes, props) {
|
||||
gen(new MapGen(seed, game.defs, game.biomes, props)) {
|
||||
|
||||
threads.reserve(THREADS);
|
||||
for (int i = 0; i < THREADS; i++) threads.emplace_back(&gen);
|
||||
for (int i = 0; i < THREADS; i++) threads.emplace_back(gen);
|
||||
}
|
||||
|
||||
void WorldInterpolationStream::queuePacket(std::unique_ptr<PacketView> p) {
|
||||
|
@ -71,7 +74,7 @@ std::unique_ptr<std::vector<std::shared_ptr<Chunk>>> WorldInterpolationStream::u
|
|||
return finishedChunks;
|
||||
}
|
||||
|
||||
WorldInterpolationStream::Thread::Thread(MapGen *gen) : gen(gen),
|
||||
WorldInterpolationStream::Thread::Thread(MapGen* gen) : gen(gen),
|
||||
thread(std::bind(&WorldInterpolationStream::Thread::exec, this)) {}
|
||||
|
||||
void WorldInterpolationStream::Thread::exec() {
|
||||
|
@ -82,7 +85,7 @@ void WorldInterpolationStream::Thread::exec() {
|
|||
if (u.job == JobType::PACKET) {
|
||||
empty = false;
|
||||
u.chunk = std::make_shared<Chunk>();
|
||||
u.chunk->deserialize(*u.packet);
|
||||
u.chunk->deserialize(u.packet->d);
|
||||
u.locked = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -6,13 +6,19 @@
|
|||
|
||||
#include <list>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "graph/MeshFarMap.h"
|
||||
#include "../../../def/gen/MapGen.h"
|
||||
#include "../../../world/chunk/Chunk.h"
|
||||
#include "../../../util/net/PacketView.h"
|
||||
|
||||
class Chunk;
|
||||
class MapGen;
|
||||
class ClientGame;
|
||||
class MapGenProps;
|
||||
|
||||
class WorldInterpolationStream {
|
||||
public:
|
||||
|
@ -60,8 +66,8 @@ private:
|
|||
std::thread thread;
|
||||
};
|
||||
|
||||
MapGen* gen;
|
||||
std::shared_ptr<MapGenProps> props;
|
||||
MapGen gen;
|
||||
|
||||
std::vector<Thread> threads;
|
||||
std::list<std::unique_ptr<PacketView>> queuedPacketTasks;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "ServerGenStream.h"
|
||||
|
||||
#include "../../def/ServerGame.h"
|
||||
#include "../../world/chunk/Chunk.h"
|
||||
#include "../../def/gen/MapGenProps.h"
|
||||
|
||||
ServerGenStream::ServerGenStream(unsigned int seed, ServerGame& game) :
|
||||
props(std::make_shared<MapGenProps>(seed)),
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "ServerGenStream.h"
|
||||
#include "../conn/ClientList.h"
|
||||
#include "../conn/ServerClient.h"
|
||||
#include "../../world/chunk/Chunk.h"
|
||||
#include "../../world/chunk/MapBlock.h"
|
||||
|
||||
ServerWorld::ServerWorld(unsigned int seed, ServerGame& game, ClientList& clients) :
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "Dimension.h"
|
||||
|
||||
#include "chunk/Chunk.h"
|
||||
#include "../def/DefinitionAtlas.h"
|
||||
|
||||
bool Dimension::setBlock(glm::ivec3 pos, unsigned int block) {
|
||||
if (!DimensionBase::setBlock(pos, block)) return false;
|
||||
|
@ -44,10 +45,10 @@ std::unordered_set<glm::ivec3, Vec::ivec3> Dimension::calculateEdgeLight(glm::iv
|
|||
else if (ypos && l.y == 3) calculateVerticalEdge(getChunk(chunkPos + glm::ivec3 {0, 1, 0}), self);
|
||||
|
||||
if (xpos && l.x == 3) calculateHorizontalEdge(self, getChunk(chunkPos + glm::ivec3 {1, 0, 0}));
|
||||
if (xneg && l.x == 0) calculateHorizontalEdge(self, getChunk(chunkPos + glm::ivec3 {-1, 0, 0}));
|
||||
else if (xneg && l.x == 0) calculateHorizontalEdge(self, getChunk(chunkPos + glm::ivec3 {-1, 0, 0}));
|
||||
|
||||
if (zpos && l.z == 3) calculateHorizontalEdge(self, getChunk(chunkPos + glm::ivec3 {0, 0, 1}));
|
||||
if (zneg && l.z == 0) calculateHorizontalEdge(self, getChunk(chunkPos + glm::ivec3 {0, 0, -1}));
|
||||
else if (zneg && l.z == 0) calculateHorizontalEdge(self, getChunk(chunkPos + glm::ivec3 {0, 0, -1}));
|
||||
}
|
||||
|
||||
return propogateRemoveNodes();
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "../world/chunk/Chunk.h"
|
||||
#include "../world/chunk/Region.h"
|
||||
#include "../util/net/PacketView.h"
|
||||
#include "../world/chunk/MapBlock.h"
|
||||
#include "../lua/api/class/LocalLuaEntity.h"
|
||||
#include "../game/scene/world/MeshGenStream.h"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "ServerDimension.h"
|
||||
|
||||
#include "chunk/Chunk.h"
|
||||
#include "chunk/Region.h"
|
||||
#include "chunk/MapBlock.h"
|
||||
#include "../def/gen/MapGen.h"
|
||||
|
|
|
@ -8,8 +8,9 @@
|
|||
|
||||
#include "Chunk.h"
|
||||
|
||||
#include "../../def/DefinitionAtlas.h"
|
||||
#include "../../util/net/Serializer.h"
|
||||
#include "../../util/net/PacketView.h"
|
||||
#include "../../util/net/Deserializer.h"
|
||||
|
||||
Chunk::Chunk(const std::vector<unsigned int>& blocks, const std::vector<unsigned short>& biomes) :
|
||||
Chunk(blocks, biomes, {0, 0, 0}) {}
|
||||
|
@ -61,8 +62,8 @@ std::string Chunk::serialize() {
|
|||
return s.data;
|
||||
}
|
||||
|
||||
void Chunk::deserialize(PacketView& packet) {
|
||||
std::string gzipped = packet.d.read<std::string>();
|
||||
void Chunk::deserialize(Deserializer& d) {
|
||||
std::string gzipped = d.read<std::string>();
|
||||
if (!gzip::is_compressed(gzipped.data(), gzipped.length())) throw "Invalid Blocks GZip Data.";
|
||||
|
||||
std::vector<unsigned char> sunLight {};
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
#include "../../util/RIE.h"
|
||||
#include "../../util/Space.h"
|
||||
#include "../../def/gen/BiomeAtlas.h"
|
||||
#include "../../def/DefinitionAtlas.h"
|
||||
#include "../../util/net/PacketView.h"
|
||||
|
||||
class Deserializer;
|
||||
|
||||
class Chunk {
|
||||
public:
|
||||
|
@ -59,7 +59,7 @@ public:
|
|||
inline void setLight(unsigned int ind, unsigned char channel, unsigned char light);
|
||||
|
||||
std::string serialize();
|
||||
void deserialize(PacketView& packet);
|
||||
void deserialize(Deserializer& d);
|
||||
|
||||
void recalculateRenderableBlocks();
|
||||
|
||||
|
@ -85,7 +85,7 @@ private:
|
|||
};
|
||||
|
||||
inline unsigned int Chunk::getBlock(const glm::ivec3& pos) const {
|
||||
if (pos.x > 15 || pos.x < 0 || pos.y > 15 || pos.y < 0 || pos.z > 15 || pos.z < 0) return DefinitionAtlas::INVALID;
|
||||
if (pos.x > 15 || pos.x < 0 || pos.y > 15 || pos.y < 0 || pos.z > 15 || pos.z < 0) return 0; // Invalid
|
||||
return getBlock(Space::Block::index(pos));
|
||||
}
|
||||
|
||||
|
@ -95,12 +95,12 @@ inline bool Chunk::setBlock(const glm::ivec3& pos, unsigned int blk) {
|
|||
}
|
||||
|
||||
inline unsigned int Chunk::getBlock(unsigned int ind) const {
|
||||
if (ind >= 4096) return DefinitionAtlas::INVALID;
|
||||
if (ind >= 4096) return 0; // Invalid
|
||||
return RIE::read<unsigned int>(ind, blocks, 4096);
|
||||
}
|
||||
|
||||
inline unsigned short Chunk::getBiome(unsigned int ind) const {
|
||||
if (ind >= 4096) return BiomeAtlas::INVALID;
|
||||
if (ind >= 4096) return 0; // Invalid
|
||||
return RIE::read<unsigned short>(ind, biomes, 4096);
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ inline bool Chunk::setBiome(unsigned int ind, unsigned short bio) {
|
|||
}
|
||||
|
||||
inline unsigned short Chunk::getBiome(const glm::ivec3& pos) const {
|
||||
if (pos.x > 15 || pos.x < 0 || pos.y > 15 || pos.y < 0 || pos.z > 15 || pos.z < 0) return BiomeAtlas::INVALID;
|
||||
if (pos.x > 15 || pos.x < 0 || pos.y > 15 || pos.y < 0 || pos.z > 15 || pos.z < 0) return 0; // Invalid
|
||||
return getBiome(Space::Block::index(pos));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue