diff --git a/SCsub b/SCsub index 8d3f2c1..8eaba38 100644 --- a/SCsub +++ b/SCsub @@ -1,6 +1,11 @@ Import('env') -env.add_source_files(env.modules_sources,"*.cpp") -env.add_source_files(env.modules_sources,"transvoxel/*.cpp") -env.add_source_files(env.modules_sources,"dmc/*.cpp") +env.add_source_files(env.modules_sources, "*.cpp") +env.add_source_files(env.modules_sources, "meshers/blocky/*.cpp") +env.add_source_files(env.modules_sources, "meshers/transvoxel/*.cpp") +env.add_source_files(env.modules_sources, "meshers/dmc/*.cpp") +env.add_source_files(env.modules_sources, "providers/*.cpp") +env.add_source_files(env.modules_sources, "util/*.cpp") +env.add_source_files(env.modules_sources, "terrain/*.cpp") +env.add_source_files(env.modules_sources, "math/*.cpp") diff --git a/cube_tables.h b/cube_tables.h index 6a7a6df..e2d92da 100644 --- a/cube_tables.h +++ b/cube_tables.h @@ -1,8 +1,8 @@ #ifndef CUBE_TABLES_H #define CUBE_TABLES_H +#include "math/vector3i.h" #include -#include "vector3i.h" namespace Cube { @@ -71,7 +71,6 @@ extern const unsigned int g_edge_corners[EDGE_COUNT][2]; const unsigned int MOORE_NEIGHBORING_3D_COUNT = 26; extern const Vector3i g_moore_neighboring_3d[MOORE_NEIGHBORING_3D_COUNT]; -} // namespace CubeTables - +} // namespace Cube #endif // CUBE_TABLES_H diff --git a/rect3i.h b/math/rect3i.h similarity index 100% rename from rect3i.h rename to math/rect3i.h diff --git a/vector3i.h b/math/vector3i.h similarity index 100% rename from vector3i.h rename to math/vector3i.h diff --git a/voxel_mesher.cpp b/meshers/blocky/voxel_mesher_blocky.cpp similarity index 93% rename from voxel_mesher.cpp rename to meshers/blocky/voxel_mesher_blocky.cpp index 6c98fa2..f3228fb 100644 --- a/voxel_mesher.cpp +++ b/meshers/blocky/voxel_mesher_blocky.cpp @@ -1,7 +1,7 @@ -#include "voxel_mesher.h" -#include "cube_tables.h" -#include "utility.h" -#include "voxel_library.h" +#include "voxel_mesher_blocky.h" +#include "../../cube_tables.h" +#include "../../util/utility.h" +#include "../../voxel_library.h" #include template @@ -11,15 +11,15 @@ void raw_copy_to(PoolVector &to, const Vector &from) { memcpy(w.ptr(), from.ptr(), from.size() * sizeof(T)); } -VoxelMesher::VoxelMesher() : +VoxelMesherBlocky::VoxelMesherBlocky() : _baked_occlusion_darkness(0.8), _bake_occlusion(true) {} -void VoxelMesher::set_library(Ref library) { +void VoxelMesherBlocky::set_library(Ref library) { _library = library; } -void VoxelMesher::set_occlusion_darkness(float darkness) { +void VoxelMesherBlocky::set_occlusion_darkness(float darkness) { _baked_occlusion_darkness = darkness; if (_baked_occlusion_darkness < 0.0) _baked_occlusion_darkness = 0.0; @@ -27,7 +27,7 @@ void VoxelMesher::set_occlusion_darkness(float darkness) { _baked_occlusion_darkness = 1.0; } -void VoxelMesher::set_occlusion_enabled(bool enable) { +void VoxelMesherBlocky::set_occlusion_enabled(bool enable) { _bake_occlusion = enable; } @@ -51,7 +51,7 @@ inline bool is_transparent(const VoxelLibrary &lib, int voxel_id) { return true; } -Ref VoxelMesher::build_mesh(Ref buffer_ref, unsigned int channel, Array materials, Ref mesh) { +Ref VoxelMesherBlocky::build_mesh(Ref buffer_ref, unsigned int channel, Array materials, Ref mesh) { ERR_FAIL_COND_V(buffer_ref.is_null(), Ref()); VoxelBuffer &buffer = **buffer_ref; @@ -75,7 +75,7 @@ Ref VoxelMesher::build_mesh(Ref buffer_ref, unsigned int return mesh; } -Array VoxelMesher::build(const VoxelBuffer &buffer, unsigned int channel, int padding) { +Array VoxelMesherBlocky::build(const VoxelBuffer &buffer, unsigned int channel, int padding) { //uint64_t time_before = OS::get_singleton()->get_ticks_usec(); ERR_FAIL_COND_V(_library.is_null(), Array()); @@ -418,20 +418,20 @@ Array VoxelMesher::build(const VoxelBuffer &buffer, unsigned int channel, int pa return surfaces; } -void VoxelMesher::_bind_methods() { +void VoxelMesherBlocky::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_library", "voxel_library"), &VoxelMesher::set_library); - ClassDB::bind_method(D_METHOD("get_library"), &VoxelMesher::get_library); + ClassDB::bind_method(D_METHOD("set_library", "voxel_library"), &VoxelMesherBlocky::set_library); + ClassDB::bind_method(D_METHOD("get_library"), &VoxelMesherBlocky::get_library); - ClassDB::bind_method(D_METHOD("set_occlusion_enabled", "enable"), &VoxelMesher::set_occlusion_enabled); - ClassDB::bind_method(D_METHOD("get_occlusion_enabled"), &VoxelMesher::get_occlusion_enabled); + ClassDB::bind_method(D_METHOD("set_occlusion_enabled", "enable"), &VoxelMesherBlocky::set_occlusion_enabled); + ClassDB::bind_method(D_METHOD("get_occlusion_enabled"), &VoxelMesherBlocky::get_occlusion_enabled); - ClassDB::bind_method(D_METHOD("set_occlusion_darkness", "value"), &VoxelMesher::set_occlusion_darkness); - ClassDB::bind_method(D_METHOD("get_occlusion_darkness"), &VoxelMesher::get_occlusion_darkness); + ClassDB::bind_method(D_METHOD("set_occlusion_darkness", "value"), &VoxelMesherBlocky::set_occlusion_darkness); + ClassDB::bind_method(D_METHOD("get_occlusion_darkness"), &VoxelMesherBlocky::get_occlusion_darkness); - ClassDB::bind_method(D_METHOD("build_mesh", "voxel_buffer", "channel", "materials", "existing_mesh"), &VoxelMesher::build_mesh); + ClassDB::bind_method(D_METHOD("build_mesh", "voxel_buffer", "channel", "materials", "existing_mesh"), &VoxelMesherBlocky::build_mesh); #ifdef VOXEL_PROFILING - ClassDB::bind_method(D_METHOD("get_profiling_info"), &VoxelMesher::get_profiling_info); + ClassDB::bind_method(D_METHOD("get_profiling_info"), &VoxelMesherBlocky::get_profiling_info); #endif } diff --git a/voxel_mesher.h b/meshers/blocky/voxel_mesher_blocky.h similarity index 79% rename from voxel_mesher.h rename to meshers/blocky/voxel_mesher_blocky.h index bc538f4..4bbc007 100644 --- a/voxel_mesher.h +++ b/meshers/blocky/voxel_mesher_blocky.h @@ -1,22 +1,22 @@ -#ifndef VOXEL_MESHER -#define VOXEL_MESHER +#ifndef VOXEL_MESHER_BLOCKY_H +#define VOXEL_MESHER_BLOCKY_H -#include "voxel.h" -#include "voxel_buffer.h" -#include "voxel_library.h" -#include "zprofiling.h" +#include "../../util/zprofiling.h" +#include "../../voxel.h" +#include "../../voxel_buffer.h" +#include "../../voxel_library.h" #include #include // TODO Should be renamed VoxelMesherBlocky or something like that -class VoxelMesher : public Reference { - GDCLASS(VoxelMesher, Reference) +class VoxelMesherBlocky : public Reference { + GDCLASS(VoxelMesherBlocky, Reference) public: static const unsigned int MAX_MATERIALS = 8; // Arbitrary. Tweak if needed. static const int MINIMUM_PADDING = 1; - VoxelMesher(); + VoxelMesherBlocky(); void set_library(Ref library); Ref get_library() const { return _library; } @@ -53,4 +53,4 @@ private: #endif }; -#endif // VOXEL_MESHER +#endif // VOXEL_MESHER_BLOCKY_H diff --git a/dmc/hermite_value.h b/meshers/dmc/hermite_value.h similarity index 97% rename from dmc/hermite_value.h rename to meshers/dmc/hermite_value.h index 37e012a..b1fb020 100644 --- a/dmc/hermite_value.h +++ b/meshers/dmc/hermite_value.h @@ -1,8 +1,8 @@ #ifndef HERMITE_VALUE_H #define HERMITE_VALUE_H -#include "../utility.h" -#include "../voxel_buffer.h" +#include "../../util/utility.h" +#include "../../voxel_buffer.h" #include namespace dmc { diff --git a/dmc/marching_cubes_tables.h b/meshers/dmc/marching_cubes_tables.h similarity index 100% rename from dmc/marching_cubes_tables.h rename to meshers/dmc/marching_cubes_tables.h diff --git a/dmc/mesh_builder.cpp b/meshers/dmc/mesh_builder.cpp similarity index 100% rename from dmc/mesh_builder.cpp rename to meshers/dmc/mesh_builder.cpp diff --git a/dmc/mesh_builder.h b/meshers/dmc/mesh_builder.h similarity index 96% rename from dmc/mesh_builder.h rename to meshers/dmc/mesh_builder.h index 46478f2..4971355 100644 --- a/dmc/mesh_builder.h +++ b/meshers/dmc/mesh_builder.h @@ -1,7 +1,7 @@ #ifndef MESH_BUILDER_H #define MESH_BUILDER_H -#include "../utility.h" +#include "../../util/utility.h" #include #include #include diff --git a/dmc/object_pool.h b/meshers/dmc/object_pool.h similarity index 100% rename from dmc/object_pool.h rename to meshers/dmc/object_pool.h diff --git a/dmc/octree_utility.h b/meshers/dmc/octree_tables.h similarity index 91% rename from dmc/octree_utility.h rename to meshers/dmc/octree_tables.h index 863b821..c24b1c8 100644 --- a/dmc/octree_utility.h +++ b/meshers/dmc/octree_tables.h @@ -1,7 +1,7 @@ -#ifndef OCTREE_UTILITY_H -#define OCTREE_UTILITY_H +#ifndef OCTREE_TABLES_H +#define OCTREE_TABLES_H -namespace OctreeUtility { +namespace OctreeTables { // Corners: Octants: // @@ -40,6 +40,6 @@ const int g_octant_position[8][3]{ { 0, 1, 1 } }; -} // namespace OctreeUtility +} // namespace OctreeTables -#endif // OCTREE_UTILITY_H +#endif // OCTREE_TABLES_H diff --git a/dmc/voxel_mesher_dmc.cpp b/meshers/dmc/voxel_mesher_dmc.cpp similarity index 99% rename from dmc/voxel_mesher_dmc.cpp rename to meshers/dmc/voxel_mesher_dmc.cpp index 20aa6ed..213bd6f 100644 --- a/dmc/voxel_mesher_dmc.cpp +++ b/meshers/dmc/voxel_mesher_dmc.cpp @@ -1,8 +1,8 @@ #include "voxel_mesher_dmc.h" -#include "../cube_tables.h" +#include "../../cube_tables.h" #include "marching_cubes_tables.h" #include "mesh_builder.h" -#include "octree_utility.h" +#include "octree_tables.h" #include // Dual marching cubes @@ -184,7 +184,7 @@ private: for (int i = 0; i < 8; ++i) { OctreeNode *child = _pool.create(); - const int *v = OctreeUtility::g_octant_position[i]; + const int *v = OctreeTables::g_octant_position[i]; child->size = node->size / 2; child->origin = node->origin + Vector3i(v[0], v[1], v[2]) * child->size; @@ -215,7 +215,7 @@ public: // Go all the way down, except leaves because we can't reason bottom-up on them if (node_size > 2) { for (int i = 0; i < 8; ++i) { - const int *dir = OctreeUtility::g_octant_position[i]; + const int *dir = OctreeTables::g_octant_position[i]; int child_size = node_size / 2; children[i] = build(node_origin + child_size * Vector3i(dir[0], dir[1], dir[2]), child_size); any_node |= children[i] != nullptr; @@ -263,7 +263,7 @@ public: private: inline OctreeNode *create_child(Vector3i parent_origin, int parent_size, int i) const { - const int *dir = OctreeUtility::g_octant_position[i]; + const int *dir = OctreeTables::g_octant_position[i]; OctreeNode *child = _pool.create(); child->size = parent_size / 2; child->origin = parent_origin + child->size * Vector3i(dir[0], dir[1], dir[2]); diff --git a/dmc/voxel_mesher_dmc.h b/meshers/dmc/voxel_mesher_dmc.h similarity index 97% rename from dmc/voxel_mesher_dmc.h rename to meshers/dmc/voxel_mesher_dmc.h index b6bbca1..9b12afe 100644 --- a/dmc/voxel_mesher_dmc.h +++ b/meshers/dmc/voxel_mesher_dmc.h @@ -1,11 +1,11 @@ #ifndef VOXEL_MESHER_DMC_H #define VOXEL_MESHER_DMC_H -#include "../voxel_buffer.h" +#include "../../voxel_buffer.h" #include "hermite_value.h" #include "mesh_builder.h" #include "object_pool.h" -#include "scene/resources/mesh.h" +#include namespace dmc { diff --git a/transvoxel/transvoxel_tables.cpp b/meshers/transvoxel/transvoxel_tables.cpp similarity index 100% rename from transvoxel/transvoxel_tables.cpp rename to meshers/transvoxel/transvoxel_tables.cpp diff --git a/transvoxel/voxel_mesher_transvoxel.cpp b/meshers/transvoxel/voxel_mesher_transvoxel.cpp similarity index 100% rename from transvoxel/voxel_mesher_transvoxel.cpp rename to meshers/transvoxel/voxel_mesher_transvoxel.cpp diff --git a/transvoxel/voxel_mesher_transvoxel.h b/meshers/transvoxel/voxel_mesher_transvoxel.h similarity index 96% rename from transvoxel/voxel_mesher_transvoxel.h rename to meshers/transvoxel/voxel_mesher_transvoxel.h index 37d3f1c..3b8fe1d 100644 --- a/transvoxel/voxel_mesher_transvoxel.h +++ b/meshers/transvoxel/voxel_mesher_transvoxel.h @@ -1,7 +1,7 @@ #ifndef VOXEL_MESHER_SMOOTH_H #define VOXEL_MESHER_SMOOTH_H -#include "../voxel_buffer.h" +#include "../../voxel_buffer.h" #include class VoxelMesherTransvoxel : public Reference { diff --git a/voxel_provider.cpp b/providers/voxel_provider.cpp similarity index 97% rename from voxel_provider.cpp rename to providers/voxel_provider.cpp index 4f34b08..db5e258 100644 --- a/voxel_provider.cpp +++ b/providers/voxel_provider.cpp @@ -1,5 +1,5 @@ #include "voxel_provider.h" -#include "voxel_map.h" +#include void VoxelProvider::emerge_block(Ref out_buffer, Vector3i origin_in_voxels) { ERR_FAIL_COND(out_buffer.is_null()); diff --git a/voxel_provider.h b/providers/voxel_provider.h similarity index 94% rename from voxel_provider.h rename to providers/voxel_provider.h index ec4a878..a7e016a 100644 --- a/voxel_provider.h +++ b/providers/voxel_provider.h @@ -1,7 +1,7 @@ #ifndef VOXEL_PROVIDER_H #define VOXEL_PROVIDER_H -#include "voxel_buffer.h" +#include "../voxel_buffer.h" #include class VoxelProvider : public Resource { diff --git a/voxel_provider_image.cpp b/providers/voxel_provider_image.cpp similarity index 100% rename from voxel_provider_image.cpp rename to providers/voxel_provider_image.cpp diff --git a/voxel_provider_image.h b/providers/voxel_provider_image.h similarity index 100% rename from voxel_provider_image.h rename to providers/voxel_provider_image.h diff --git a/voxel_provider_test.cpp b/providers/voxel_provider_test.cpp similarity index 99% rename from voxel_provider_test.cpp rename to providers/voxel_provider_test.cpp index edc63cf..8516c41 100644 --- a/voxel_provider_test.cpp +++ b/providers/voxel_provider_test.cpp @@ -1,5 +1,4 @@ #include "voxel_provider_test.h" -#include "voxel_map.h" VARIANT_ENUM_CAST(VoxelProviderTest::Mode) diff --git a/voxel_provider_test.h b/providers/voxel_provider_test.h similarity index 100% rename from voxel_provider_test.h rename to providers/voxel_provider_test.h diff --git a/register_types.cpp b/register_types.cpp index a4fd60b..286f5a0 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -1,31 +1,42 @@ #include "register_types.h" -#include "dmc/voxel_mesher_dmc.h" -#include "transvoxel/voxel_mesher_transvoxel.h" -#include "voxel_box_mover.h" +#include "meshers/blocky/voxel_mesher_blocky.h" +#include "meshers/dmc/voxel_mesher_dmc.h" +#include "meshers/transvoxel/voxel_mesher_transvoxel.h" +#include "providers/voxel_provider_image.h" +#include "providers/voxel_provider_test.h" +#include "terrain/voxel_box_mover.h" +#include "terrain/voxel_map.h" +#include "terrain/voxel_terrain.h" #include "voxel_buffer.h" #include "voxel_isosurface_tool.h" #include "voxel_library.h" -#include "voxel_map.h" -#include "voxel_mesher.h" -#include "voxel_provider_image.h" -#include "voxel_provider_test.h" -#include "voxel_terrain.h" void register_voxel_types() { - ClassDB::register_class(); + // Storage ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); + + // Voxel types + ClassDB::register_class(); + ClassDB::register_class(); + + // Nodes ClassDB::register_class(); + + // Providers ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); + + // Helpers ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); + + // Meshers + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); } void unregister_voxel_types() { diff --git a/voxel_block.cpp b/terrain/voxel_block.cpp similarity index 100% rename from voxel_block.cpp rename to terrain/voxel_block.cpp diff --git a/voxel_block.h b/terrain/voxel_block.h similarity index 96% rename from voxel_block.h rename to terrain/voxel_block.h index ff00d69..dcc1313 100644 --- a/voxel_block.h +++ b/terrain/voxel_block.h @@ -1,7 +1,7 @@ #ifndef VOXEL_BLOCK_H #define VOXEL_BLOCK_H -#include "voxel_buffer.h" +#include "../voxel_buffer.h" #include #include diff --git a/voxel_box_mover.cpp b/terrain/voxel_box_mover.cpp similarity index 100% rename from voxel_box_mover.cpp rename to terrain/voxel_box_mover.cpp diff --git a/voxel_box_mover.h b/terrain/voxel_box_mover.h similarity index 100% rename from voxel_box_mover.h rename to terrain/voxel_box_mover.h diff --git a/voxel_map.cpp b/terrain/voxel_map.cpp similarity index 99% rename from voxel_map.cpp rename to terrain/voxel_map.cpp index 33087cf..7a664a9 100644 --- a/voxel_map.cpp +++ b/terrain/voxel_map.cpp @@ -1,5 +1,5 @@ #include "voxel_map.h" -#include "cube_tables.h" +#include "../cube_tables.h" #include "voxel_block.h" #include "core/os/os.h" diff --git a/voxel_map.h b/terrain/voxel_map.h similarity index 100% rename from voxel_map.h rename to terrain/voxel_map.h diff --git a/voxel_mesh_updater.cpp b/terrain/voxel_mesh_updater.cpp similarity index 99% rename from voxel_mesh_updater.cpp rename to terrain/voxel_mesh_updater.cpp index fcd562a..9cfcebc 100644 --- a/voxel_mesh_updater.cpp +++ b/terrain/voxel_mesh_updater.cpp @@ -1,5 +1,5 @@ #include "voxel_mesh_updater.h" -#include "utility.h" +#include "../util/utility.h" #include VoxelMeshUpdater::VoxelMeshUpdater(Ref library, MeshingParams params) { diff --git a/voxel_mesh_updater.h b/terrain/voxel_mesh_updater.h similarity index 90% rename from voxel_mesh_updater.h rename to terrain/voxel_mesh_updater.h index 61483e2..283b30e 100644 --- a/voxel_mesh_updater.h +++ b/terrain/voxel_mesh_updater.h @@ -5,9 +5,9 @@ #include #include -#include "dmc/voxel_mesher_dmc.h" -#include "voxel_buffer.h" -#include "voxel_mesher.h" +#include "../meshers/blocky/voxel_mesher_blocky.h" +#include "../meshers/dmc/voxel_mesher_dmc.h" +#include "../voxel_buffer.h" class VoxelMeshUpdater { public: @@ -83,7 +83,7 @@ private: Output _shared_output; Mutex *_output_mutex; - Ref _blocky_mesher; + Ref _blocky_mesher; Ref _dmc_mesher; Input _input; diff --git a/voxel_provider_thread.cpp b/terrain/voxel_provider_thread.cpp similarity index 97% rename from voxel_provider_thread.cpp rename to terrain/voxel_provider_thread.cpp index 22a3c70..b2f1dec 100644 --- a/voxel_provider_thread.cpp +++ b/terrain/voxel_provider_thread.cpp @@ -1,10 +1,11 @@ #include "voxel_provider_thread.h" -#include "core/os/os.h" -#include "core/os/semaphore.h" -#include "core/os/thread.h" -#include "utility.h" +#include "../providers/voxel_provider.h" +#include "../util/utility.h" #include "voxel_map.h" -#include "voxel_provider.h" + +#include +#include +#include VoxelProviderThread::VoxelProviderThread(Ref provider, int block_size_pow2) { diff --git a/voxel_provider_thread.h b/terrain/voxel_provider_thread.h similarity index 96% rename from voxel_provider_thread.h rename to terrain/voxel_provider_thread.h index 939fac5..dd3bf6c 100644 --- a/voxel_provider_thread.h +++ b/terrain/voxel_provider_thread.h @@ -1,8 +1,8 @@ #ifndef VOXEL_PROVIDER_THREAD_H #define VOXEL_PROVIDER_THREAD_H -#include "core/resource.h" -#include "vector3i.h" +#include "../math/vector3i.h" +#include class VoxelProvider; class VoxelBuffer; diff --git a/voxel_terrain.cpp b/terrain/voxel_terrain.cpp similarity index 98% rename from voxel_terrain.cpp rename to terrain/voxel_terrain.cpp index 47d06f5..d44bb0d 100644 --- a/voxel_terrain.cpp +++ b/terrain/voxel_terrain.cpp @@ -1,10 +1,10 @@ #include "voxel_terrain.h" -#include "utility.h" +#include "../providers/voxel_provider_test.h" +#include "../util/utility.h" +#include "../util/voxel_raycast.h" #include "voxel_block.h" #include "voxel_map.h" -#include "voxel_provider_test.h" #include "voxel_provider_thread.h" -#include "voxel_raycast.h" #include #include @@ -41,7 +41,7 @@ bool VoxelTerrain::_set(const StringName &p_name, const Variant &p_value) { if (p_name.operator String().begins_with("material/")) { int idx = p_name.operator String().get_slicec('/', 1).to_int(); - ERR_FAIL_COND_V(idx >= VoxelMesher::MAX_MATERIALS || idx < 0, false); + ERR_FAIL_COND_V(idx >= VoxelMesherBlocky::MAX_MATERIALS || idx < 0, false); set_material(idx, p_value); return true; } @@ -53,7 +53,7 @@ bool VoxelTerrain::_get(const StringName &p_name, Variant &r_ret) const { if (p_name.operator String().begins_with("material/")) { int idx = p_name.operator String().get_slicec('/', 1).to_int(); - ERR_FAIL_COND_V(idx >= VoxelMesher::MAX_MATERIALS || idx < 0, false); + ERR_FAIL_COND_V(idx >= VoxelMesherBlocky::MAX_MATERIALS || idx < 0, false); r_ret = get_material(idx); return true; } @@ -63,7 +63,7 @@ bool VoxelTerrain::_get(const StringName &p_name, Variant &r_ret) const { void VoxelTerrain::_get_property_list(List *p_list) const { - for (int i = 0; i < VoxelMesher::MAX_MATERIALS; ++i) { + for (int i = 0; i < VoxelMesherBlocky::MAX_MATERIALS; ++i) { p_list->push_back(PropertyInfo(Variant::OBJECT, "material/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial")); } } @@ -151,12 +151,12 @@ Spatial *VoxelTerrain::get_viewer(NodePath path) const { void VoxelTerrain::set_material(int id, Ref material) { // TODO Update existing block surfaces - ERR_FAIL_COND(id < 0 || id >= VoxelMesher::MAX_MATERIALS); + ERR_FAIL_COND(id < 0 || id >= VoxelMesherBlocky::MAX_MATERIALS); _materials[id] = material; } Ref VoxelTerrain::get_material(int id) const { - ERR_FAIL_COND_V(id < 0 || id >= VoxelMesher::MAX_MATERIALS, Ref()); + ERR_FAIL_COND_V(id < 0 || id >= VoxelMesherBlocky::MAX_MATERIALS, Ref()); return _materials[id]; } diff --git a/voxel_terrain.h b/terrain/voxel_terrain.h similarity index 95% rename from voxel_terrain.h rename to terrain/voxel_terrain.h index 1c2965f..66eca2b 100644 --- a/voxel_terrain.h +++ b/terrain/voxel_terrain.h @@ -1,12 +1,12 @@ #ifndef VOXEL_TERRAIN_H #define VOXEL_TERRAIN_H -#include "rect3i.h" -#include "vector3i.h" +#include "../math/rect3i.h" +#include "../math/vector3i.h" +#include "../providers/voxel_provider.h" +#include "../util/zprofiling.h" #include "voxel_mesh_updater.h" -#include "voxel_provider.h" #include "voxel_provider_thread.h" -#include "zprofiling.h" #include @@ -150,7 +150,7 @@ private: bool _run_in_editor; bool _smooth_meshing_enabled; - Ref _materials[VoxelMesher::MAX_MATERIALS]; + Ref _materials[VoxelMesherBlocky::MAX_MATERIALS]; Stats _stats; }; diff --git a/utility.h b/util/utility.h similarity index 96% rename from utility.h rename to util/utility.h index 49ad2e4..93a9b96 100644 --- a/utility.h +++ b/util/utility.h @@ -1,7 +1,7 @@ #ifndef HEADER_VOXEL_UTILITY_H #define HEADER_VOXEL_UTILITY_H -#include "vector3i.h" +#include "../math/vector3i.h" #include #include #include @@ -54,7 +54,7 @@ void raw_copy_to(PoolVector &to, const std::vector &from) { } // Trilinear interpolation between corner values of a cube. -// Cube points respect the same position as in octree_utility.h +// Cube points respect the same position as in octree_tables.h template inline T interpolate(const T v0, const T v1, const T v2, const T v3, const T v4, const T v5, const T v6, const T v7, Vector3 position) { diff --git a/voxel_raycast.cpp b/util/voxel_raycast.cpp similarity index 100% rename from voxel_raycast.cpp rename to util/voxel_raycast.cpp diff --git a/voxel_raycast.h b/util/voxel_raycast.h similarity index 93% rename from voxel_raycast.h rename to util/voxel_raycast.h index a827aab..0a84ddd 100644 --- a/voxel_raycast.h +++ b/util/voxel_raycast.h @@ -1,4 +1,4 @@ -#include "vector3i.h" +#include "../math/vector3i.h" #include // TODO that could be a template function diff --git a/zprofiling.cpp b/util/zprofiling.cpp similarity index 100% rename from zprofiling.cpp rename to util/zprofiling.cpp diff --git a/zprofiling.h b/util/zprofiling.h similarity index 100% rename from zprofiling.h rename to util/zprofiling.h diff --git a/voxel.cpp b/voxel.cpp index 8799b9d..a714195 100644 --- a/voxel.cpp +++ b/voxel.cpp @@ -1,6 +1,6 @@ #include "voxel.h" +#include "meshers/blocky/voxel_mesher_blocky.h" // TODO Only required because of MAX_MATERIALS... could be enough inverting that dependency #include "voxel_library.h" -#include "voxel_mesher.h" #define STRLEN(x) (sizeof(x) / sizeof(x[0])) @@ -110,7 +110,7 @@ Ref Voxel::set_color(Color color) { } Ref Voxel::set_material_id(unsigned int id) { - ERR_FAIL_COND_V(id >= VoxelMesher::MAX_MATERIALS, Ref(this)); + ERR_FAIL_COND_V(id >= VoxelMesherBlocky::MAX_MATERIALS, Ref(this)); _material_id = id; return Ref(this); } diff --git a/voxel_buffer.h b/voxel_buffer.h index df33be7..c168dc9 100644 --- a/voxel_buffer.h +++ b/voxel_buffer.h @@ -1,7 +1,7 @@ #ifndef VOXEL_BUFFER_H #define VOXEL_BUFFER_H -#include "vector3i.h" +#include "math/vector3i.h" #include #include diff --git a/voxel_isosurface_tool.cpp b/voxel_isosurface_tool.cpp index 947ba30..491a66d 100644 --- a/voxel_isosurface_tool.cpp +++ b/voxel_isosurface_tool.cpp @@ -1,5 +1,5 @@ #include "voxel_isosurface_tool.h" -#include "utility.h" +#include "util/utility.h" VoxelIsoSurfaceTool::VoxelIsoSurfaceTool() { _iso_scale = 1.0;