From 5b9617bfaac62d2c5dce62a8f120a1c874b7306b Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 6 Feb 2021 11:51:02 +0100 Subject: [PATCH] Fix compile for 4.0. --- README.md | 1 + mesh_data_resource.h | 10 +++++++++- mesh_data_resource_collection.h | 8 +++++++- nodes/mesh_data_instance.cpp | 11 ++++++++++- plugin/mdr_import_plugin_base.cpp | 16 ++++++++++++++-- plugin/mdr_import_plugin_base.h | 16 +++++++++++++--- plugin_collada/editor_import_collada_mdr.h | 12 ++++++++++-- plugin_collada/editor_plugin_collada_mdr.h | 7 +++++++ plugin_gltf/editor_import_gltf_mdr.h | 15 ++++++++++++--- plugin_gltf/editor_plugin_gltf_mdr.h | 7 +++++++ 10 files changed, 90 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 5851474..8d2020c 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ If you want Godot 3.2: If you want Godot 4.0: ```git clone https://github.com/godotengine/godot.git godot``` +[last tested commit for 4.0](https://github.com/godotengine/godot/commit/b7e10141197fdd9b0dbc4cfa7890329510d36540) 2. Go into Godot's modules directory. diff --git a/mesh_data_resource.h b/mesh_data_resource.h index 8db1536..0772c2f 100644 --- a/mesh_data_resource.h +++ b/mesh_data_resource.h @@ -23,8 +23,16 @@ SOFTWARE. #ifndef MESH_DATA_REOURCE_H #define MESH_DATA_REOURCE_H -#include "core/array.h" +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/io/resource.h" +#include "core/variant/array.h" +#else #include "core/resource.h" +#include "core/array.h" +#endif + #include "core/version.h" #include "scene/resources/mesh.h" diff --git a/mesh_data_resource_collection.h b/mesh_data_resource_collection.h index 681aabd..88a4735 100644 --- a/mesh_data_resource_collection.h +++ b/mesh_data_resource_collection.h @@ -23,9 +23,15 @@ SOFTWARE. #ifndef MESH_DATA_REOURCE_COLLECTION_H #define MESH_DATA_REOURCE_COLLECTION_H -#include "core/resource.h" +#include "core/version.h" +#if VERSION_MAJOR > 3 +#include "core/io/resource.h" +#include "core/templates/vector.h" +#else +#include "core/resource.h" #include "core/vector.h" +#endif #include "mesh_data_resource.h" diff --git a/nodes/mesh_data_instance.cpp b/nodes/mesh_data_instance.cpp index 4432832..e290470 100644 --- a/nodes/mesh_data_instance.cpp +++ b/nodes/mesh_data_instance.cpp @@ -2,11 +2,20 @@ #include "core/version.h" +#include "core/version.h" +#include "scene/resources/texture.h" + +#if VERSION_MAJOR < 4 +#include "core/image.h" +#else +#include "core/io/image.h" +#endif + #if TEXTURE_PACKER_PRESENT #include "../../texture_packer/texture_resource/packer_image_resource.h" #endif -#include "core/image.h" + bool MeshDataInstance::get_snap_to_mesh() const { return _snap_to_mesh; diff --git a/plugin/mdr_import_plugin_base.cpp b/plugin/mdr_import_plugin_base.cpp index 48e8516..fff3162 100644 --- a/plugin/mdr_import_plugin_base.cpp +++ b/plugin/mdr_import_plugin_base.cpp @@ -281,7 +281,7 @@ Ref MDRImportPluginBase::get_mesh(MeshInstance *mi, const Map< m.instance(); m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array()); - Vector > shapes = mesh->convex_decompose(); + Vector> shapes = mesh->convex_decompose(); for (int j = 0; j < shapes.size(); ++j) { scale_shape(shapes[j], scale); @@ -301,7 +301,11 @@ Ref MDRImportPluginBase::get_mesh(MeshInstance *mi, const Map< AABB aabb = m->get_aabb(); Vector3 size = aabb.get_size(); +#if VERSION_MAJOR > 3 + shape->set_size(size * 0.5); +#else shape->set_extents(size * 0.5); +#endif Vector3 pos = aabb.position; pos += size / 2.0; @@ -420,7 +424,7 @@ Ref MDRImportPluginBase::get_mesh_arrays(Array &arrs, const Ma m.instance(); m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array()); - Vector > shapes = mesh->convex_decompose(); + Vector> shapes = mesh->convex_decompose(); for (int j = 0; j < shapes.size(); ++j) { scale_shape(shapes[j], scale); @@ -440,7 +444,11 @@ Ref MDRImportPluginBase::get_mesh_arrays(Array &arrs, const Ma AABB aabb = m->get_aabb(); Vector3 size = aabb.get_size(); +#if VERSION_MAJOR > 3 + shape->set_size(size * 0.5); +#else shape->set_extents(size * 0.5); +#endif Vector3 pos = aabb.position; pos += size / 2.0; @@ -746,7 +754,11 @@ Ref MDRImportPluginBase::scale_shape(Ref shape, const Vector3 &sca if (Object::cast_to(*shape)) { Ref bs = shape; +#if VERSION_MAJOR > 3 + bs->set_size(bs->get_size() * scale); +#else bs->set_extents(bs->get_extents() * scale); +#endif } if (Object::cast_to(*shape)) { diff --git a/plugin/mdr_import_plugin_base.h b/plugin/mdr_import_plugin_base.h index 94c707a..3630fb3 100644 --- a/plugin/mdr_import_plugin_base.h +++ b/plugin/mdr_import_plugin_base.h @@ -23,18 +23,26 @@ SOFTWARE. #ifndef MDR_IMPORT_PLUGIN_BASE #define MDR_IMPORT_PLUGIN_BASE -#include "../mesh_data_resource_collection.h" +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/string/ustring.h" +#include "core/variant/array.h" +#else +#include "core/ustring.h" #include "core/array.h" +#endif + +#include "../mesh_data_resource_collection.h" #include "core/io/resource_saver.h" #include "core/math/basis.h" #include "core/math/transform.h" -#include "core/ustring.h" #include "editor/import/editor_import_plugin.h" #include "scene/main/node.h" #include "scene/resources/mesh.h" #include "../mesh_data_resource.h" -#include "editor/import/editor_scene_importer_gltf.h" + #include "core/math/transform.h" @@ -42,8 +50,10 @@ SOFTWARE. #if VERSION_MAJOR < 4 #include "scene/3d/mesh_instance.h" +#include "editor/import/editor_scene_importer_gltf.h" #else #include "scene/3d/mesh_instance_3d.h" +#include "../../gltf/editor_scene_importer_gltf.h" #define MeshInstance MeshInstance3D #endif diff --git a/plugin_collada/editor_import_collada_mdr.h b/plugin_collada/editor_import_collada_mdr.h index 8d5535c..2d58309 100644 --- a/plugin_collada/editor_import_collada_mdr.h +++ b/plugin_collada/editor_import_collada_mdr.h @@ -23,13 +23,21 @@ SOFTWARE. #ifndef EDITOR_IMPORT_COLLADA_MDR #define EDITOR_IMPORT_COLLADA_MDR +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/string/ustring.h" +#include "core/variant/array.h" +#else +#include "core/ustring.h" +#include "core/array.h" +#endif + #include "../plugin/mdr_import_plugin_base.h" -#include "core/array.h" #include "core/io/resource_saver.h" #include "core/math/basis.h" #include "core/math/transform.h" -#include "core/ustring.h" #include "editor/import/editor_import_plugin.h" #include "scene/main/node.h" #include "scene/resources/mesh.h" diff --git a/plugin_collada/editor_plugin_collada_mdr.h b/plugin_collada/editor_plugin_collada_mdr.h index ad3bfd6..71006fe 100644 --- a/plugin_collada/editor_plugin_collada_mdr.h +++ b/plugin_collada/editor_plugin_collada_mdr.h @@ -23,7 +23,14 @@ SOFTWARE. #ifndef EDITOR_PLUGIN_COLLADA_MDR #define EDITOR_PLUGIN_COLLADA_MDR +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/string/ustring.h" +#else #include "core/ustring.h" +#endif + #include "editor/editor_plugin.h" #include "editor_import_collada_mdr.h" diff --git a/plugin_gltf/editor_import_gltf_mdr.h b/plugin_gltf/editor_import_gltf_mdr.h index bf1ea90..46b81b5 100644 --- a/plugin_gltf/editor_import_gltf_mdr.h +++ b/plugin_gltf/editor_import_gltf_mdr.h @@ -23,26 +23,35 @@ SOFTWARE. #ifndef EDITOR_IMPORT_GLTF_MDR #define EDITOR_IMPORT_GLTF_MDR +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/string/ustring.h" +#include "core/variant/array.h" +#else +#include "core/ustring.h" +#include "core/array.h" +#endif + #include "../plugin/mdr_import_plugin_base.h" -#include "core/array.h" #include "core/io/resource_saver.h" #include "core/math/basis.h" #include "core/math/transform.h" -#include "core/ustring.h" #include "scene/main/node.h" #include "scene/resources/mesh.h" #include "../mesh_data_resource.h" -#include "editor/import/editor_scene_importer_gltf.h" #include "core/math/transform.h" #include "core/version.h" #if VERSION_MAJOR < 4 +#include "editor/import/editor_scene_importer_gltf.h" #include "scene/3d/mesh_instance.h" #else +#include "../../gltf/editor_scene_importer_gltf.h" #include "scene/3d/mesh_instance_3d.h" #define MeshInstance MeshInstance3D diff --git a/plugin_gltf/editor_plugin_gltf_mdr.h b/plugin_gltf/editor_plugin_gltf_mdr.h index de4fd20..b854e27 100644 --- a/plugin_gltf/editor_plugin_gltf_mdr.h +++ b/plugin_gltf/editor_plugin_gltf_mdr.h @@ -23,7 +23,14 @@ SOFTWARE. #ifndef EDITOR_PLUGIN_GLTF_MDR #define EDITOR_PLUGIN_GLTF_MDR +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/string/ustring.h" +#else #include "core/ustring.h" +#endif + #include "editor/editor_plugin.h" #include "editor_import_gltf_mdr.h"