Unnecessary includes

This commit is contained in:
Marc Gilleron 2022-06-03 19:02:03 +01:00
parent 9bad06737b
commit 6ab6f4a8b6
5 changed files with 16 additions and 20 deletions

View File

@ -325,6 +325,14 @@ void VoxelToolTerrain::run_blocky_random_tick_static(VoxelDataMap &map, Box3i vo
} }
} }
static Ref<VoxelBlockyLibrary> get_voxel_library(const VoxelTerrain &terrain) {
Ref<VoxelMesherBlocky> blocky_mesher = terrain.get_mesher();
if (blocky_mesher.is_valid()) {
return blocky_mesher->get_library();
}
return Ref<VoxelBlockyLibrary>();
}
// TODO This function snaps the given AABB to blocks, this is not intuitive. Should figure out a way to respect the // TODO This function snaps the given AABB to blocks, this is not intuitive. Should figure out a way to respect the
// area. Executes a function on random voxels in the provided area, using the type channel. This allows to implement // area. Executes a function on random voxels in the provided area, using the type channel. This allows to implement
// slow "natural" cellular automata behavior, as can be seen in Minecraft. // slow "natural" cellular automata behavior, as can be seen in Minecraft.
@ -333,8 +341,8 @@ void VoxelToolTerrain::run_blocky_random_tick(
ZN_PROFILE_SCOPE(); ZN_PROFILE_SCOPE();
ERR_FAIL_COND(_terrain == nullptr); ERR_FAIL_COND(_terrain == nullptr);
ERR_FAIL_COND_MSG( ERR_FAIL_COND_MSG(get_voxel_library(*_terrain).is_null(),
_terrain->get_voxel_library().is_null(), "This function requires a volume using VoxelMesherBlocky"); String("This function requires a volume using {0}").format(varray(VoxelMesherBlocky::get_class_static())));
ERR_FAIL_COND(callback.is_null()); ERR_FAIL_COND(callback.is_null());
ERR_FAIL_COND(batch_count <= 0); ERR_FAIL_COND(batch_count <= 0);
ERR_FAIL_COND(voxel_count < 0); ERR_FAIL_COND(voxel_count < 0);
@ -349,7 +357,7 @@ void VoxelToolTerrain::run_blocky_random_tick(
}; };
CallbackData cb_self{ callback }; CallbackData cb_self{ callback };
const VoxelBlockyLibrary &lib = **_terrain->get_voxel_library(); const VoxelBlockyLibrary &lib = **get_voxel_library(*_terrain);
VoxelDataMap &map = _terrain->get_storage(); VoxelDataMap &map = _terrain->get_storage();
const Box3i voxel_box(math::floor_to_int(voxel_area.position), math::floor_to_int(voxel_area.size)); const Box3i voxel_box(math::floor_to_int(voxel_area.position), math::floor_to_int(voxel_area.size));

View File

@ -1,19 +1,16 @@
#ifndef VOXEL_SERVER_H #ifndef VOXEL_SERVER_H
#define VOXEL_SERVER_H #define VOXEL_SERVER_H
#include "../constants/voxel_constants.h" #include "../meshers/voxel_mesher.h"
#include "../generators/voxel_generator.h" #include "../streams/instance_data.h"
#include "../meshers/blocky/voxel_mesher_blocky.h"
#include "../streams/voxel_stream.h"
#include "../util/file_locker.h" #include "../util/file_locker.h"
#include "../util/memory.h"
#include "../util/struct_db.h" #include "../util/struct_db.h"
#include "../util/tasks/progressive_task_runner.h" #include "../util/tasks/progressive_task_runner.h"
#include "../util/tasks/threaded_task_runner.h" #include "../util/tasks/threaded_task_runner.h"
#include "../util/tasks/time_spread_task_runner.h" #include "../util/tasks/time_spread_task_runner.h"
#include "priority_dependency.h" #include "priority_dependency.h"
#include <memory>
namespace zylann::voxel { namespace zylann::voxel {
// Access point for asynchronous voxel processing APIs. // Access point for asynchronous voxel processing APIs.

View File

@ -2,6 +2,7 @@
#include "../../constants/voxel_constants.h" #include "../../constants/voxel_constants.h"
#include "../../constants/voxel_string_names.h" #include "../../constants/voxel_string_names.h"
#include "../../edition/voxel_tool_terrain.h" #include "../../edition/voxel_tool_terrain.h"
#include "../../meshers/blocky/voxel_mesher_blocky.h"
#include "../../server/generate_block_task.h" #include "../../server/generate_block_task.h"
#include "../../server/load_block_data_task.h" #include "../../server/load_block_data_task.h"
#include "../../server/mesh_block_task.h" #include "../../server/mesh_block_task.h"
@ -296,14 +297,6 @@ void VoxelTerrain::set_mesher(Ref<VoxelMesher> mesher) {
update_configuration_warnings(); update_configuration_warnings();
} }
Ref<VoxelBlockyLibrary> VoxelTerrain::get_voxel_library() const {
Ref<VoxelMesherBlocky> blocky_mesher = _mesher;
if (blocky_mesher.is_valid()) {
return blocky_mesher->get_library();
}
return Ref<VoxelBlockyLibrary>();
}
void VoxelTerrain::get_viewers_in_area(std::vector<int> &out_viewer_ids, Box3i voxel_box) const { void VoxelTerrain::get_viewers_in_area(std::vector<int> &out_viewer_ids, Box3i voxel_box) const {
const Box3i block_box = voxel_box.downscaled(_data_map.get_block_size()); const Box3i block_box = voxel_box.downscaled(_data_map.get_block_size());

View File

@ -110,9 +110,6 @@ public:
// If the block is out of range of any viewer, it will be cancelled. // If the block is out of range of any viewer, it will be cancelled.
void generate_block_async(Vector3i block_position); void generate_block_async(Vector3i block_position);
// For convenience, this is actually stored in a particular type of mesher
Ref<VoxelBlockyLibrary> get_voxel_library() const;
struct Stats { struct Stats {
int updated_blocks = 0; int updated_blocks = 0;
int dropped_block_loads = 0; int dropped_block_loads = 0;

View File

@ -1,6 +1,7 @@
#include "voxel_lod_terrain.h" #include "voxel_lod_terrain.h"
#include "../../constants/voxel_string_names.h" #include "../../constants/voxel_string_names.h"
#include "../../edition/voxel_tool_lod_terrain.h" #include "../../edition/voxel_tool_lod_terrain.h"
#include "../../meshers/blocky/voxel_mesher_blocky.h"
#include "../../meshers/transvoxel/voxel_mesher_transvoxel.h" #include "../../meshers/transvoxel/voxel_mesher_transvoxel.h"
#include "../../server/load_all_blocks_data_task.h" #include "../../server/load_all_blocks_data_task.h"
#include "../../server/voxel_server_gd.h" #include "../../server/voxel_server_gd.h"