From bedb86c98739bd7b045cdaacae43a9cdbbcbe373 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 9 Jan 2023 01:17:26 +0100 Subject: [PATCH] Work on fixing compile. --- mesh_data_resource.cpp | 9 ++- nodes/mesh_data_instance.cpp | 38 +++++----- nodes/mesh_data_instance.h | 8 +- nodes/mesh_data_instance_2d.cpp | 20 ++--- plugin/mdr_import_plugin_base.cpp | 79 ++++++++++---------- plugin/mdr_import_plugin_base.h | 26 +++---- plugin_collada/editor_import_collada_mdr.cpp | 6 +- plugin_collada/editor_import_collada_mdr.h | 8 +- plugin_collada/editor_plugin_collada_mdr.cpp | 5 +- plugin_collada/editor_plugin_collada_mdr.h | 3 +- plugin_gltf/editor_import_gltf_mdr.cpp | 4 +- plugin_gltf/editor_import_gltf_mdr.h | 15 ++-- plugin_gltf/editor_plugin_gltf_mdr.cpp | 5 +- plugin_gltf/editor_plugin_gltf_mdr.h | 3 +- props/prop_data_mesh_data.cpp | 4 +- props_2d/prop_2d_data_mesh_data.cpp | 2 +- register_types.cpp | 2 +- 17 files changed, 118 insertions(+), 119 deletions(-) diff --git a/mesh_data_resource.cpp b/mesh_data_resource.cpp index 6c37268..7851c38 100644 --- a/mesh_data_resource.cpp +++ b/mesh_data_resource.cpp @@ -28,11 +28,16 @@ SOFTWARE. #include "core/variant/variant.h" #define PoolVector Vector -#define POOL_INT_ARRAY PACKED_INT_ARRAY +#define POOL_INT_ARRAY PACKED_INT32_ARRAY #else #include "core/variant.h" #endif +#define PoolVector3Array PackedVector3Array +#define PoolRealArray PackedFloat32Array +#define PoolColorArray PackedColorArray +#define PoolVector2Array PackedVector2Array + const String MeshDataResource::BINDING_STRING_COLLIDER_TYPE = "None,Trimesh Collision Shape,Single Convex Collision Shape,Multiple Convex Collision Shapes,Approximated Box,Approximated Capsule,Approximated Cylinder,Approximated Sphere"; Array MeshDataResource::get_array() { @@ -300,7 +305,7 @@ void MeshDataResource::recompute_aabb() { PoolVector::Read r = vertices_2d.read(); const Vector2 *vtx = r.ptr(); #else - const Vector2 *vtx = vertices.ptr(); + const Vector2 *vtx = vertices_2d.ptr(); #endif int len = vertices_2d.size(); aabb.position = Vector3(vtx[0].x, vtx[0].y, 0); diff --git a/nodes/mesh_data_instance.cpp b/nodes/mesh_data_instance.cpp index 6b1b113..8daf310 100644 --- a/nodes/mesh_data_instance.cpp +++ b/nodes/mesh_data_instance.cpp @@ -19,7 +19,7 @@ #include "../../texture_packer/texture_resource/packer_image_resource.h" #endif -#include "scene/3d/mesh_instance.h" +#include "scene/3d/mesh_instance_3d.h" bool MeshDataInstance::get_snap_to_mesh() const { return _snap_to_mesh; @@ -40,7 +40,7 @@ Ref MeshDataInstance::get_mesh_data() { } void MeshDataInstance::set_mesh_data(const Ref &mesh) { if (_mesh.is_valid()) { - _mesh->disconnect("changed", this, "refresh"); + _mesh->disconnect("changed", Callable(this, "refresh")); } _mesh = mesh; @@ -48,7 +48,7 @@ void MeshDataInstance::set_mesh_data(const Ref &mesh) { refresh(); if (_mesh.is_valid()) { - _mesh->connect("changed", this, "refresh"); + _mesh->connect("changed", Callable(this, "refresh")); } emit_signal("mesh_data_resource_changed", _mesh); @@ -82,8 +82,8 @@ AABB MeshDataInstance::get_aabb() const { return _mesh->get_aabb(); } -PoolVector MeshDataInstance::get_faces(uint32_t p_usage_flags) const { - PoolVector faces; +Vector MeshDataInstance::get_faces(uint32_t p_usage_flags) const { + Vector faces; if (_mesh.is_valid()) { Array arrs = _mesh->get_array_const(); @@ -92,15 +92,15 @@ PoolVector MeshDataInstance::get_faces(uint32_t p_usage_flags) const { return faces; } - PoolVector vertices = arrs[Mesh::ARRAY_VERTEX]; - PoolVector indices = arrs[Mesh::ARRAY_INDEX]; + Vector vertices = arrs[Mesh::ARRAY_VERTEX]; + Vector indices = arrs[Mesh::ARRAY_INDEX]; int ts = indices.size() / 3; faces.resize(ts); - PoolVector::Write w = faces.write(); - PoolVector::Read rv = vertices.read(); - PoolVector::Read ri = indices.read(); + Face3 *w = faces.ptrw(); + const Vector3 *rv = vertices.ptr(); + //const int *ri = indices.ptr(); for (int i = 0; i < ts; i++) { int im3 = (i * 3); @@ -109,8 +109,6 @@ PoolVector MeshDataInstance::get_faces(uint32_t p_usage_flags) const { w[i].vertex[j] = rv[indices[im3 + j]]; } } - - w.release(); } return faces; @@ -122,12 +120,12 @@ void MeshDataInstance::refresh() { } if (_mesh_rid == RID()) { - _mesh_rid = VisualServer::get_singleton()->mesh_create(); + _mesh_rid = RS::get_singleton()->mesh_create(); - VS::get_singleton()->instance_set_base(get_instance(), _mesh_rid); + RS::get_singleton()->instance_set_base(get_instance(), _mesh_rid); } - VisualServer::get_singleton()->mesh_clear(_mesh_rid); + RS::get_singleton()->mesh_clear(_mesh_rid); if (!_mesh.is_valid()) { return; @@ -139,16 +137,16 @@ void MeshDataInstance::refresh() { return; } - PoolVector vertices = arr[Mesh::ARRAY_VERTEX]; + Vector vertices = arr[Mesh::ARRAY_VERTEX]; if (vertices.size() == 0) { return; } - VisualServer::get_singleton()->mesh_add_surface_from_arrays(_mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, arr); + RS::get_singleton()->mesh_add_surface_from_arrays(_mesh_rid, RS::PRIMITIVE_TRIANGLES, arr); if (_material.is_valid()) { - VisualServer::get_singleton()->mesh_surface_set_material(_mesh_rid, 0, _material->get_rid()); + RS::get_singleton()->mesh_surface_set_material(_mesh_rid, 0, _material->get_rid()); } } @@ -183,7 +181,7 @@ void MeshDataInstance::setup_material_texture() { Ref i = r->get_data(); Ref tex; - tex.instance(); + tex.instantiate(); #if VERSION_MAJOR < 4 tex->create_from_image(i, 0); #else @@ -204,7 +202,7 @@ void MeshDataInstance::setup_material_texture() { void MeshDataInstance::free_meshes() { if (_mesh_rid != RID()) { - VS::get_singleton()->free(_mesh_rid); + RS::get_singleton()->free(_mesh_rid); _mesh_rid = RID(); } } diff --git a/nodes/mesh_data_instance.h b/nodes/mesh_data_instance.h index e1e4823..ca6e38b 100644 --- a/nodes/mesh_data_instance.h +++ b/nodes/mesh_data_instance.h @@ -29,7 +29,7 @@ SOFTWARE. #if VERSION_MAJOR < 4 #include "scene/3d/visual_instance.h" #else -#include "scene/3d/node_3d.h" +#include "scene/3d/visual_instance_3d.h" #define SpatialMaterial StandardMaterial3D #define Spatial Node3D @@ -42,8 +42,8 @@ SOFTWARE. class PropInstance; -class MeshDataInstance : public GeometryInstance { - GDCLASS(MeshDataInstance, GeometryInstance); +class MeshDataInstance : public GeometryInstance3D { + GDCLASS(MeshDataInstance, GeometryInstance3D); public: bool get_snap_to_mesh() const; @@ -62,7 +62,7 @@ public: void set_material(const Ref &mat); AABB get_aabb() const; - PoolVector get_faces(uint32_t p_usage_flags) const; + Vector get_faces(uint32_t p_usage_flags) const; void refresh(); void setup_material_texture(); diff --git a/nodes/mesh_data_instance_2d.cpp b/nodes/mesh_data_instance_2d.cpp index 554a35d..a898e0c 100644 --- a/nodes/mesh_data_instance_2d.cpp +++ b/nodes/mesh_data_instance_2d.cpp @@ -24,7 +24,7 @@ void MeshDataInstance2D::set_mesh_data(const Ref &mesh) { } if (_mesh.is_valid()) { - _mesh->disconnect("changed", this, "refresh"); + _mesh->disconnect("changed", Callable(this, "refresh")); } _mesh = mesh; @@ -32,7 +32,7 @@ void MeshDataInstance2D::set_mesh_data(const Ref &mesh) { refresh(); if (_mesh.is_valid()) { - _mesh->connect("changed", this, "refresh"); + _mesh->connect("changed", Callable(this, "refresh")); } emit_signal("mesh_data_resource_changed"); @@ -49,7 +49,7 @@ void MeshDataInstance2D::set_texture(const Ref &texture) { _texture = texture; emit_signal("texture_changed"); - _change_notify("texture"); + //_change_notify("texture"); refresh(); } @@ -71,7 +71,7 @@ void MeshDataInstance2D::refresh() { return; } - VisualServer::get_singleton()->mesh_clear(_mesh_rid); + RenderingServer::get_singleton()->mesh_clear(_mesh_rid); if (!_mesh.is_valid()) { return; @@ -83,13 +83,13 @@ void MeshDataInstance2D::refresh() { return; } - PoolVector vertices = arr[Mesh::ARRAY_VERTEX]; + Vector vertices = arr[Mesh::ARRAY_VERTEX]; if (vertices.size() == 0) { return; } - VisualServer::get_singleton()->mesh_add_surface_from_arrays(_mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, arr); + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(_mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, arr); } #ifdef TOOLS_ENABLED @@ -108,14 +108,14 @@ bool MeshDataInstance2D::_edit_use_rect() const { #endif MeshDataInstance2D::MeshDataInstance2D() { - _mesh_rid = VisualServer::get_singleton()->mesh_create(); + _mesh_rid = RenderingServer::get_singleton()->mesh_create(); } MeshDataInstance2D::~MeshDataInstance2D() { _mesh.unref(); _texture.unref(); if (_mesh_rid != RID()) { - VS::get_singleton()->free(_mesh_rid); + RS::get_singleton()->free(_mesh_rid); _mesh_rid = RID(); } } @@ -128,9 +128,9 @@ void MeshDataInstance2D::_notification(int p_what) { case NOTIFICATION_DRAW: { if (_mesh.is_valid()) { RID texture_rid = _texture.is_valid() ? _texture->get_rid() : RID(); - RID normal_map_rid = _normal_map.is_valid() ? _normal_map->get_rid() : RID(); + //RID normal_map_rid = _normal_map.is_valid() ? _normal_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_mesh(get_canvas_item(), _mesh_rid, Transform2D(), get_modulate(), texture_rid, normal_map_rid); + RenderingServer::get_singleton()->canvas_item_add_mesh(get_canvas_item(), _mesh_rid, Transform2D(), get_modulate(), texture_rid); } } break; } diff --git a/plugin/mdr_import_plugin_base.cpp b/plugin/mdr_import_plugin_base.cpp index af8235d..45b779d 100644 --- a/plugin/mdr_import_plugin_base.cpp +++ b/plugin/mdr_import_plugin_base.cpp @@ -81,7 +81,7 @@ const String MDRImportPluginBase::BINDING_MDR_OPTIMIZATION_TYPE = "Off" #endif ; -void MDRImportPluginBase::get_import_options(List *r_options, int p_preset) const { +void MDRImportPluginBase::get_import_options(const String &p_path, List *r_options, int p_preset) const { r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_type", PROPERTY_HINT_ENUM, BINDING_MDR_IMPORT_TYPE), MDRImportPluginBase::MDR_IMPORT_TIME_SINGLE)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "surface_handling", PROPERTY_HINT_ENUM, BINDING_MDR_SURFACE_HANDLING_TYPE), MDRImportPluginBase::MDR_SURFACE_HANDLING_TYPE_ONLY_USE_FIRST)); @@ -101,11 +101,11 @@ void MDRImportPluginBase::get_import_options(List *r_options, int r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "save_copy_as_resource"), false)); } -bool MDRImportPluginBase::get_option_visibility(const String &p_option, const Map &p_options) const { +bool MDRImportPluginBase::get_option_visibility(const String &p_path, const String &p_option, const HashMap &p_options) const { return true; } -Error MDRImportPluginBase::process_node(Node *n, const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { +Error MDRImportPluginBase::process_node(Node *n, const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { MDRImportPluginBase::MDRImportType type = static_cast(static_cast(p_options["import_type"])); switch (type) { @@ -121,12 +121,12 @@ Error MDRImportPluginBase::process_node(Node *n, const String &p_source_file, co bool save_copy_as_resource = static_cast(p_options["save_copy_as_resource"]); Ref coll; - coll.instance(); + coll.instantiate(); Ref copy_coll; if (save_copy_as_resource) { - copy_coll.instance(); + copy_coll.instantiate(); } process_node_multi(n, p_source_file, p_save_path, p_options, r_platform_variants, r_gen_files, r_metadata, coll, copy_coll); @@ -135,7 +135,7 @@ Error MDRImportPluginBase::process_node(Node *n, const String &p_source_file, co save_mdrcoll_copy_as_tres(p_source_file, copy_coll); } - return ResourceSaver::save(p_save_path + "." + get_save_extension(), coll); + return ResourceSaver::save(coll, p_save_path + "." + get_save_extension()); } //case MDR_IMPORT_TIME_SINGLE_WITH_SEPARATED_BONES: { @@ -162,7 +162,7 @@ int MDRImportPluginBase::get_mesh_count(Node *n) { return count; } -Error MDRImportPluginBase::process_node_single(Node *n, const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { +Error MDRImportPluginBase::process_node_single(Node *n, const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { #if MESH_UTILS_PRESENT MDRImportPluginBase::MDROptimizationType optimization_type = static_cast(static_cast(p_options["optimization_type"])); #endif @@ -208,7 +208,7 @@ Error MDRImportPluginBase::process_node_single(Node *n, const String &p_source_f save_mdr_copy_as_tres(p_source_file, mdr, mdrs.size() > 1, mi); } - ResourceSaver::save(p_save_path + "." + get_save_extension(), mdr); + ResourceSaver::save(mdr, p_save_path + "." + get_save_extension()); } return Error::OK; @@ -222,7 +222,7 @@ Error MDRImportPluginBase::process_node_single(Node *n, const String &p_source_f return Error::ERR_PARSE_ERROR; } -Error MDRImportPluginBase::process_node_single_separated_bones(Node *n, const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { +Error MDRImportPluginBase::process_node_single_separated_bones(Node *n, const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { #if MESH_UTILS_PRESENT MDRImportPluginBase::MDROptimizationType optimization_type = static_cast(static_cast(p_options["optimization_type"])); #endif @@ -239,7 +239,7 @@ Error MDRImportPluginBase::process_node_single_separated_bones(Node *n, const St if (Object::cast_to(c)) { Ref coll; - coll.instance(); + coll.instantiate(); MeshInstance *mesh_inst = Object::cast_to(c); @@ -275,7 +275,7 @@ Error MDRImportPluginBase::process_node_single_separated_bones(Node *n, const St node_name = node_name.to_lower(); String filename = p_source_file.get_basename() + "_" + node_name + "_" + String::num(j) + "." + get_save_extension(); - Error err = ResourceSaver::save(filename, mdr); + Error err = ResourceSaver::save(mdr, filename); ERR_CONTINUE(err != Error::OK); @@ -296,7 +296,7 @@ Error MDRImportPluginBase::process_node_single_separated_bones(Node *n, const St // save_mdrcoll_copy_as_tres(mdr_coll_name, coll); } - return ResourceSaver::save(p_save_path + "." + get_save_extension(), coll); + return ResourceSaver::save(coll, p_save_path + "." + get_save_extension()); } if (process_node_single_separated_bones(c, p_source_file, p_save_path, p_options, r_platform_variants, r_gen_files, r_metadata) == Error::OK) { @@ -307,7 +307,7 @@ Error MDRImportPluginBase::process_node_single_separated_bones(Node *n, const St return Error::ERR_PARSE_ERROR; } -Error MDRImportPluginBase::process_node_multi(Node *n, const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata, Ref coll, Ref copy_coll, int node_count) { +Error MDRImportPluginBase::process_node_multi(Node *n, const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata, Ref coll, Ref copy_coll, int node_count) { #if MESH_UTILS_PRESENT MDRImportPluginBase::MDROptimizationType optimization_type = static_cast(static_cast(p_options["optimization_type"])); #endif @@ -358,7 +358,7 @@ Error MDRImportPluginBase::process_node_multi(Node *n, const String &p_source_fi filename += ".tres"; - Error err = ResourceSaver::save(filename, mdr); + Error err = ResourceSaver::save(mdr, filename); Ref mdrtl = ResourceLoader::load(filename); copy_coll->add_mdr(mdrtl); @@ -378,7 +378,7 @@ Error MDRImportPluginBase::process_node_multi(Node *n, const String &p_source_fi filename += "." + get_save_extension(); - Error err = ResourceSaver::save(filename, mdr); + Error err = ResourceSaver::save(mdr, filename); Ref mdrl = ResourceLoader::load(filename); coll->add_mdr(mdrl); @@ -396,7 +396,7 @@ Error MDRImportPluginBase::process_node_multi(Node *n, const String &p_source_fi return Error::OK; } -Vector> MDRImportPluginBase::get_meshes(MeshInstance *mi, const Map &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale) { +Vector> MDRImportPluginBase::get_meshes(MeshInstance *mi, const HashMap &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale) { MDRImportPluginBase::MDRSurfaceHandlingType surface_handling = static_cast(static_cast(p_options["surface_handling"])); Vector> ret; @@ -406,7 +406,7 @@ Vector> MDRImportPluginBase::get_meshes(MeshInstance *mi, if (mesh.is_valid()) { if (surface_handling == MDR_SURFACE_HANDLING_TYPE_ONLY_USE_FIRST) { Ref mdr; - mdr.instance(); + mdr.instantiate(); Array arrays = mesh->surface_get_arrays(0); @@ -417,7 +417,7 @@ Vector> MDRImportPluginBase::get_meshes(MeshInstance *mi, ret.push_back(mdr); } else if (surface_handling == MDR_SURFACE_HANDLING_TYPE_MERGE) { Ref mdr; - mdr.instance(); + mdr.instantiate(); for (int i = 0; i < mesh->get_surface_count(); ++i) { Array arrays = mesh->surface_get_arrays(i); @@ -430,7 +430,7 @@ Vector> MDRImportPluginBase::get_meshes(MeshInstance *mi, } else if (surface_handling == MDR_SURFACE_HANDLING_TYPE_SEPARATE_MDRS) { for (int i = 0; i < mesh->get_surface_count(); ++i) { Ref mdr; - mdr.instance(); + mdr.instantiate(); Array arrays = mesh->surface_get_arrays(i); @@ -446,17 +446,17 @@ Vector> MDRImportPluginBase::get_meshes(MeshInstance *mi, return ret; } -Ref MDRImportPluginBase::get_mesh_arrays(Array &arrs, const Map &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale) { +Ref MDRImportPluginBase::get_mesh_arrays(Array &arrs, const HashMap &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale) { ERR_FAIL_COND_V(arrs.size() < VS::ARRAY_MAX, Ref()); Ref mesh; - mesh.instance(); + mesh.instantiate(); mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arrs); ERR_FAIL_COND_V(mesh->get_surface_count() == 0, Ref()); Ref mdr; - mdr.instance(); + mdr.instantiate(); Array arrays = mesh->surface_get_arrays(0); @@ -466,10 +466,10 @@ Ref MDRImportPluginBase::get_mesh_arrays(Array &arrs, const Ma return mdr; } -void MDRImportPluginBase::add_colliders(Ref mdr, Ref mesh, const Map &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale) { +void MDRImportPluginBase::add_colliders(Ref mdr, Ref mesh, const HashMap &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale) { if (collider_type == MeshDataResource::COLLIDER_TYPE_TRIMESH_COLLISION_SHAPE) { Ref m; - m.instance(); + m.instantiate(); m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array()); Ref shape = m->create_trimesh_shape(); @@ -479,7 +479,7 @@ void MDRImportPluginBase::add_colliders(Ref mdr, Ref m; - m.instance(); + m.instantiate(); m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array()); Ref shape = mesh->create_convex_shape(); @@ -490,10 +490,11 @@ void MDRImportPluginBase::add_colliders(Ref mdr, Ref m; - m.instance(); + m.instantiate(); m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array()); - Vector> shapes = mesh->convex_decompose(); + Mesh::ConvexDecompositionSettings settings; + Vector> shapes = mesh->convex_decompose(settings); for (int j = 0; j < shapes.size(); ++j) { scale_shape(shapes[j], scale); @@ -504,11 +505,11 @@ void MDRImportPluginBase::add_colliders(Ref mdr, Ref m; - m.instance(); + m.instantiate(); m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array()); Ref shape; - shape.instance(); + shape.instantiate(); AABB aabb = m->get_aabb(); Vector3 size = aabb.get_size(); @@ -528,11 +529,11 @@ void MDRImportPluginBase::add_colliders(Ref mdr, Refadd_collision_shape(t, shape); } else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_CAPSULE) { Ref m; - m.instance(); + m.instantiate(); m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array()); Ref shape; - shape.instance(); + shape.instantiate(); AABB aabb = m->get_aabb(); Vector3 size = aabb.get_size(); @@ -549,11 +550,11 @@ void MDRImportPluginBase::add_colliders(Ref mdr, Refadd_collision_shape(t, shape); } else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_CYLINDER) { Ref m; - m.instance(); + m.instantiate(); m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array()); Ref shape; - shape.instance(); + shape.instantiate(); AABB aabb = m->get_aabb(); Vector3 size = aabb.get_size(); @@ -570,11 +571,11 @@ void MDRImportPluginBase::add_colliders(Ref mdr, Refadd_collision_shape(t, shape); } else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_SPHERE) { Ref m; - m.instance(); + m.instantiate(); m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array()); Ref shape; - shape.instance(); + shape.instantiate(); AABB aabb = m->get_aabb(); Vector3 size = aabb.get_size(); @@ -756,14 +757,14 @@ Array MDRImportPluginBase::slice_mesh_bone(const Array &arr, int bone_idx) { return resarrs; } -Array MDRImportPluginBase::apply_transforms(Array &array, const Map &p_options) { +Array MDRImportPluginBase::apply_transforms(Array &array, const HashMap &p_options) { Vector3 offset = p_options["offset"]; Vector3 rotation = p_options["rotation"]; Vector3 scale = p_options["scale"]; ERR_FAIL_COND_V(array.size() < VS::ARRAY_MAX, array); - Transform transform = Transform(Basis(rotation).scaled(scale), offset); + Transform3D transform = Transform3D(Basis::from_euler(rotation).scaled(scale), offset); PoolVector3Array verts = array.get(Mesh::ARRAY_VERTEX); @@ -889,7 +890,7 @@ void MDRImportPluginBase::save_mdr_copy_as_tres(const String &p_source_file, con sp += ".tres"; - ResourceSaver::save(sp, res); + ResourceSaver::save(res, sp); } void MDRImportPluginBase::save_mdrcoll_copy_as_tres(const String &p_source_file, const Ref &res) { String sp = p_source_file; @@ -897,7 +898,7 @@ void MDRImportPluginBase::save_mdrcoll_copy_as_tres(const String &p_source_file, sp.resize(sp.size() - ext.size()); sp += ".tres"; - ResourceSaver::save(sp, res); + ResourceSaver::save(res, sp); } MDRImportPluginBase::MDRImportPluginBase() { diff --git a/plugin/mdr_import_plugin_base.h b/plugin/mdr_import_plugin_base.h index 8ea427e..975d005 100644 --- a/plugin/mdr_import_plugin_base.h +++ b/plugin/mdr_import_plugin_base.h @@ -36,14 +36,14 @@ SOFTWARE. #include "../mesh_data_resource_collection.h" #include "core/io/resource_saver.h" #include "core/math/basis.h" -#include "core/math/transform.h" +#include "core/math/transform_3d.h" #include "editor/import/editor_import_plugin.h" #include "scene/main/node.h" #include "scene/resources/mesh.h" #include "../mesh_data_resource.h" -#include "core/math/transform.h" +#include "core/math/transform_3d.h" #include "core/version.h" @@ -57,7 +57,7 @@ SOFTWARE. #endif #else -#include "../../gltf/editor_scene_importer_gltf.h" +#include "../../gltf/editor/editor_scene_importer_gltf.h" #include "scene/3d/mesh_instance_3d.h" #define MeshInstance MeshInstance3D @@ -93,22 +93,22 @@ public: }; public: - virtual void get_import_options(List *r_options, int p_preset = 0) const; - virtual bool get_option_visibility(const String &p_option, const Map &p_options) const; + virtual void get_import_options(const String &p_path, List *r_options, int p_preset) const override; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap &p_options) const override; - Error process_node(Node *n, const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files = NULL, Variant *r_metadata = NULL); + Error process_node(Node *n, const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files = NULL, Variant *r_metadata = NULL); int get_mesh_count(Node *n); - Error process_node_single(Node *n, const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata); - Error process_node_single_separated_bones(Node *n, const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata); - Error process_node_multi(Node *n, const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata, Ref coll, Ref copy_coll, int node_count = 0); - Vector> get_meshes(MeshInstance *mi, const Map &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale); - Ref get_mesh_arrays(Array &arrs, const Map &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale); - void add_colliders(Ref mdr, Ref mesh, const Map &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale); + Error process_node_single(Node *n, const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata); + Error process_node_single_separated_bones(Node *n, const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata); + Error process_node_multi(Node *n, const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata, Ref coll, Ref copy_coll, int node_count = 0); + Vector> get_meshes(MeshInstance *mi, const HashMap &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale); + Ref get_mesh_arrays(Array &arrs, const HashMap &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale); + void add_colliders(Ref mdr, Ref mesh, const HashMap &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale); Vector split_mesh_bones(Ref mesh); Array slice_mesh_bone(const Array &array, int bone_idx); - Array apply_transforms(Array &array, const Map &p_options); + Array apply_transforms(Array &array, const HashMap &p_options); Ref scale_shape(Ref shape, const Vector3 &scale); void save_mdr_copy_as_tres(const String &p_source_file, const Ref &res, bool indexed = false, int index = 0); diff --git a/plugin_collada/editor_import_collada_mdr.cpp b/plugin_collada/editor_import_collada_mdr.cpp index b495e91..99e9b2e 100644 --- a/plugin_collada/editor_import_collada_mdr.cpp +++ b/plugin_collada/editor_import_collada_mdr.cpp @@ -54,7 +54,7 @@ String EditorImportColladaMdr::get_preset_name(int p_idx) const { return ""; } -Error EditorImportColladaMdr::import(const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { +Error EditorImportColladaMdr::import(const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { //MeshDataResource::ColliderType collider_type = static_cast(static_cast(p_options["collider_type"])); Error erri; @@ -73,12 +73,12 @@ Error EditorImportColladaMdr::import(const String &p_source_file, const String & Error err = process_node(n, p_source_file, p_save_path, p_options, r_platform_variants, r_gen_files, r_metadata); - n->queue_delete(); + n->queue_free(); return err; } EditorImportColladaMdr::EditorImportColladaMdr() { - _importer.instance(); + _importer.instantiate(); } EditorImportColladaMdr::~EditorImportColladaMdr() { diff --git a/plugin_collada/editor_import_collada_mdr.h b/plugin_collada/editor_import_collada_mdr.h index 396926e..c02310b 100644 --- a/plugin_collada/editor_import_collada_mdr.h +++ b/plugin_collada/editor_import_collada_mdr.h @@ -29,15 +29,15 @@ SOFTWARE. #include "core/string/ustring.h" #include "core/variant/array.h" #else -#include "core/ustring.h" #include "core/array.h" +#include "core/ustring.h" #endif #include "../plugin/mdr_import_plugin_base.h" #include "core/io/resource_saver.h" #include "core/math/basis.h" -#include "core/math/transform.h" +#include "core/math/transform_3d.h" #include "editor/import/editor_import_plugin.h" #include "scene/main/node.h" #include "scene/resources/mesh.h" @@ -69,13 +69,13 @@ public: virtual int get_preset_count() const; virtual String get_preset_name(int p_idx) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata = nullptr) override; EditorImportColladaMdr(); ~EditorImportColladaMdr(); private: - Ref _importer; + Ref _importer; }; #endif diff --git a/plugin_collada/editor_plugin_collada_mdr.cpp b/plugin_collada/editor_plugin_collada_mdr.cpp index 6861d11..8be2c7c 100644 --- a/plugin_collada/editor_plugin_collada_mdr.cpp +++ b/plugin_collada/editor_plugin_collada_mdr.cpp @@ -25,7 +25,7 @@ SOFTWARE. void EditorPluginColladaMdr::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: - _importer.instance(); + _importer.instantiate(); add_import_plugin(_importer); @@ -39,6 +39,5 @@ void EditorPluginColladaMdr::_notification(int p_what) { } } -EditorPluginColladaMdr::EditorPluginColladaMdr(EditorNode *node) { - _node = node; +EditorPluginColladaMdr::EditorPluginColladaMdr() { } diff --git a/plugin_collada/editor_plugin_collada_mdr.h b/plugin_collada/editor_plugin_collada_mdr.h index f1a76ae..9d72183 100644 --- a/plugin_collada/editor_plugin_collada_mdr.h +++ b/plugin_collada/editor_plugin_collada_mdr.h @@ -40,13 +40,12 @@ class EditorPluginColladaMdr : public EditorPlugin { GDCLASS(EditorPluginColladaMdr, EditorPlugin); public: - EditorPluginColladaMdr(EditorNode *node); + EditorPluginColladaMdr(); protected: void _notification(int p_what); private: - EditorNode *_node; Ref _importer; }; diff --git a/plugin_gltf/editor_import_gltf_mdr.cpp b/plugin_gltf/editor_import_gltf_mdr.cpp index af7d836..30e7ad4 100644 --- a/plugin_gltf/editor_import_gltf_mdr.cpp +++ b/plugin_gltf/editor_import_gltf_mdr.cpp @@ -55,7 +55,7 @@ String EditorImportGLTFMdr::get_preset_name(int p_idx) const { return ""; } -Error EditorImportGLTFMdr::import(const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { +Error EditorImportGLTFMdr::import(const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { //MeshDataResource::ColliderType collider_type = static_cast(static_cast(p_options["collider_type"])); Error erri; @@ -79,7 +79,7 @@ Error EditorImportGLTFMdr::import(const String &p_source_file, const String &p_s } EditorImportGLTFMdr::EditorImportGLTFMdr() { - _importer.instance(); + _importer.instantiate(); } EditorImportGLTFMdr::~EditorImportGLTFMdr() { diff --git a/plugin_gltf/editor_import_gltf_mdr.h b/plugin_gltf/editor_import_gltf_mdr.h index aea8c11..bbaaf9f 100644 --- a/plugin_gltf/editor_import_gltf_mdr.h +++ b/plugin_gltf/editor_import_gltf_mdr.h @@ -29,21 +29,21 @@ SOFTWARE. #include "core/string/ustring.h" #include "core/variant/array.h" #else -#include "core/ustring.h" #include "core/array.h" +#include "core/ustring.h" #endif #include "../plugin/mdr_import_plugin_base.h" #include "core/io/resource_saver.h" #include "core/math/basis.h" -#include "core/math/transform.h" +#include "core/math/transform_3d.h" #include "scene/main/node.h" #include "scene/resources/mesh.h" #include "../mesh_data_resource.h" -#include "core/math/transform.h" +#include "core/math/transform_3d.h" #include "core/version.h" @@ -52,19 +52,18 @@ SOFTWARE. #if VERSION_MINOR < 4 #include "editor/import/editor_scene_importer_gltf.h" #else -#include "../../gltf/editor_scene_importer_gltf.h" +#include "../../gltf/editor/editor_scene_importer_gltf.h" #endif #include "scene/3d/mesh_instance.h" #else -#include "../../gltf/editor_scene_importer_gltf.h" +#include "../../gltf/editor/editor_scene_importer_gltf.h" #include "scene/3d/mesh_instance_3d.h" #define MeshInstance MeshInstance3D #endif class EditorImportGLTFMdr : public MDRImportPluginBase { - GDCLASS(EditorImportGLTFMdr, MDRImportPluginBase); public: @@ -78,13 +77,13 @@ public: virtual int get_preset_count() const; virtual String get_preset_name(int p_idx) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata = nullptr) override; EditorImportGLTFMdr(); ~EditorImportGLTFMdr(); private: - Ref _importer; + Ref _importer; }; #endif diff --git a/plugin_gltf/editor_plugin_gltf_mdr.cpp b/plugin_gltf/editor_plugin_gltf_mdr.cpp index 9f1467d..17be32a 100644 --- a/plugin_gltf/editor_plugin_gltf_mdr.cpp +++ b/plugin_gltf/editor_plugin_gltf_mdr.cpp @@ -25,7 +25,7 @@ SOFTWARE. void EditorPluginGLTFMdr::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: - _importer.instance(); + _importer.instantiate(); add_import_plugin(_importer); @@ -39,6 +39,5 @@ void EditorPluginGLTFMdr::_notification(int p_what) { } } -EditorPluginGLTFMdr::EditorPluginGLTFMdr(EditorNode *node) { - _node = node; +EditorPluginGLTFMdr::EditorPluginGLTFMdr() { } diff --git a/plugin_gltf/editor_plugin_gltf_mdr.h b/plugin_gltf/editor_plugin_gltf_mdr.h index 7a5c48d..5613ae9 100644 --- a/plugin_gltf/editor_plugin_gltf_mdr.h +++ b/plugin_gltf/editor_plugin_gltf_mdr.h @@ -40,13 +40,12 @@ class EditorPluginGLTFMdr : public EditorPlugin { GDCLASS(EditorPluginGLTFMdr, EditorPlugin); public: - EditorPluginGLTFMdr(EditorNode *node); + EditorPluginGLTFMdr(); protected: void _notification(int p_what); private: - EditorNode *_node; Ref _importer; }; diff --git a/props/prop_data_mesh_data.cpp b/props/prop_data_mesh_data.cpp index 137eb13..69933fe 100644 --- a/props/prop_data_mesh_data.cpp +++ b/props/prop_data_mesh_data.cpp @@ -75,7 +75,7 @@ void PropDataMeshData::_processor_process(Ref prop_data, Node *node, c ERR_FAIL_COND(!i); Ref m; - m.instance(); + m.instantiate(); m->set_mesh(i->get_mesh_data()); m->set_texture(i->get_texture()); m->set_transform(transform * i->get_transform()); @@ -86,7 +86,7 @@ Node *PropDataMeshData::_processor_get_node_for(const Transform &transform) { MeshDataInstance *i = memnew(MeshDataInstance); Ref m; - m.instance(); + m.instantiate(); i->set_material(m); i->set_texture(get_texture()); diff --git a/props_2d/prop_2d_data_mesh_data.cpp b/props_2d/prop_2d_data_mesh_data.cpp index 997df95..7b97c46 100644 --- a/props_2d/prop_2d_data_mesh_data.cpp +++ b/props_2d/prop_2d_data_mesh_data.cpp @@ -79,7 +79,7 @@ void Prop2DDataMeshData::_processor_process(Ref prop_data, Node *nod if (entry.is_valid()) { m = entry; } else { - m.instance(); + m.instantiate(); } m->set_mesh(i->get_mesh_data()); diff --git a/register_types.cpp b/register_types.cpp index fa47663..3ae4fc7 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -75,5 +75,5 @@ void initialize_mesh_data_resource_module(ModuleInitializationLevel p_level) { #endif } -void initialize_mesh_data_resource_module(ModuleInitializationLevel p_level) { +void uninitialize_mesh_data_resource_module(ModuleInitializationLevel p_level) { }