diff --git a/README.md b/README.md index 5610b46..42ad621 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This is an engine module! Which means that you will need to compile it into Godo You can find a demonstration project here: https://github.com/Relintai/the_tower -It supports both godot 3.2 and 4.0 (master). Note that since 4.0 is still in very early stages I only +It supports both godot 3.2 and 4.0 (master [last tested commit](https://github.com/godotengine/godot/commit/b7e10141197fdd9b0dbc4cfa7890329510d36540)). Note that since 4.0 is still in very early stages I only check whether it works from time to time. ## Optional Dependencies diff --git a/areas/world_area.h b/areas/world_area.h index 6105412..7078c69 100644 --- a/areas/world_area.h +++ b/areas/world_area.h @@ -23,10 +23,18 @@ SOFTWARE. #ifndef WORLD_AREA_H #define WORLD_AREA_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/object/reference.h" +#include "core/string/ustring.h" +#else #include "core/reference.h" +#include "core/ustring.h" +#endif #include "core/math/aabb.h" -#include "core/ustring.h" + #include "scene/resources/texture.h" class WorldArea : public Reference { diff --git a/data/voxel_light.h b/data/voxel_light.h index 4374ae8..9f435cc 100644 --- a/data/voxel_light.h +++ b/data/voxel_light.h @@ -23,9 +23,17 @@ SOFTWARE. #ifndef VOXEL_LIGHT_H #define VOXEL_LIGHT_H -#include "core/color.h" +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/object/reference.h" +#include "core/templates/vector.h" +#include "core/math/color.h" +#else #include "core/reference.h" #include "core/vector.h" +#include "core/color.h" +#endif class VoxelLight : public Reference { GDCLASS(VoxelLight, Reference); diff --git a/defines.h b/defines.h index 873b64d..1f61690 100644 --- a/defines.h +++ b/defines.h @@ -18,7 +18,7 @@ #define light_h "scene/3d/light_3d.h" #define visual_server_h "servers/rendering_server.h" #define mesh_instance_h "scene/3d/mesh_instance_3d.h" -#define pool_vector_h "core/vector.h" +#define pool_vector_h "core/templates/vector.h" #define physics_server_h "servers/physics_server_3d.h" #define immediate_geometry_h "scene/3d/immediate_geometry_3d.h" #define include_pool_vector \ diff --git a/level_generator/voxelman_level_generator.h b/level_generator/voxelman_level_generator.h index ef952cf..d696ec1 100644 --- a/level_generator/voxelman_level_generator.h +++ b/level_generator/voxelman_level_generator.h @@ -23,7 +23,13 @@ SOFTWARE. #ifndef VOXELMAN_LEVEL_GENERATOR_H #define VOXELMAN_LEVEL_GENERATOR_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/io/resource.h" +#else #include "core/resource.h" +#endif class VoxelChunk; diff --git a/library/voxel_surface.h b/library/voxel_surface.h index 48090a9..fdeb635 100644 --- a/library/voxel_surface.h +++ b/library/voxel_surface.h @@ -23,11 +23,20 @@ SOFTWARE. #ifndef VOXEL_SURFACE_H #define VOXEL_SURFACE_H -#include "core/resource.h" -#include "core/color.h" -#include "core/math/rect2.h" +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/io/resource.h" +#include "core/templates/vector.h" +#include "core/math/color.h" +#else +#include "core/resource.h" #include "core/vector.h" +#include "core/color.h" +#endif + +#include "core/math/rect2.h" #include "scene/resources/material.h" #include "voxelman_library.h" diff --git a/library/voxelman_library.h b/library/voxelman_library.h index 4c42a2e..c47f691 100644 --- a/library/voxelman_library.h +++ b/library/voxelman_library.h @@ -23,8 +23,15 @@ SOFTWARE. #ifndef VOXELMAN_LIBRARY_H #define VOXELMAN_LIBRARY_H -#include "core/math/rect2.h" +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/io/resource.h" +#else #include "core/resource.h" +#endif + +#include "core/math/rect2.h" #include "scene/resources/material.h" #include "../data/voxel_light.h" diff --git a/library/voxelman_library_merger.h b/library/voxelman_library_merger.h index 73636b2..ca5f3c4 100644 --- a/library/voxelman_library_merger.h +++ b/library/voxelman_library_merger.h @@ -23,10 +23,18 @@ SOFTWARE. #ifndef VOXELMAN_LIBRARY_MERGER_H #define VOXELMAN_LIBRARY_MERGER_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/io/resource.h" +#include "core/templates/map.h" +#else +#include "core/resource.h" +#include "core/map.h" +#endif + #include "voxelman_library.h" -#include "core/map.h" -#include "core/resource.h" #include "scene/resources/material.h" #include "../data/voxel_light.h" diff --git a/library/voxelman_library_simple.h b/library/voxelman_library_simple.h index 20b6be2..0df9486 100644 --- a/library/voxelman_library_simple.h +++ b/library/voxelman_library_simple.h @@ -23,9 +23,16 @@ SOFTWARE. #ifndef VOXELMAN_LIBRARY_SIMPLE_H #define VOXELMAN_LIBRARY_SIMPLE_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/io/resource.h" +#else +#include "core/resource.h" +#endif + #include "voxelman_library.h" -#include "core/resource.h" #include "scene/resources/material.h" #include "../data/voxel_light.h" diff --git a/meshers/blocky/voxel_mesher_blocky.h b/meshers/blocky/voxel_mesher_blocky.h index 55ccb91..0cf7965 100644 --- a/meshers/blocky/voxel_mesher_blocky.h +++ b/meshers/blocky/voxel_mesher_blocky.h @@ -23,7 +23,14 @@ SOFTWARE. #ifndef VOXEL_MESHER_BLOCKY_H #define VOXEL_MESHER_BLOCKY_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/math/color.h" +#else #include "core/color.h" +#endif + #include "core/math/vector2.h" #include "core/math/vector3.h" diff --git a/meshers/blocky/voxel_mesher_liquid_blocky.h b/meshers/blocky/voxel_mesher_liquid_blocky.h index b5632ec..57870d3 100644 --- a/meshers/blocky/voxel_mesher_liquid_blocky.h +++ b/meshers/blocky/voxel_mesher_liquid_blocky.h @@ -23,7 +23,14 @@ SOFTWARE. #ifndef VOXEL_MESHER_LIQUID_BLOCKY_H #define VOXEL_MESHER_LIQUID_BLOCKY_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/math/color.h" +#else #include "core/color.h" +#endif + #include "core/math/vector2.h" #include "core/math/vector3.h" diff --git a/meshers/cubic/voxel_cube_points.h b/meshers/cubic/voxel_cube_points.h index fcc668e..90f2bed 100644 --- a/meshers/cubic/voxel_cube_points.h +++ b/meshers/cubic/voxel_cube_points.h @@ -23,8 +23,15 @@ SOFTWARE. #ifndef SUB_VOXEL_POINTS_H #define SUB_VOXEL_POINTS_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/object/reference.h" +#include "core/templates/vector.h" +#else #include "core/reference.h" #include "core/vector.h" +#endif class VoxelChunk; class SubVoxelFacePointsHelper; diff --git a/meshers/cubic/voxel_mesher_cubic.h b/meshers/cubic/voxel_mesher_cubic.h index 57fbf62..ec69d1b 100644 --- a/meshers/cubic/voxel_mesher_cubic.h +++ b/meshers/cubic/voxel_mesher_cubic.h @@ -23,7 +23,14 @@ SOFTWARE. #ifndef VOXEL_MESHER_CUBIC_H #define VOXEL_MESHER_CUBIC_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/math/color.h" +#else #include "core/color.h" +#endif + #include "core/math/vector2.h" #include "core/math/vector3.h" diff --git a/meshers/default/voxel_mesher_default.h b/meshers/default/voxel_mesher_default.h index abf7814..cbe0d1c 100644 --- a/meshers/default/voxel_mesher_default.h +++ b/meshers/default/voxel_mesher_default.h @@ -23,7 +23,14 @@ SOFTWARE. #ifndef VOXEL_MESHER_DEFAULT_H #define VOXEL_MESHER_DEFAULT_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/math/color.h" +#else #include "core/color.h" +#endif + #include "core/math/vector2.h" #include "core/math/vector3.h" diff --git a/meshers/marching_cubes/marching_cubes_cell_data.h b/meshers/marching_cubes/marching_cubes_cell_data.h index e757b60..653eb4e 100644 --- a/meshers/marching_cubes/marching_cubes_cell_data.h +++ b/meshers/marching_cubes/marching_cubes_cell_data.h @@ -23,7 +23,13 @@ SOFTWARE. #ifndef MARCHING_CUBES_CELL_DATA_H #define MARCHING_CUBES_CELL_DATA_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/object/reference.h" +#else #include "core/reference.h" +#endif #include "marching_cubes_tables.h" diff --git a/meshers/marching_cubes/voxel_mesher_marching_cubes.cpp b/meshers/marching_cubes/voxel_mesher_marching_cubes.cpp index 33d9f38..2945c28 100644 --- a/meshers/marching_cubes/voxel_mesher_marching_cubes.cpp +++ b/meshers/marching_cubes/voxel_mesher_marching_cubes.cpp @@ -20,12 +20,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/variant/array.h" +#include "core/variant/dictionary.h" +#else +#include "core/array.h" +#include "core/dictionary.h" +#endif + #include "voxel_mesher_marching_cubes.h" #include "../../world/default/voxel_chunk_default.h" #include "../../world/voxel_chunk.h" -#include "core/array.h" -#include "core/dictionary.h" #include "../../world/jobs/voxel_job.h" diff --git a/meshers/marching_cubes/voxel_mesher_marching_cubes.h b/meshers/marching_cubes/voxel_mesher_marching_cubes.h index 2f03225..1a7389e 100644 --- a/meshers/marching_cubes/voxel_mesher_marching_cubes.h +++ b/meshers/marching_cubes/voxel_mesher_marching_cubes.h @@ -23,8 +23,15 @@ SOFTWARE. #ifndef VOXEL_MESHER_MARCHING_CUBES_H #define VOXEL_MESHER_MARCHING_CUBES_H -#include "../default/voxel_mesher_default.h" +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/object/reference.h" +#else #include "core/reference.h" +#endif + +#include "../default/voxel_mesher_default.h" #include "marching_cubes_cell_data.h" diff --git a/meshers/voxel_mesher.h b/meshers/voxel_mesher.h index 60f0505..4daa2b6 100644 --- a/meshers/voxel_mesher.h +++ b/meshers/voxel_mesher.h @@ -23,7 +23,17 @@ SOFTWARE. #ifndef VOXEL_TOOLS_H #define VOXEL_TOOLS_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/object/reference.h" +#include "core/templates/vector.h" +#include "core/math/color.h" +#else #include "core/reference.h" +#include "core/vector.h" +#include "core/color.h" +#endif #include "../defines.h" @@ -32,11 +42,9 @@ include_pool_vector #include mesh_instance_h -#include "core/color.h" #include "core/math/rect2.h" #include "core/math/vector2.h" #include "core/math/vector3.h" -#include "core/vector.h" #include "scene/main/node.h" #include "scene/resources/material.h" #include "scene/resources/mesh.h" diff --git a/world/block_voxel_structure.h b/world/block_voxel_structure.h index 73afa1f..0851804 100644 --- a/world/block_voxel_structure.h +++ b/world/block_voxel_structure.h @@ -23,13 +23,21 @@ SOFTWARE. #ifndef BLOCK_VOXEL_STRUCTURE_H #define BLOCK_VOXEL_STRUCTURE_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/templates/vector.h" +#else +#include "core/vector.h" +#endif + #include "voxel_structure.h" #include "../defines.h" #include pool_vector_h include_pool_vector -#include "core/vector.h" + #include "voxel_chunk.h" ; diff --git a/world/default/voxel_chunk_default.cpp b/world/default/voxel_chunk_default.cpp index ad2e502..369be46 100644 --- a/world/default/voxel_chunk_default.cpp +++ b/world/default/voxel_chunk_default.cpp @@ -122,8 +122,13 @@ RID VoxelChunkDefault::mesh_rid_get(const int mesh_index, const int mesh_type_in Variant v = m[mesh_type_index]; +#if VERSION_MAJOR > 3 + if (v.get_type() != Variant::RID) + return RID(); +#else if (v.get_type() != Variant::_RID) return RID(); +#endif return v; } @@ -141,7 +146,11 @@ void VoxelChunkDefault::mesh_rid_set(const int mesh_index, const int mesh_type_i Variant v = m[mesh_type_index]; +#if VERSION_MAJOR > 3 + ERR_FAIL_COND(v.get_type() != Variant::RID); +#else ERR_FAIL_COND(v.get_type() != Variant::_RID); +#endif m[mesh_type_index] = value; _rids[mesh_index] = m; diff --git a/world/default/voxel_chunk_default.h b/world/default/voxel_chunk_default.h index 115ff34..d8c8e6f 100644 --- a/world/default/voxel_chunk_default.h +++ b/world/default/voxel_chunk_default.h @@ -23,26 +23,31 @@ SOFTWARE. #ifndef VOXEL_CHUNK_DEFAULT_H #define VOXEL_CHUNK_DEFAULT_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/string/ustring.h" +#include "core/config/engine.h" +#include "core/variant/array.h" +#else +#include "core/ustring.h" +#include "core/engine.h" +#include "core/array.h" +#endif + + #include "../voxel_chunk.h" #include "../../defines.h" -#include "core/engine.h" #include "core/os/mutex.h" #include "core/os/thread.h" #include "core/os/thread_safe.h" -#include "core/ustring.h" - -#include "core/array.h" #include "scene/resources/packed_scene.h" - #include "../voxel_world.h" - #include "../../data/voxel_light.h" - #include "../../meshers/voxel_mesher.h" - #include "../../library/voxel_surface.h" #include "../../library/voxelman_library.h" diff --git a/world/environment_data.h b/world/environment_data.h index 445a579..37d39b7 100644 --- a/world/environment_data.h +++ b/world/environment_data.h @@ -23,13 +23,20 @@ SOFTWARE. #ifndef ENVIRONMENT_DATA_H #define ENVIRONMENT_DATA_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/io/resource.h" +#include "core/math/color.h" +#else +#include "core/resource.h" +#include "core/color.h" +#endif + #include "../defines.h" #include light_h -#include "core/color.h" -#include "core/resource.h" - #include "scene/3d/world_environment.h" #include "scene/main/node.h" diff --git a/world/jobs/voxel_job.h b/world/jobs/voxel_job.h index 2c3be49..023af5a 100644 --- a/world/jobs/voxel_job.h +++ b/world/jobs/voxel_job.h @@ -28,9 +28,17 @@ SOFTWARE. #if THREAD_POOL_PRESENT #include "../../../thread_pool/thread_pool_job.h" #else + +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/object/reference.h" +#else #include "core/reference.h" #endif +#endif + #include "../../defines.h" #if GODOT4 diff --git a/world/voxel_chunk.h b/world/voxel_chunk.h index d4f7a51..06f76c1 100644 --- a/world/voxel_chunk.h +++ b/world/voxel_chunk.h @@ -23,20 +23,28 @@ SOFTWARE. #ifndef VOXEL_CHUNK_H #define VOXEL_CHUNK_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/io/resource.h" +#include "core/string/ustring.h" +#include "core/config/engine.h" +#include "core/variant/array.h" +#else #include "core/resource.h" +#include "core/ustring.h" +#include "core/engine.h" +#include "core/array.h" +#endif #include "../defines.h" #include pool_vector_h include_pool_vector -#include "core/engine.h" #include "core/os/mutex.h" #include "core/os/thread.h" #include "core/os/thread_safe.h" -#include "core/ustring.h" - -#include "core/array.h" #include "scene/resources/packed_scene.h" diff --git a/world/voxel_structure.h b/world/voxel_structure.h index 5dfe91a..67164af 100644 --- a/world/voxel_structure.h +++ b/world/voxel_structure.h @@ -23,14 +23,21 @@ SOFTWARE. #ifndef VOXEL_STRUCTURE_H #define VOXEL_STRUCTURE_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/io/resource.h" +#include "core/templates/hash_map.h" +#else #include "core/resource.h" +#include "core/hash_map.h" +#endif #include "../defines.h" #include pool_vector_h include_pool_vector -#include "core/hash_map.h" #include "core/math/aabb.h" #include "voxel_chunk.h" diff --git a/world/voxel_world.cpp b/world/voxel_world.cpp index 00ee45b..0a40906 100644 --- a/world/voxel_world.cpp +++ b/world/voxel_world.cpp @@ -22,6 +22,8 @@ SOFTWARE. #include "voxel_world.h" +#include "core/version.h" + #include "voxel_chunk.h" #include "voxel_structure.h" @@ -942,7 +944,11 @@ void VoxelWorld::_notification(int p_what) { } } +#if VERSION_MAJOR > 3 + if (_is_priority_generation && _generation_queue.is_empty() && _generating.is_empty()) { +#else if (_is_priority_generation && _generation_queue.empty() && _generating.empty()) { +#endif _is_priority_generation = false; call("_generation_finished"); diff --git a/world/voxel_world.h b/world/voxel_world.h index 516944a..ac9a594 100644 --- a/world/voxel_world.h +++ b/world/voxel_world.h @@ -23,13 +23,20 @@ SOFTWARE. #ifndef VOXEL_WORLD_H #define VOXEL_WORLD_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/templates/hash_map.h" +#include "core/config/engine.h" +#else +#include "core/hash_map.h" +#include "core/engine.h" +#endif + #include "../defines.h" #include navigation_h -#include "core/engine.h" -#include "core/hash_map.h" - #include "../areas/world_area.h" #include "../level_generator/voxelman_level_generator.h" #include "../library/voxelman_library.h"