diff options
| author | untodesu <kirill@untode.su> | 2025-09-12 16:16:06 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-09-12 16:16:06 +0500 |
| commit | fc80fa024fc93dac6ea89461ef36f455c5e468a2 (patch) | |
| tree | 7c4ea8f03b6778572d59784dc28b600e3f8f2268 /game/client/game.cc | |
| parent | 12947aafcc6a6eb362cc454e2149796ec9265743 (diff) | |
| parent | 522a7514012da86f7b9643179f0763746f3b232e (diff) | |
| download | voxelius-fc80fa024fc93dac6ea89461ef36f455c5e468a2.tar.bz2 voxelius-fc80fa024fc93dac6ea89461ef36f455c5e468a2.zip | |
Merge pull request #15 from untodesu/metavoxels
Metavoxels
Diffstat (limited to 'game/client/game.cc')
| -rw-r--r-- | game/client/game.cc | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/game/client/game.cc b/game/client/game.cc index a59aec3..d61ce84 100644 --- a/game/client/game.cc +++ b/game/client/game.cc @@ -372,32 +372,48 @@ void client_game::init_late(void) // NOTE: this is very debug, early and a quite
// conservative limit choice; there must be a better
// way to make this limit way smaller than it currently is
- for(const std::shared_ptr<world::VoxelInfo>& info : world::voxel_registry::voxels) {
- for(const world::VoxelTexture& vtex : info->textures) {
- max_texture_count += vtex.paths.size();
- }
+ for(const auto& voxel : world::voxel_registry::voxels) {
+ max_texture_count += voxel->get_default_textures().size();
+ max_texture_count += voxel->get_face_textures(world::VFACE_NORTH).size();
+ max_texture_count += voxel->get_face_textures(world::VFACE_SOUTH).size();
+ max_texture_count += voxel->get_face_textures(world::VFACE_EAST).size();
+ max_texture_count += voxel->get_face_textures(world::VFACE_WEST).size();
+ max_texture_count += voxel->get_face_textures(world::VFACE_TOP).size();
+ max_texture_count += voxel->get_face_textures(world::VFACE_BOTTOM).size();
+ max_texture_count += voxel->get_face_textures(world::VFACE_CROSS_NWSE).size();
+ max_texture_count += voxel->get_face_textures(world::VFACE_CROSS_NESW).size();
}
// UNDONE: asset packs for non-16x16 stuff
world::voxel_atlas::create(16, 16, max_texture_count);
- for(std::shared_ptr<world::VoxelInfo>& info : world::voxel_registry::voxels) {
- for(world::VoxelTexture& vtex : info->textures) {
- if(auto strip = world::voxel_atlas::find_or_load(vtex.paths)) {
- vtex.cached_offset = strip->offset;
- vtex.cached_plane = strip->plane;
+ for(auto& voxel : world::voxel_registry::voxels) {
+ constexpr std::array faces = {
+ world::VFACE_NORTH,
+ world::VFACE_SOUTH,
+ world::VFACE_EAST,
+ world::VFACE_WEST,
+ world::VFACE_TOP,
+ world::VFACE_BOTTOM,
+ world::VFACE_CROSS_NWSE,
+ world::VFACE_CROSS_NESW,
+ };
+
+ for(auto face : faces) {
+ if(auto strip = world::voxel_atlas::find_or_load(voxel->get_face_textures(face))) {
+ voxel->set_face_cache(face, strip->offset, strip->plane);
continue;
}
- spdlog::critical("client_gl: {}: failed to load atlas strips", info->name);
+ spdlog::critical("client_gl: {}: failed to load atlas strips", voxel->get_name());
std::terminate();
}
}
world::voxel_atlas::generate_mipmaps();
- for(std::shared_ptr<world::ItemInfo>& info : world::item_registry::items) {
- info->cached_texture = resource::load<TextureGUI>(info->texture.c_str(), TEXTURE_GUI_LOAD_CLAMP_S | TEXTURE_GUI_LOAD_CLAMP_T);
+ for(auto& item : world::item_registry::items) {
+ item->set_cached_texture(resource::load<TextureGUI>(item->get_texture(), TEXTURE_GUI_LOAD_CLAMP_S | TEXTURE_GUI_LOAD_CLAMP_T));
}
experiments::init_late();
|
