mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
Merge pull request #852 from MihailRis/refactor-world-renderer
update world renderer (part 1)
This commit is contained in:
commit
33053f07ed
45 changed files with 737 additions and 593 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "world/Level.hpp"
|
||||
#include "world/World.hpp"
|
||||
#include "world/Weather.hpp"
|
||||
|
||||
using namespace scripting;
|
||||
|
||||
|
|
@ -9,6 +10,11 @@ static Weather& require_weather() {
|
|||
if (level == nullptr) {
|
||||
throw std::runtime_error("world is not open");
|
||||
}
|
||||
if (renderer == nullptr) {
|
||||
throw std::runtime_error(
|
||||
"world frontend is not initialized yet (wait for on_hud_open event)"
|
||||
);
|
||||
}
|
||||
return renderer->getWeather();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ static Level& require_level() {
|
|||
}
|
||||
|
||||
static WorldInfo& require_world_info() {
|
||||
return require_level().getWorld()->getInfo();
|
||||
return require_level().getWorld().getInfo();
|
||||
}
|
||||
|
||||
static int l_is_open(lua::State* L) {
|
||||
|
|
@ -139,7 +139,7 @@ static int l_get_chunk_data(lua::State* L) {
|
|||
auto voxelData = std::make_unique<ubyte[]>(CHUNK_DATA_LEN);
|
||||
std::vector<ubyte> chunkData;
|
||||
if (chunk == nullptr) {
|
||||
auto& regions = level->getWorld()->wfile->getRegions();
|
||||
auto& regions = level->getWorld().wfile->getRegions();
|
||||
if (!regions.getVoxels(x, z, voxelData.get())) {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ static int l_save_chunk_data(lua::State* L) {
|
|||
reinterpret_cast<const ubyte*>(buffer.data()),
|
||||
reinterpret_cast<const ubyte*>(buffer.data()) + buffer.size()
|
||||
),
|
||||
level->getWorld()->wfile->getRegions()
|
||||
level->getWorld().wfile->getRegions()
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ void scripting::on_world_load(LevelController* controller) {
|
|||
for (auto& pack : content_control->getAllContentPacks()) {
|
||||
lua::emit_event(L, pack.id + ":.worldopen", [](auto L) {
|
||||
return lua::pushboolean(
|
||||
L, !scripting::level->getWorld()->getInfo().isLoaded
|
||||
L, !scripting::level->getWorld().getInfo().isLoaded
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue