Fix compile for 4.0.

This commit is contained in:
Relintai 2021-02-06 11:51:50 +01:00
parent fd464c042c
commit 547aeaad4d
27 changed files with 218 additions and 36 deletions

View File

@ -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 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. check whether it works from time to time.
## Optional Dependencies ## Optional Dependencies

View File

@ -23,10 +23,18 @@ SOFTWARE.
#ifndef WORLD_AREA_H #ifndef WORLD_AREA_H
#define 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/reference.h"
#include "core/ustring.h"
#endif
#include "core/math/aabb.h" #include "core/math/aabb.h"
#include "core/ustring.h"
#include "scene/resources/texture.h" #include "scene/resources/texture.h"
class WorldArea : public Reference { class WorldArea : public Reference {

View File

@ -23,9 +23,17 @@ SOFTWARE.
#ifndef VOXEL_LIGHT_H #ifndef VOXEL_LIGHT_H
#define 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/reference.h"
#include "core/vector.h" #include "core/vector.h"
#include "core/color.h"
#endif
class VoxelLight : public Reference { class VoxelLight : public Reference {
GDCLASS(VoxelLight, Reference); GDCLASS(VoxelLight, Reference);

View File

@ -18,7 +18,7 @@
#define light_h "scene/3d/light_3d.h" #define light_h "scene/3d/light_3d.h"
#define visual_server_h "servers/rendering_server.h" #define visual_server_h "servers/rendering_server.h"
#define mesh_instance_h "scene/3d/mesh_instance_3d.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 physics_server_h "servers/physics_server_3d.h"
#define immediate_geometry_h "scene/3d/immediate_geometry_3d.h" #define immediate_geometry_h "scene/3d/immediate_geometry_3d.h"
#define include_pool_vector \ #define include_pool_vector \

View File

@ -23,7 +23,13 @@ SOFTWARE.
#ifndef VOXELMAN_LEVEL_GENERATOR_H #ifndef VOXELMAN_LEVEL_GENERATOR_H
#define 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" #include "core/resource.h"
#endif
class VoxelChunk; class VoxelChunk;

View File

@ -23,11 +23,20 @@ SOFTWARE.
#ifndef VOXEL_SURFACE_H #ifndef VOXEL_SURFACE_H
#define VOXEL_SURFACE_H #define VOXEL_SURFACE_H
#include "core/resource.h"
#include "core/color.h" #include "core/version.h"
#include "core/math/rect2.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/vector.h"
#include "core/color.h"
#endif
#include "core/math/rect2.h"
#include "scene/resources/material.h" #include "scene/resources/material.h"
#include "voxelman_library.h" #include "voxelman_library.h"

View File

@ -23,8 +23,15 @@ SOFTWARE.
#ifndef VOXELMAN_LIBRARY_H #ifndef VOXELMAN_LIBRARY_H
#define 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" #include "core/resource.h"
#endif
#include "core/math/rect2.h"
#include "scene/resources/material.h" #include "scene/resources/material.h"
#include "../data/voxel_light.h" #include "../data/voxel_light.h"

View File

@ -23,10 +23,18 @@ SOFTWARE.
#ifndef VOXELMAN_LIBRARY_MERGER_H #ifndef VOXELMAN_LIBRARY_MERGER_H
#define 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 "voxelman_library.h"
#include "core/map.h"
#include "core/resource.h"
#include "scene/resources/material.h" #include "scene/resources/material.h"
#include "../data/voxel_light.h" #include "../data/voxel_light.h"

View File

@ -23,9 +23,16 @@ SOFTWARE.
#ifndef VOXELMAN_LIBRARY_SIMPLE_H #ifndef VOXELMAN_LIBRARY_SIMPLE_H
#define 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 "voxelman_library.h"
#include "core/resource.h"
#include "scene/resources/material.h" #include "scene/resources/material.h"
#include "../data/voxel_light.h" #include "../data/voxel_light.h"

View File

@ -23,7 +23,14 @@ SOFTWARE.
#ifndef VOXEL_MESHER_BLOCKY_H #ifndef VOXEL_MESHER_BLOCKY_H
#define 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" #include "core/color.h"
#endif
#include "core/math/vector2.h" #include "core/math/vector2.h"
#include "core/math/vector3.h" #include "core/math/vector3.h"

View File

@ -23,7 +23,14 @@ SOFTWARE.
#ifndef VOXEL_MESHER_LIQUID_BLOCKY_H #ifndef VOXEL_MESHER_LIQUID_BLOCKY_H
#define 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" #include "core/color.h"
#endif
#include "core/math/vector2.h" #include "core/math/vector2.h"
#include "core/math/vector3.h" #include "core/math/vector3.h"

View File

@ -23,8 +23,15 @@ SOFTWARE.
#ifndef SUB_VOXEL_POINTS_H #ifndef SUB_VOXEL_POINTS_H
#define 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/reference.h"
#include "core/vector.h" #include "core/vector.h"
#endif
class VoxelChunk; class VoxelChunk;
class SubVoxelFacePointsHelper; class SubVoxelFacePointsHelper;

View File

@ -23,7 +23,14 @@ SOFTWARE.
#ifndef VOXEL_MESHER_CUBIC_H #ifndef VOXEL_MESHER_CUBIC_H
#define 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" #include "core/color.h"
#endif
#include "core/math/vector2.h" #include "core/math/vector2.h"
#include "core/math/vector3.h" #include "core/math/vector3.h"

View File

@ -23,7 +23,14 @@ SOFTWARE.
#ifndef VOXEL_MESHER_DEFAULT_H #ifndef VOXEL_MESHER_DEFAULT_H
#define 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" #include "core/color.h"
#endif
#include "core/math/vector2.h" #include "core/math/vector2.h"
#include "core/math/vector3.h" #include "core/math/vector3.h"

View File

@ -23,7 +23,13 @@ SOFTWARE.
#ifndef MARCHING_CUBES_CELL_DATA_H #ifndef MARCHING_CUBES_CELL_DATA_H
#define 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" #include "core/reference.h"
#endif
#include "marching_cubes_tables.h" #include "marching_cubes_tables.h"

View File

@ -20,12 +20,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. 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 "voxel_mesher_marching_cubes.h"
#include "../../world/default/voxel_chunk_default.h" #include "../../world/default/voxel_chunk_default.h"
#include "../../world/voxel_chunk.h" #include "../../world/voxel_chunk.h"
#include "core/array.h"
#include "core/dictionary.h"
#include "../../world/jobs/voxel_job.h" #include "../../world/jobs/voxel_job.h"

View File

@ -23,8 +23,15 @@ SOFTWARE.
#ifndef VOXEL_MESHER_MARCHING_CUBES_H #ifndef VOXEL_MESHER_MARCHING_CUBES_H
#define 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" #include "core/reference.h"
#endif
#include "../default/voxel_mesher_default.h"
#include "marching_cubes_cell_data.h" #include "marching_cubes_cell_data.h"

View File

@ -23,7 +23,17 @@ SOFTWARE.
#ifndef VOXEL_TOOLS_H #ifndef VOXEL_TOOLS_H
#define 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/reference.h"
#include "core/vector.h"
#include "core/color.h"
#endif
#include "../defines.h" #include "../defines.h"
@ -32,11 +42,9 @@ include_pool_vector
#include mesh_instance_h #include mesh_instance_h
#include "core/color.h"
#include "core/math/rect2.h" #include "core/math/rect2.h"
#include "core/math/vector2.h" #include "core/math/vector2.h"
#include "core/math/vector3.h" #include "core/math/vector3.h"
#include "core/vector.h"
#include "scene/main/node.h" #include "scene/main/node.h"
#include "scene/resources/material.h" #include "scene/resources/material.h"
#include "scene/resources/mesh.h" #include "scene/resources/mesh.h"

View File

@ -23,13 +23,21 @@ SOFTWARE.
#ifndef BLOCK_VOXEL_STRUCTURE_H #ifndef BLOCK_VOXEL_STRUCTURE_H
#define 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 "voxel_structure.h"
#include "../defines.h" #include "../defines.h"
#include pool_vector_h #include pool_vector_h
include_pool_vector include_pool_vector
#include "core/vector.h"
#include "voxel_chunk.h" #include "voxel_chunk.h"
; ;

View File

@ -122,8 +122,13 @@ RID VoxelChunkDefault::mesh_rid_get(const int mesh_index, const int mesh_type_in
Variant v = m[mesh_type_index]; 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) if (v.get_type() != Variant::_RID)
return RID(); return RID();
#endif
return v; 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]; 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); ERR_FAIL_COND(v.get_type() != Variant::_RID);
#endif
m[mesh_type_index] = value; m[mesh_type_index] = value;
_rids[mesh_index] = m; _rids[mesh_index] = m;

View File

@ -23,26 +23,31 @@ SOFTWARE.
#ifndef VOXEL_CHUNK_DEFAULT_H #ifndef VOXEL_CHUNK_DEFAULT_H
#define 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 "../voxel_chunk.h"
#include "../../defines.h" #include "../../defines.h"
#include "core/engine.h"
#include "core/os/mutex.h" #include "core/os/mutex.h"
#include "core/os/thread.h" #include "core/os/thread.h"
#include "core/os/thread_safe.h" #include "core/os/thread_safe.h"
#include "core/ustring.h"
#include "core/array.h"
#include "scene/resources/packed_scene.h" #include "scene/resources/packed_scene.h"
#include "../voxel_world.h" #include "../voxel_world.h"
#include "../../data/voxel_light.h" #include "../../data/voxel_light.h"
#include "../../meshers/voxel_mesher.h" #include "../../meshers/voxel_mesher.h"
#include "../../library/voxel_surface.h" #include "../../library/voxel_surface.h"
#include "../../library/voxelman_library.h" #include "../../library/voxelman_library.h"

View File

@ -23,13 +23,20 @@ SOFTWARE.
#ifndef ENVIRONMENT_DATA_H #ifndef ENVIRONMENT_DATA_H
#define 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 "../defines.h"
#include light_h #include light_h
#include "core/color.h"
#include "core/resource.h"
#include "scene/3d/world_environment.h" #include "scene/3d/world_environment.h"
#include "scene/main/node.h" #include "scene/main/node.h"

View File

@ -28,9 +28,17 @@ SOFTWARE.
#if THREAD_POOL_PRESENT #if THREAD_POOL_PRESENT
#include "../../../thread_pool/thread_pool_job.h" #include "../../../thread_pool/thread_pool_job.h"
#else #else
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/object/reference.h"
#else
#include "core/reference.h" #include "core/reference.h"
#endif #endif
#endif
#include "../../defines.h" #include "../../defines.h"
#if GODOT4 #if GODOT4

View File

@ -23,20 +23,28 @@ SOFTWARE.
#ifndef VOXEL_CHUNK_H #ifndef VOXEL_CHUNK_H
#define 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/resource.h"
#include "core/ustring.h"
#include "core/engine.h"
#include "core/array.h"
#endif
#include "../defines.h" #include "../defines.h"
#include pool_vector_h #include pool_vector_h
include_pool_vector include_pool_vector
#include "core/engine.h"
#include "core/os/mutex.h" #include "core/os/mutex.h"
#include "core/os/thread.h" #include "core/os/thread.h"
#include "core/os/thread_safe.h" #include "core/os/thread_safe.h"
#include "core/ustring.h"
#include "core/array.h"
#include "scene/resources/packed_scene.h" #include "scene/resources/packed_scene.h"

View File

@ -23,14 +23,21 @@ SOFTWARE.
#ifndef VOXEL_STRUCTURE_H #ifndef VOXEL_STRUCTURE_H
#define 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/resource.h"
#include "core/hash_map.h"
#endif
#include "../defines.h" #include "../defines.h"
#include pool_vector_h #include pool_vector_h
include_pool_vector include_pool_vector
#include "core/hash_map.h"
#include "core/math/aabb.h" #include "core/math/aabb.h"
#include "voxel_chunk.h" #include "voxel_chunk.h"

View File

@ -22,6 +22,8 @@ SOFTWARE.
#include "voxel_world.h" #include "voxel_world.h"
#include "core/version.h"
#include "voxel_chunk.h" #include "voxel_chunk.h"
#include "voxel_structure.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()) { if (_is_priority_generation && _generation_queue.empty() && _generating.empty()) {
#endif
_is_priority_generation = false; _is_priority_generation = false;
call("_generation_finished"); call("_generation_finished");

View File

@ -23,13 +23,20 @@ SOFTWARE.
#ifndef VOXEL_WORLD_H #ifndef VOXEL_WORLD_H
#define 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 "../defines.h"
#include navigation_h #include navigation_h
#include "core/engine.h"
#include "core/hash_map.h"
#include "../areas/world_area.h" #include "../areas/world_area.h"
#include "../level_generator/voxelman_level_generator.h" #include "../level_generator/voxelman_level_generator.h"
#include "../library/voxelman_library.h" #include "../library/voxelman_library.h"