diff --git a/SCsub b/SCsub index 4905a4e..a74ef11 100644 --- a/SCsub +++ b/SCsub @@ -7,15 +7,12 @@ env.add_source_files(env.modules_sources,"collections/vector3i.cpp") env.add_source_files(env.modules_sources,"library/voxelman_library.cpp") env.add_source_files(env.modules_sources,"library/voxel_surface.cpp") -env.add_source_files(env.modules_sources,"data/voxel.cpp") env.add_source_files(env.modules_sources,"data/voxel_light.cpp") env.add_source_files(env.modules_sources,"meshers/voxel_mesher.cpp") env.add_source_files(env.modules_sources,"meshers/voxel_mesher_transvoxel.cpp") env.add_source_files(env.modules_sources,"meshers/transvoxel_tables.cpp") -env.add_source_files(env.modules_sources,"utility/marching_cubes_voxel_query.cpp") - env.add_source_files(env.modules_sources,"world/voxel_buffer.cpp") env.add_source_files(env.modules_sources,"world/voxel_world.cpp") env.add_source_files(env.modules_sources,"world/voxel_chunk.cpp") diff --git a/data/voxel.cpp b/data/voxel.cpp deleted file mode 100644 index 1e7e86b..0000000 --- a/data/voxel.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "voxel.h" - -Ref Voxel::get_surface() { - return _surface; -} - -Vector3i Voxel::get_local_position() const { - return _local_position; -} -void Voxel::set_local_position(Vector3i value) { - _local_position = value; -} - -Vector3 Voxel::get_local_position_bind() const { - return _local_position.to_vec3(); -} -void Voxel::set_local_position_bind(Vector3 value) { - _local_position = value; -} - -char Voxel::get_fill() { - return _fill; -} -void Voxel::set_fill(char fill) { - _fill = fill; -} - -int Voxel::get_fill_bind() { - return (unsigned int) _fill; -} -void Voxel::set_fill_bind(int fill) { - _fill = (char) fill; -} - -float Voxel::get_light() const { - return _light; -} -void Voxel::set_light(float value) { - _light = value; -} - -Voxel::Voxel() { - _light = (float)1; -} - -Voxel::Voxel(Vector3i position, char fill, Ref surface) { - _light = (float)1; - _fill = fill; - - set_surface(surface); - - _local_position = position; -} - -Voxel::~Voxel() { -} - -void Voxel::set_surface(Ref surface) { - _surface = Ref(surface); -} - -void Voxel::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_surface"), &Voxel::get_surface); - ClassDB::bind_method(D_METHOD("set_surface", "Mesher"), &Voxel::set_surface); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "surface", PROPERTY_HINT_RESOURCE_TYPE, "VoxelSurface"), "set_surface", "get_surface"); - - ClassDB::bind_method(D_METHOD("get_fill"), &Voxel::get_fill_bind); - ClassDB::bind_method(D_METHOD("set_fill", "value"), &Voxel::set_fill_bind); - ADD_PROPERTY(PropertyInfo(Variant::INT, "fill"), "set_fill", "get_fill"); - - ClassDB::bind_method(D_METHOD("get_local_position"), &Voxel::get_local_position_bind); - ClassDB::bind_method(D_METHOD("set_local_position", "value"), &Voxel::set_local_position_bind); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "local_position"), "set_fill", "get_local_position"); - - ClassDB::bind_method(D_METHOD("get_light"), &Voxel::get_light); - ClassDB::bind_method(D_METHOD("set_light", "value"), &Voxel::set_light); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "light"), "set_light", "get_light"); -} diff --git a/data/voxel.h b/data/voxel.h deleted file mode 100644 index ce556c8..0000000 --- a/data/voxel.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef VOXEL_H -#define VOXEL_H - -#include "core/reference.h" -#include "../math/vector3i.h" -#include "core/math/quat.h" -#include "core/resource.h" -#include "core/vector.h" - -#include "../library/voxel_surface.h" - -class VoxelSurface; - -class Voxel : public Reference { - GDCLASS(Voxel, Reference); - -public: - Ref get_surface(); - void set_surface(Ref surface); - - Vector3i get_local_position() const; - void set_local_position(Vector3i value); - - Vector3 get_local_position_bind() const; - void set_local_position_bind(Vector3 value); - - char get_fill(); - void set_fill(char fill); - - int get_fill_bind(); - void set_fill_bind(int fill); - - float get_light() const; - void set_light(float value); - - Voxel(); - Voxel(Vector3i position, char fill, Ref surface); - ~Voxel(); - -protected: - static void _bind_methods(); - -private: - char _fill; - Ref _surface; - Vector3i _local_position; - float _light; -}; - -#endif diff --git a/meshers/voxel_mesher.cpp b/meshers/voxel_mesher.cpp index 180116a..224ab05 100644 --- a/meshers/voxel_mesher.cpp +++ b/meshers/voxel_mesher.cpp @@ -25,7 +25,12 @@ VoxelMesher::~VoxelMesher() { _uvs.clear(); _indices.clear(); _bones.clear(); + memdelete(_surface_tool); + + if (_library.is_valid()) { + _library.unref(); + } } Ref VoxelMesher::build_mesh() { @@ -70,17 +75,10 @@ void VoxelMesher::reset() { _bones.clear(); } -void VoxelMesher::create_mesh_for_marching_cubes_query(Ref query) { - ERR_FAIL_COND(!query.is_valid()); - ERR_FAIL_COND(!has_method("_create_mesh_for_marching_cubes_query")); - - call("_create_mesh_for_marching_cubes_query", query); -} - void VoxelMesher::add_buffer(Ref voxels) { - ERR_FAIL_COND(!has_method("_add_voxel")); + ERR_FAIL_COND(!has_method("_add_buffer")); - call("_add_voxel", voxels); + call("_add_buffer", voxels); } void VoxelMesher::create_trimesh_shape(Ref shape) const { @@ -308,9 +306,9 @@ void VoxelMesher::remove_indices(int idx) { void VoxelMesher::_bind_methods() { - //BIND_VMETHOD(MethodInfo("_build_mesh", PropertyInfo(Variant::BOOL, "recal", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo"))); - BIND_VMETHOD(MethodInfo("_add_voxels", PropertyInfo(Variant::OBJECT, "buffer", PROPERTY_HINT_RESOURCE_TYPE, "VoxelBuffer"))); - BIND_VMETHOD(MethodInfo("_create_mesh_for_marching_cubes_query", PropertyInfo(Variant::OBJECT, "query", PROPERTY_HINT_RESOURCE_TYPE, "MarchingCubesVoxelQuery"))); + BIND_VMETHOD(MethodInfo("_add_buffer", PropertyInfo(Variant::OBJECT, "buffer", PROPERTY_HINT_RESOURCE_TYPE, "VoxelBuffer"))); + + ClassDB::bind_method(D_METHOD("add_buffer", "buffer"), &VoxelMesher::add_buffer); ClassDB::bind_method(D_METHOD("get_library"), &VoxelMesher::get_library); ClassDB::bind_method(D_METHOD("set_library", "value"), &VoxelMesher::set_library); diff --git a/meshers/voxel_mesher.h b/meshers/voxel_mesher.h index 6dfdf4f..39b10dd 100644 --- a/meshers/voxel_mesher.h +++ b/meshers/voxel_mesher.h @@ -1,7 +1,7 @@ #ifndef VOXEL_TOOLS_H #define VOXEL_TOOLS_H -#include "core/reference.h" +#include "core/resource.h" #include "core/color.h" #include "core/math/vector2.h" #include "core/math/vector3.h" @@ -17,7 +17,6 @@ #include "../library/voxelman_library.h" #include "../math/vector3i.h" -#include "../utility/marching_cubes_voxel_query.h" #include "../world/voxel_buffer.h" const double PI_2 = 3.141592653589793238463 / 2; @@ -26,8 +25,8 @@ const double PI = 3.141592653589793238463; class VoxelmanLibrary; class Voxel; -class VoxelMesher : public Reference { - GDCLASS(VoxelMesher, Reference); +class VoxelMesher : public Resource { + GDCLASS(VoxelMesher, Resource); public: Ref get_library() { return _library; } @@ -36,7 +35,6 @@ public: void reset(); void add_buffer(Ref voxels); - void create_mesh_for_marching_cubes_query(Ref query); void create_trimesh_shape(Ref shape) const; void bake_lights(MeshInstance *node, Vector > &lights); diff --git a/meshers/voxel_mesher_transvoxel.cpp b/meshers/voxel_mesher_transvoxel.cpp index f44102a..b41bb84 100644 --- a/meshers/voxel_mesher_transvoxel.cpp +++ b/meshers/voxel_mesher_transvoxel.cpp @@ -214,4 +214,24 @@ void VoxelMesherTransvoxel::_bind_methods() { ClassDB::bind_method(D_METHOD("get_transition_vertex_data_second_vertex", "index1", "index2"), &VoxelMesherTransvoxel::get_transition_vertex_data_second_vertex); ClassDB::bind_method(D_METHOD("get_transition_vertex_start_position", "index1", "index2"), &VoxelMesherTransvoxel::get_transition_vertex_start_position); ClassDB::bind_method(D_METHOD("get_transition_vertex_direction", "index1", "index2"), &VoxelMesherTransvoxel::get_transition_vertex_direction); + + BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_000); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_100); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_010); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_110); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_001); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_101); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_011); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_111); + + BIND_ENUM_CONSTANT(VOXEL_ENTRIES_SIZE); + + BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_000); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_100); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_010); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_110); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_001); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_101); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_011); + BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_111); } diff --git a/meshers/voxel_mesher_transvoxel.h b/meshers/voxel_mesher_transvoxel.h index 177364b..457c3b6 100644 --- a/meshers/voxel_mesher_transvoxel.h +++ b/meshers/voxel_mesher_transvoxel.h @@ -52,6 +52,36 @@ class VoxelMesherTransvoxel : public VoxelMesher { GDCLASS(VoxelMesherTransvoxel, VoxelMesher) public: + static const String BINDING_STRING_VOXEL_ENTRY_INDICES; + static const String BINDING_STRING_VOXEL_ENTRY_MASK; + + enum VoxelEntryIndices { + VOXEL_ENTRY_INDEX_000 = 0, + VOXEL_ENTRY_INDEX_100 = 1, + VOXEL_ENTRY_INDEX_001 = 2, + VOXEL_ENTRY_INDEX_101 = 3, + + VOXEL_ENTRY_INDEX_010 = 4, + VOXEL_ENTRY_INDEX_110 = 5, + VOXEL_ENTRY_INDEX_011 = 6, + VOXEL_ENTRY_INDEX_111 = 7, + + VOXEL_ENTRIES_SIZE = 8, + }; + + enum VoxelEntryMask { + VOXEL_ENTRY_MASK_000 = 1 << 0, + VOXEL_ENTRY_MASK_100 = 1 << 1, + VOXEL_ENTRY_MASK_001 = 1 << 2, + VOXEL_ENTRY_MASK_101 = 1 << 3, + + VOXEL_ENTRY_MASK_010 = 1 << 4, + VOXEL_ENTRY_MASK_110 = 1 << 5, + VOXEL_ENTRY_MASK_011 = 1 << 6, + VOXEL_ENTRY_MASK_111 = 1 << 7, + }; + + int get_regular_cell_class(int index) const; Ref get_regular_cell_data(int index) const; @@ -81,4 +111,7 @@ protected: Ref _transition_cell_data[56]; }; +VARIANT_ENUM_CAST(VoxelMesherTransvoxel::VoxelEntryIndices); +VARIANT_ENUM_CAST(VoxelMesherTransvoxel::VoxelEntryMask); + #endif // VOXEL_MESHER_SMOOTH_H diff --git a/register_types.cpp b/register_types.cpp index 2b103a5..c84a5fd 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -3,13 +3,10 @@ #include "library/voxel_surface.h" #include "library/voxelman_library.h" -#include "data/voxel.h" #include "data/voxel_light.h" #include "meshers/voxel_mesher.h" #include "meshers/voxel_mesher_transvoxel.h" -#include "utility/marching_cubes_voxel_query.h" - #include "world/voxel_buffer.h" #include "world/voxel_world.h" #include "world/voxel_chunk.h" @@ -23,10 +20,7 @@ void register_voxelman_types() { ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); - - ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); diff --git a/utility/marching_cubes_voxel_query.cpp b/utility_old/marching_cubes_voxel_query.cpp similarity index 100% rename from utility/marching_cubes_voxel_query.cpp rename to utility_old/marching_cubes_voxel_query.cpp diff --git a/utility/marching_cubes_voxel_query.h b/utility_old/marching_cubes_voxel_query.h similarity index 100% rename from utility/marching_cubes_voxel_query.h rename to utility_old/marching_cubes_voxel_query.h diff --git a/world/voxel_chunk.cpp b/world/voxel_chunk.cpp index b0039b8..867190e 100644 --- a/world/voxel_chunk.cpp +++ b/world/voxel_chunk.cpp @@ -56,34 +56,6 @@ void VoxelChunk::set_bake_lights(bool value) { _bake_lights = value; } -bool VoxelChunk::get_bake_ambient_occlusion() { - return _bake_ambient_occlusion; -} -void VoxelChunk::set_bake_ambient_occlusion(bool value) { - _bake_ambient_occlusion = value; -} - -float VoxelChunk::get_ao_radius() { - return _ao_radius; -} -void VoxelChunk::set_ao_radius(float value) { - _ao_radius = value; -} - -float VoxelChunk::get_ao_intensity() { - return _ao_intensity; -} -void VoxelChunk::set_ao_intensity(float value) { - _ao_intensity = value; -} - -int VoxelChunk::get_ao_sample_count() { - return _ao_sample_count; -} -void VoxelChunk::set_ao_sample_count(int value) { - _ao_sample_count = value; -} - NodePath VoxelChunk::get_debug_drawer_path() { return _debug_drawer_path; } @@ -106,19 +78,19 @@ void VoxelChunk::build() { _mesher->set_library(_library); if (_debug_drawer == NULL) { - Node *n = get_node(_debug_drawer_path); + Node *n = get_node_or_null(_debug_drawer_path); if (n != NULL) { _debug_drawer = Object::cast_to(n); } } - _mesher->add_buffer(_buffer); - if (get_build_mesh()) { - ERR_FAIL_COND(!has_method("_build_mesh")); - - call("_build_mesh"); + if (has_method("_create_mesh")) { + call("_create_mesh"); + } else { + _mesher->add_buffer(_buffer); + } finalize_mesh(); } @@ -133,20 +105,19 @@ void VoxelChunk::finalize_mesh() { Node *node = get_node(_mesh_instance_path); - if (node != NULL) { + ERR_FAIL_COND(node == NULL); - _mesh_instance = Object::cast_to(node); + _mesh_instance = Object::cast_to(node); - if (_mesh_instance != NULL) { - //if (get_bake_ambient_occlusion()) { - // set_enabled(true); - //} else { - Ref mesh = get_mesher()->build_mesh(); + ERR_FAIL_COND(_mesh_instance == NULL); - _mesh_instance->set_mesh(mesh); - //} - } - } + //if (get_bake_ambient_occlusion()) { + // set_enabled(true); + //} else { + Ref mesh = get_mesher()->build_mesh(); + + _mesh_instance->set_mesh(mesh); + //} } void VoxelChunk::update_collider() { @@ -178,25 +149,6 @@ StaticBody *VoxelChunk::create_trimesh_collision_node() { return static_body; } -void VoxelChunk::query_marching_cubes_data(Ref query) { - ERR_FAIL_COND(!query.is_valid()); - - Vector3i position = query->get_position(); - int size = query->get_size(); - /* - query->set_entries(Ref(_VoxelChunk->getptr(position)), Ref(_VoxelChunk->getptr(Vector3i(size, 0, 0) + position)), - Ref(_VoxelChunk->getptr(Vector3i(0, size, 0) + position)), Ref(_VoxelChunk->getptr(Vector3i(size, size, 0) + position)), - Ref(_VoxelChunk->getptr(Vector3i(0, 0, size) + position)), Ref(_VoxelChunk->getptr(Vector3i(size, 0, size) + position)), - Ref(_VoxelChunk->getptr(Vector3i(0, size, size) + position)), Ref(_VoxelChunk->getptr(Vector3i(size, size, size) + position)));*/ -} - -void VoxelChunk::create_mesh_for_marching_cubes_query(Ref query) { - ERR_FAIL_COND(!query.is_valid()); - ERR_FAIL_COND(!_mesher.is_valid()); - - _mesher->create_mesh_for_marching_cubes_query(query); -} - void VoxelChunk::set_enabled(bool p_enabled) { _enabled = p_enabled; @@ -209,51 +161,6 @@ bool VoxelChunk::is_enabled() const { return _enabled; } -void VoxelChunk::_notification(int p_what) { - - switch (p_what) { - - case NOTIFICATION_ENTER_TREE: { - if (!_mesher.is_valid()) { - if (has_method("_create_mesher")) { - call("_create_mesher"); - - if (!Engine::get_singleton()->is_editor_hint()) { - ERR_FAIL_COND(!_mesher.is_valid()); - } - } else { - _mesher = Ref(memnew(VoxelMesher())); - } - } - } break; - case NOTIFICATION_EXIT_TREE: { - - //if (_mesher != NULL) { - // memdelete(_mesher); - //} - - } break; - case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { - - //if (!_enabled) - // break; - - //if (_mesh_instance != NULL) { - // if (get_bake_ambient_occlusion()) { - //get_mesher()->calculate_vertex_ambient_occlusion(_mesh_instance, get_ao_radius(), get_ao_intensity(), get_ao_sample_count()); - // } - - //Ref mesh = get_mesher()->build_mesh(); - - //_mesh_instance->set_mesh(mesh); - //} - - //set_enabled(false); - - } break; - } -} - void VoxelChunk::add_voxel_light_bind(Vector3 position, Color color, float strength) { add_voxel_light(position, color, strength); } @@ -393,8 +300,7 @@ void VoxelChunk::draw_debug_voxel_lights(int max, bool localPosition) { } void VoxelChunk::_bind_methods() { - BIND_VMETHOD(MethodInfo("_create_mesher")); - BIND_VMETHOD(MethodInfo("_build_mesh")); + BIND_VMETHOD(MethodInfo("_create_mesh")); ClassDB::bind_method(D_METHOD("get_library_path"), &VoxelChunk::get_library_path); ClassDB::bind_method(D_METHOD("set_library_path", "value"), &VoxelChunk::set_library_path); @@ -428,29 +334,12 @@ void VoxelChunk::_bind_methods() { ClassDB::bind_method(D_METHOD("meshing_set_bake_lights", "value"), &VoxelChunk::set_bake_lights); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "meshing_bake_lights"), "meshing_set_bake_lights", "meshing_get_bake_lights"); - ClassDB::bind_method(D_METHOD("meshing_get_bake_ambient_occlusion"), &VoxelChunk::get_bake_ambient_occlusion); - ClassDB::bind_method(D_METHOD("meshing_set_bake_ambient_occlusion", "value"), &VoxelChunk::set_bake_ambient_occlusion); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "meshing_bake_ambient_occlusion"), "meshing_set_bake_ambient_occlusion", "meshing_get_bake_ambient_occlusion"); - ADD_GROUP("Settings", "setting"); ClassDB::bind_method(D_METHOD("get_debug_drawer_path"), &VoxelChunk::get_debug_drawer_path); ClassDB::bind_method(D_METHOD("set_debug_drawer_path", "value"), &VoxelChunk::set_debug_drawer_path); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "debug_drawer_path"), "set_debug_drawer_path", "get_debug_drawer_path"); - ADD_GROUP("Ambient Occlusion", "ao"); - ClassDB::bind_method(D_METHOD("get_ao_radius"), &VoxelChunk::get_ao_radius); - ClassDB::bind_method(D_METHOD("set_ao_radius", "value"), &VoxelChunk::set_ao_radius); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_radius"), "set_ao_radius", "get_ao_radius"); - - ClassDB::bind_method(D_METHOD("get_ao_intensity"), &VoxelChunk::get_ao_intensity); - ClassDB::bind_method(D_METHOD("set_ao_intensity", "value"), &VoxelChunk::set_ao_intensity); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_intensity"), "set_ao_intensity", "get_ao_intensity"); - - ClassDB::bind_method(D_METHOD("get_ao_sample_count"), &VoxelChunk::get_ao_sample_count); - ClassDB::bind_method(D_METHOD("set_ao_sample_count", "value"), &VoxelChunk::set_ao_sample_count); - ADD_PROPERTY(PropertyInfo(Variant::INT, "ao_sample_count"), "set_ao_sample_count", "get_ao_sample_count"); - ClassDB::bind_method(D_METHOD("get_mesher"), &VoxelChunk::get_mesher); ClassDB::bind_method(D_METHOD("set_mesher", "Mesher"), &VoxelChunk::set_mesher); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher"), "set_mesher", "get_mesher"); @@ -460,9 +349,6 @@ void VoxelChunk::_bind_methods() { ClassDB::bind_method(D_METHOD("clear"), &VoxelChunk::clear); - ClassDB::bind_method(D_METHOD("query_marching_cubes_data", "query"), &VoxelChunk::query_marching_cubes_data); - ClassDB::bind_method(D_METHOD("create_mesh_for_marching_cubes_query", "query"), &VoxelChunk::create_mesh_for_marching_cubes_query); - ClassDB::bind_method(D_METHOD("draw_debug_voxels", "max"), &VoxelChunk::draw_debug_voxels, DEFVAL(Color(1, 1, 1))); ClassDB::bind_method(D_METHOD("draw_debug_voxel_lights", "max", "localPosition"), &VoxelChunk::draw_debug_voxel_lights); } @@ -471,11 +357,6 @@ VoxelChunk::VoxelChunk() { _build_mesh = true; _create_collider = true; _bake_lights = true; - _bake_ambient_occlusion = true; - - _ao_radius = 6; - _ao_intensity = 1; - _ao_sample_count = 5; _voxel_scale = 1; @@ -494,4 +375,12 @@ VoxelChunk::~VoxelChunk() { _buffer.unref(); _debug_drawer = NULL; + + if (_library.is_valid()) { + _library.unref(); + } + + if (_mesh.is_valid()) { + _mesh.unref(); + } } diff --git a/world/voxel_chunk.h b/world/voxel_chunk.h index 113f395..9930c33 100644 --- a/world/voxel_chunk.h +++ b/world/voxel_chunk.h @@ -10,7 +10,6 @@ #include "scene/3d/physics_body.h" #include "scene/resources/concave_polygon_shape.h" -#include "../data/voxel.h" #include "../data/voxel_light.h" #include "../meshers/voxel_mesher.h" @@ -18,7 +17,6 @@ #include "../library/voxel_surface.h" #include "../library/voxelman_library.h" -#include "../utility/marching_cubes_voxel_query.h" #include "voxel_buffer.h" @@ -50,18 +48,6 @@ public: bool get_bake_lights(); void set_bake_lights(bool value); - bool get_bake_ambient_occlusion(); - void set_bake_ambient_occlusion(bool value); - - float get_ao_radius(); - void set_ao_radius(float value); - - float get_ao_intensity(); - void set_ao_intensity(float value); - - int get_ao_sample_count(); - void set_ao_sample_count(int value); - NodePath get_debug_drawer_path(); void set_debug_drawer_path(NodePath value); @@ -82,9 +68,6 @@ public: StaticBody *create_trimesh_collision_node(); - void query_marching_cubes_data(Ref query); - void create_mesh_for_marching_cubes_query(Ref query); - VoxelChunk(); virtual ~VoxelChunk(); @@ -95,7 +78,6 @@ public: protected: static void _bind_methods(); - void _notification(int p_what); bool _enabled; @@ -119,11 +101,6 @@ protected: bool _create_collider; bool _bake_lights; - bool _bake_ambient_occlusion; - - float _ao_radius; - float _ao_intensity; - int _ao_sample_count; }; #endif diff --git a/world/voxel_world.cpp b/world/voxel_world.cpp index ea61a73..b591a55 100644 --- a/world/voxel_world.cpp +++ b/world/voxel_world.cpp @@ -8,6 +8,10 @@ void VoxelWorld::set_player_path(NodePath player_path) { _player_path = player_path; } +VoxelWorld ::~VoxelWorld() { + _chunks.clear(); +} + void VoxelWorld::_bind_methods() { ClassDB::bind_method(D_METHOD("get_player_path"), &VoxelWorld::get_player_path); ClassDB::bind_method(D_METHOD("set_player_path", "value"), &VoxelWorld::set_player_path); diff --git a/world/voxel_world.h b/world/voxel_world.h index 9f9d9fb..20b9dc2 100644 --- a/world/voxel_world.h +++ b/world/voxel_world.h @@ -15,6 +15,7 @@ public: void set_player_path(NodePath player_path); VoxelWorld() {} + ~VoxelWorld(); protected: static void _bind_methods();