mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +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
|
||||
zlib
|
||||
libpng
|
||||
freetype
|
||||
libvorbis
|
||||
openal
|
||||
luajit
|
||||
|
|
@ -39,7 +40,7 @@
|
|||
entt
|
||||
mesa
|
||||
freeglut
|
||||
]; # libglvnd
|
||||
];
|
||||
|
||||
packages = with pkgs; [
|
||||
glfw
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -186,7 +186,7 @@ void BlocksController::randomTick(int tickid, int parts, uint padding) {
|
|||
continue;
|
||||
}
|
||||
auto& chunk = chunks.getChunks()[index];
|
||||
if (chunk == nullptr || !chunk->flags.lighted) {
|
||||
if (chunk == nullptr || !chunk->flags.ready) {
|
||||
continue;
|
||||
}
|
||||
if (chunk->lastRandomTickId == randomTickId) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,11 @@ ChunksController::ChunksController(Level& level)
|
|||
ChunksController::~ChunksController() = default;
|
||||
|
||||
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 auto& position = player.getPosition();
|
||||
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++) {
|
||||
timeutil::Timer timer;
|
||||
if (loadVisible(player, padding)) {
|
||||
if (loadVisible(player, padding, isLocalPlayer)) {
|
||||
int64_t mcs = timer.stop();
|
||||
if (mcstotal + mcs < maxDuration * 1000) {
|
||||
mcstotal += mcs;
|
||||
|
|
@ -77,7 +81,9 @@ bool ChunksController::isInLoadingZone(
|
|||
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;
|
||||
int sizeX = chunks.getWidth();
|
||||
int sizeY = chunks.getHeight();
|
||||
|
|
@ -113,7 +119,7 @@ bool ChunksController::loadVisible(const Player& player, uint padding) const {
|
|||
auto& chunk = chunks.getChunks()[index];
|
||||
if (chunk != nullptr) {
|
||||
if (chunk->flags.loaded && !chunk->flags.lighted) {
|
||||
if (buildLights(player, chunk)) {
|
||||
if (isLocalPlayer && buildLights(player, chunk)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ private:
|
|||
std::unique_ptr<WorldGenerator> generator;
|
||||
|
||||
/// @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;
|
||||
void createChunk(const Player& player, int x, int y) const;
|
||||
public:
|
||||
|
|
@ -29,7 +29,11 @@ public:
|
|||
|
||||
/// @param maxDuration milliseconds reserved for chunks loading
|
||||
void update(
|
||||
int64_t maxDuration, int loadDistance, uint padding, Player& player
|
||||
int64_t maxDuration,
|
||||
int loadDistance,
|
||||
uint padding,
|
||||
Player& player,
|
||||
bool isLocalPlayer
|
||||
) const;
|
||||
|
||||
bool isInLoadingZone(const Player& player, uint padding, int x, int z) const;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ LevelController::LevelController(
|
|||
settings(engine.getSettings()),
|
||||
level(std::move(levelPtr)),
|
||||
chunks(std::make_unique<ChunksController>(*level)),
|
||||
playerTickClock(20, 3) {
|
||||
playerTickClock(20, 3),
|
||||
clientPlayer(clientPlayer) {
|
||||
|
||||
level->events->listen(LevelEventType::CHUNK_PRESENT, [](auto, Chunk* chunk) {
|
||||
scripting::on_chunk_present(*chunk, chunk->flags.loaded);
|
||||
|
|
@ -61,7 +62,7 @@ LevelController::LevelController(
|
|||
player->chunks->configure(
|
||||
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(
|
||||
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.loadDistance.get(),
|
||||
settings.chunks.padding.get(),
|
||||
*player
|
||||
*player,
|
||||
player.get() == clientPlayer
|
||||
);
|
||||
}
|
||||
if (!pause) {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ class LevelController {
|
|||
std::unique_ptr<ChunksController> chunks;
|
||||
|
||||
util::Clock playerTickClock;
|
||||
|
||||
Player* clientPlayer;
|
||||
public:
|
||||
CallbacksSet<> preQuitCallbacks;
|
||||
|
||||
|
|
|
|||
|
|
@ -194,5 +194,10 @@ State* lua::create_state(const EnginePaths& paths, StateType stateType) {
|
|||
}
|
||||
pop(L);
|
||||
}
|
||||
|
||||
if (stateType == StateType::GENERATOR) {
|
||||
pushnil(L);
|
||||
setglobal(L, "ffi");
|
||||
}
|
||||
return L;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ void WorldRegions::put(Chunk* chunk, std::vector<ubyte> entitiesData) {
|
|||
return;
|
||||
}
|
||||
assert(chunk != nullptr);
|
||||
if (!chunk->flags.lighted) {
|
||||
if (!chunk->flags.ready) {
|
||||
return;
|
||||
}
|
||||
bool lightsUnsaved = !chunk->flags.loadedLights && doWriteLights;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue