mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 15:01:49 +00:00
Merge branch 'main' into physics-upgrade
This commit is contained in:
commit
454aa20546
9 changed files with 32 additions and 12 deletions
|
|
@ -32,6 +32,7 @@
|
||||||
glew
|
glew
|
||||||
zlib
|
zlib
|
||||||
libpng
|
libpng
|
||||||
|
freetype
|
||||||
libvorbis
|
libvorbis
|
||||||
openal
|
openal
|
||||||
luajit
|
luajit
|
||||||
|
|
@ -39,7 +40,7 @@
|
||||||
entt
|
entt
|
||||||
mesa
|
mesa
|
||||||
freeglut
|
freeglut
|
||||||
]; # libglvnd
|
];
|
||||||
|
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
glfw
|
glfw
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -186,7 +186,7 @@ void BlocksController::randomTick(int tickid, int parts, uint padding) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto& chunk = chunks.getChunks()[index];
|
auto& chunk = chunks.getChunks()[index];
|
||||||
if (chunk == nullptr || !chunk->flags.lighted) {
|
if (chunk == nullptr || !chunk->flags.ready) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (chunk->lastRandomTickId == randomTickId) {
|
if (chunk->lastRandomTickId == randomTickId) {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,11 @@ ChunksController::ChunksController(Level& level)
|
||||||
ChunksController::~ChunksController() = default;
|
ChunksController::~ChunksController() = default;
|
||||||
|
|
||||||
void ChunksController::update(
|
void ChunksController::update(
|
||||||
int64_t maxDuration, int loadDistance, uint padding, Player& player
|
int64_t maxDuration,
|
||||||
|
int loadDistance,
|
||||||
|
uint padding,
|
||||||
|
Player& player,
|
||||||
|
bool isLocalPlayer
|
||||||
) const {
|
) const {
|
||||||
const auto& position = player.getPosition();
|
const auto& position = player.getPosition();
|
||||||
int centerX = floordiv<CHUNK_W>(glm::floor(position.x));
|
int centerX = floordiv<CHUNK_W>(glm::floor(position.x));
|
||||||
|
|
@ -50,7 +54,7 @@ void ChunksController::update(
|
||||||
|
|
||||||
for (uint i = 0; i < MAX_WORK_PER_FRAME; i++) {
|
for (uint i = 0; i < MAX_WORK_PER_FRAME; i++) {
|
||||||
timeutil::Timer timer;
|
timeutil::Timer timer;
|
||||||
if (loadVisible(player, padding)) {
|
if (loadVisible(player, padding, isLocalPlayer)) {
|
||||||
int64_t mcs = timer.stop();
|
int64_t mcs = timer.stop();
|
||||||
if (mcstotal + mcs < maxDuration * 1000) {
|
if (mcstotal + mcs < maxDuration * 1000) {
|
||||||
mcstotal += mcs;
|
mcstotal += mcs;
|
||||||
|
|
@ -77,7 +81,9 @@ bool ChunksController::isInLoadingZone(
|
||||||
return distance < minDistance;
|
return distance < minDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChunksController::loadVisible(const Player& player, uint padding) const {
|
bool ChunksController::loadVisible(
|
||||||
|
const Player& player, uint padding, bool isLocalPlayer
|
||||||
|
) const {
|
||||||
auto& chunks = *player.chunks;
|
auto& chunks = *player.chunks;
|
||||||
int sizeX = chunks.getWidth();
|
int sizeX = chunks.getWidth();
|
||||||
int sizeY = chunks.getHeight();
|
int sizeY = chunks.getHeight();
|
||||||
|
|
@ -113,7 +119,7 @@ bool ChunksController::loadVisible(const Player& player, uint padding) const {
|
||||||
auto& chunk = chunks.getChunks()[index];
|
auto& chunk = chunks.getChunks()[index];
|
||||||
if (chunk != nullptr) {
|
if (chunk != nullptr) {
|
||||||
if (chunk->flags.loaded && !chunk->flags.lighted) {
|
if (chunk->flags.loaded && !chunk->flags.lighted) {
|
||||||
if (buildLights(player, chunk)) {
|
if (isLocalPlayer && buildLights(player, chunk)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ private:
|
||||||
std::unique_ptr<WorldGenerator> generator;
|
std::unique_ptr<WorldGenerator> generator;
|
||||||
|
|
||||||
/// @brief Process one chunk: load it or calculate lights for it
|
/// @brief Process one chunk: load it or calculate lights for it
|
||||||
bool loadVisible(const Player& player, uint padding) const;
|
bool loadVisible(const Player& player, uint padding, bool isLocalPlayer) const;
|
||||||
bool buildLights(const Player& player, const std::shared_ptr<Chunk>& chunk) const;
|
bool buildLights(const Player& player, const std::shared_ptr<Chunk>& chunk) const;
|
||||||
void createChunk(const Player& player, int x, int y) const;
|
void createChunk(const Player& player, int x, int y) const;
|
||||||
public:
|
public:
|
||||||
|
|
@ -29,7 +29,11 @@ public:
|
||||||
|
|
||||||
/// @param maxDuration milliseconds reserved for chunks loading
|
/// @param maxDuration milliseconds reserved for chunks loading
|
||||||
void update(
|
void update(
|
||||||
int64_t maxDuration, int loadDistance, uint padding, Player& player
|
int64_t maxDuration,
|
||||||
|
int loadDistance,
|
||||||
|
uint padding,
|
||||||
|
Player& player,
|
||||||
|
bool isLocalPlayer
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
bool isInLoadingZone(const Player& player, uint padding, int x, int z) const;
|
bool isInLoadingZone(const Player& player, uint padding, int x, int z) const;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ LevelController::LevelController(
|
||||||
settings(engine.getSettings()),
|
settings(engine.getSettings()),
|
||||||
level(std::move(levelPtr)),
|
level(std::move(levelPtr)),
|
||||||
chunks(std::make_unique<ChunksController>(*level)),
|
chunks(std::make_unique<ChunksController>(*level)),
|
||||||
playerTickClock(20, 3) {
|
playerTickClock(20, 3),
|
||||||
|
clientPlayer(clientPlayer) {
|
||||||
|
|
||||||
level->events->listen(LevelEventType::CHUNK_PRESENT, [](auto, Chunk* chunk) {
|
level->events->listen(LevelEventType::CHUNK_PRESENT, [](auto, Chunk* chunk) {
|
||||||
scripting::on_chunk_present(*chunk, chunk->flags.loaded);
|
scripting::on_chunk_present(*chunk, chunk->flags.loaded);
|
||||||
|
|
@ -61,7 +62,7 @@ LevelController::LevelController(
|
||||||
player->chunks->configure(
|
player->chunks->configure(
|
||||||
std::floor(position.x), std::floor(position.z), 1
|
std::floor(position.x), std::floor(position.z), 1
|
||||||
);
|
);
|
||||||
chunks->update(16, 1, 0, *player);
|
chunks->update(16, 1, 0, *player, player.get() == clientPlayer);
|
||||||
if (player->chunks->get(
|
if (player->chunks->get(
|
||||||
std::floor(position.x), 0, std::floor(position.z)
|
std::floor(position.x), 0, std::floor(position.z)
|
||||||
)) {
|
)) {
|
||||||
|
|
@ -91,7 +92,8 @@ void LevelController::update(float delta, bool pause) {
|
||||||
settings.chunks.loadSpeed.get(),
|
settings.chunks.loadSpeed.get(),
|
||||||
settings.chunks.loadDistance.get(),
|
settings.chunks.loadDistance.get(),
|
||||||
settings.chunks.padding.get(),
|
settings.chunks.padding.get(),
|
||||||
*player
|
*player,
|
||||||
|
player.get() == clientPlayer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!pause) {
|
if (!pause) {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ class LevelController {
|
||||||
std::unique_ptr<ChunksController> chunks;
|
std::unique_ptr<ChunksController> chunks;
|
||||||
|
|
||||||
util::Clock playerTickClock;
|
util::Clock playerTickClock;
|
||||||
|
|
||||||
|
Player* clientPlayer;
|
||||||
public:
|
public:
|
||||||
CallbacksSet<> preQuitCallbacks;
|
CallbacksSet<> preQuitCallbacks;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -194,5 +194,10 @@ State* lua::create_state(const EnginePaths& paths, StateType stateType) {
|
||||||
}
|
}
|
||||||
pop(L);
|
pop(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stateType == StateType::GENERATOR) {
|
||||||
|
pushnil(L);
|
||||||
|
setglobal(L, "ffi");
|
||||||
|
}
|
||||||
return L;
|
return L;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ void WorldRegions::put(Chunk* chunk, std::vector<ubyte> entitiesData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert(chunk != nullptr);
|
assert(chunk != nullptr);
|
||||||
if (!chunk->flags.lighted) {
|
if (!chunk->flags.ready) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool lightsUnsaved = !chunk->flags.loadedLights && doWriteLights;
|
bool lightsUnsaved = !chunk->flags.loadedLights && doWriteLights;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue