Work on fixing compile.

This commit is contained in:
Relintai 2023-01-09 01:17:26 +01:00
parent 1b9fb57a73
commit bedb86c987
17 changed files with 118 additions and 119 deletions

View File

@ -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<Vector2>::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);

View File

@ -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<MeshDataResource> MeshDataInstance::get_mesh_data() {
}
void MeshDataInstance::set_mesh_data(const Ref<MeshDataResource> &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<MeshDataResource> &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<Face3> MeshDataInstance::get_faces(uint32_t p_usage_flags) const {
PoolVector<Face3> faces;
Vector<Face3> MeshDataInstance::get_faces(uint32_t p_usage_flags) const {
Vector<Face3> faces;
if (_mesh.is_valid()) {
Array arrs = _mesh->get_array_const();
@ -92,15 +92,15 @@ PoolVector<Face3> MeshDataInstance::get_faces(uint32_t p_usage_flags) const {
return faces;
}
PoolVector<Vector3> vertices = arrs[Mesh::ARRAY_VERTEX];
PoolVector<int> indices = arrs[Mesh::ARRAY_INDEX];
Vector<Vector3> vertices = arrs[Mesh::ARRAY_VERTEX];
Vector<int> indices = arrs[Mesh::ARRAY_INDEX];
int ts = indices.size() / 3;
faces.resize(ts);
PoolVector<Face3>::Write w = faces.write();
PoolVector<Vector3>::Read rv = vertices.read();
PoolVector<int>::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<Face3> 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<Vector3> vertices = arr[Mesh::ARRAY_VERTEX];
Vector<Vector3> 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<Image> i = r->get_data();
Ref<ImageTexture> 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();
}
}

View File

@ -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<Material> &mat);
AABB get_aabb() const;
PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
Vector<Face3> get_faces(uint32_t p_usage_flags) const;
void refresh();
void setup_material_texture();

View File

@ -24,7 +24,7 @@ void MeshDataInstance2D::set_mesh_data(const Ref<MeshDataResource> &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<MeshDataResource> &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 = 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<Vector2> vertices = arr[Mesh::ARRAY_VERTEX];
Vector<Vector2> 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;
}

View File

@ -81,7 +81,7 @@ const String MDRImportPluginBase::BINDING_MDR_OPTIMIZATION_TYPE = "Off"
#endif
;
void MDRImportPluginBase::get_import_options(List<ImportOption> *r_options, int p_preset) const {
void MDRImportPluginBase::get_import_options(const String &p_path, List<ImportOption> *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<ImportOption> *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<StringName, Variant> &p_options) const {
bool MDRImportPluginBase::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
return true;
}
Error MDRImportPluginBase::process_node(Node *n, const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
Error MDRImportPluginBase::process_node(Node *n, const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
MDRImportPluginBase::MDRImportType type = static_cast<MDRImportPluginBase::MDRImportType>(static_cast<int>(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<bool>(p_options["save_copy_as_resource"]);
Ref<MeshDataResourceCollection> coll;
coll.instance();
coll.instantiate();
Ref<MeshDataResourceCollection> 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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
#if MESH_UTILS_PRESENT
MDRImportPluginBase::MDROptimizationType optimization_type = static_cast<MDRImportPluginBase::MDROptimizationType>(static_cast<int>(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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
#if MESH_UTILS_PRESENT
MDRImportPluginBase::MDROptimizationType optimization_type = static_cast<MDRImportPluginBase::MDROptimizationType>(static_cast<int>(p_options["optimization_type"]));
#endif
@ -239,7 +239,7 @@ Error MDRImportPluginBase::process_node_single_separated_bones(Node *n, const St
if (Object::cast_to<MeshInstance>(c)) {
Ref<MeshDataResourceCollection> coll;
coll.instance();
coll.instantiate();
MeshInstance *mesh_inst = Object::cast_to<MeshInstance>(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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata, Ref<MeshDataResourceCollection> coll, Ref<MeshDataResourceCollection> copy_coll, int node_count) {
Error MDRImportPluginBase::process_node_multi(Node *n, const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata, Ref<MeshDataResourceCollection> coll, Ref<MeshDataResourceCollection> copy_coll, int node_count) {
#if MESH_UTILS_PRESENT
MDRImportPluginBase::MDROptimizationType optimization_type = static_cast<MDRImportPluginBase::MDROptimizationType>(static_cast<int>(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<MeshDataResource> 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<MeshDataResource> 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<Ref<MeshDataResource>> MDRImportPluginBase::get_meshes(MeshInstance *mi, const Map<StringName, Variant> &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale) {
Vector<Ref<MeshDataResource>> MDRImportPluginBase::get_meshes(MeshInstance *mi, const HashMap<StringName, Variant> &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale) {
MDRImportPluginBase::MDRSurfaceHandlingType surface_handling = static_cast<MDRImportPluginBase::MDRSurfaceHandlingType>(static_cast<int>(p_options["surface_handling"]));
Vector<Ref<MeshDataResource>> ret;
@ -406,7 +406,7 @@ Vector<Ref<MeshDataResource>> MDRImportPluginBase::get_meshes(MeshInstance *mi,
if (mesh.is_valid()) {
if (surface_handling == MDR_SURFACE_HANDLING_TYPE_ONLY_USE_FIRST) {
Ref<MeshDataResource> mdr;
mdr.instance();
mdr.instantiate();
Array arrays = mesh->surface_get_arrays(0);
@ -417,7 +417,7 @@ Vector<Ref<MeshDataResource>> MDRImportPluginBase::get_meshes(MeshInstance *mi,
ret.push_back(mdr);
} else if (surface_handling == MDR_SURFACE_HANDLING_TYPE_MERGE) {
Ref<MeshDataResource> 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<Ref<MeshDataResource>> 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<MeshDataResource> mdr;
mdr.instance();
mdr.instantiate();
Array arrays = mesh->surface_get_arrays(i);
@ -446,17 +446,17 @@ Vector<Ref<MeshDataResource>> MDRImportPluginBase::get_meshes(MeshInstance *mi,
return ret;
}
Ref<MeshDataResource> MDRImportPluginBase::get_mesh_arrays(Array &arrs, const Map<StringName, Variant> &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale) {
Ref<MeshDataResource> MDRImportPluginBase::get_mesh_arrays(Array &arrs, const HashMap<StringName, Variant> &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale) {
ERR_FAIL_COND_V(arrs.size() < VS::ARRAY_MAX, Ref<MeshDataResource>());
Ref<ArrayMesh> mesh;
mesh.instance();
mesh.instantiate();
mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arrs);
ERR_FAIL_COND_V(mesh->get_surface_count() == 0, Ref<MeshDataResource>());
Ref<MeshDataResource> mdr;
mdr.instance();
mdr.instantiate();
Array arrays = mesh->surface_get_arrays(0);
@ -466,10 +466,10 @@ Ref<MeshDataResource> MDRImportPluginBase::get_mesh_arrays(Array &arrs, const Ma
return mdr;
}
void MDRImportPluginBase::add_colliders(Ref<MeshDataResource> mdr, Ref<ArrayMesh> mesh, const Map<StringName, Variant> &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale) {
void MDRImportPluginBase::add_colliders(Ref<MeshDataResource> mdr, Ref<ArrayMesh> mesh, const HashMap<StringName, Variant> &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale) {
if (collider_type == MeshDataResource::COLLIDER_TYPE_TRIMESH_COLLISION_SHAPE) {
Ref<ArrayMesh> m;
m.instance();
m.instantiate();
m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array());
Ref<Shape> shape = m->create_trimesh_shape();
@ -479,7 +479,7 @@ void MDRImportPluginBase::add_colliders(Ref<MeshDataResource> mdr, Ref<ArrayMesh
}
} else if (collider_type == MeshDataResource::COLLIDER_TYPE_SINGLE_CONVEX_COLLISION_SHAPE) {
Ref<ArrayMesh> m;
m.instance();
m.instantiate();
m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array());
Ref<Shape> shape = mesh->create_convex_shape();
@ -490,10 +490,11 @@ void MDRImportPluginBase::add_colliders(Ref<MeshDataResource> mdr, Ref<ArrayMesh
} else if (collider_type == MeshDataResource::COLLIDER_TYPE_MULTIPLE_CONVEX_COLLISION_SHAPES) {
Ref<ArrayMesh> m;
m.instance();
m.instantiate();
m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array());
Vector<Ref<Shape>> shapes = mesh->convex_decompose();
Mesh::ConvexDecompositionSettings settings;
Vector<Ref<Shape>> 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<MeshDataResource> mdr, Ref<ArrayMesh
}
} else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_BOX) {
Ref<ArrayMesh> m;
m.instance();
m.instantiate();
m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array());
Ref<BoxShape> shape;
shape.instance();
shape.instantiate();
AABB aabb = m->get_aabb();
Vector3 size = aabb.get_size();
@ -528,11 +529,11 @@ void MDRImportPluginBase::add_colliders(Ref<MeshDataResource> mdr, Ref<ArrayMesh
mdr->add_collision_shape(t, shape);
} else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_CAPSULE) {
Ref<ArrayMesh> m;
m.instance();
m.instantiate();
m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array());
Ref<CapsuleShape> shape;
shape.instance();
shape.instantiate();
AABB aabb = m->get_aabb();
Vector3 size = aabb.get_size();
@ -549,11 +550,11 @@ void MDRImportPluginBase::add_colliders(Ref<MeshDataResource> mdr, Ref<ArrayMesh
mdr->add_collision_shape(t, shape);
} else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_CYLINDER) {
Ref<ArrayMesh> m;
m.instance();
m.instantiate();
m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array());
Ref<CylinderShape> shape;
shape.instance();
shape.instantiate();
AABB aabb = m->get_aabb();
Vector3 size = aabb.get_size();
@ -570,11 +571,11 @@ void MDRImportPluginBase::add_colliders(Ref<MeshDataResource> mdr, Ref<ArrayMesh
mdr->add_collision_shape(t, shape);
} else if (collider_type == MeshDataResource::COLLIDER_TYPE_APPROXIMATED_SPHERE) {
Ref<ArrayMesh> m;
m.instance();
m.instantiate();
m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, mdr->get_array());
Ref<SphereShape> 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<StringName, Variant> &p_options) {
Array MDRImportPluginBase::apply_transforms(Array &array, const HashMap<StringName, Variant> &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<MeshDataResourceCollection> &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() {

View File

@ -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<ImportOption> *r_options, int p_preset = 0) const;
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const override;
virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const override;
Error process_node(Node *n, const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata);
Error process_node_multi(Node *n, const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata, Ref<MeshDataResourceCollection> coll, Ref<MeshDataResourceCollection> copy_coll, int node_count = 0);
Vector<Ref<MeshDataResource>> get_meshes(MeshInstance *mi, const Map<StringName, Variant> &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale);
Ref<MeshDataResource> get_mesh_arrays(Array &arrs, const Map<StringName, Variant> &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale);
void add_colliders(Ref<MeshDataResource> mdr, Ref<ArrayMesh> mesh, const Map<StringName, Variant> &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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata);
Error process_node_multi(Node *n, const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata, Ref<MeshDataResourceCollection> coll, Ref<MeshDataResourceCollection> copy_coll, int node_count = 0);
Vector<Ref<MeshDataResource>> get_meshes(MeshInstance *mi, const HashMap<StringName, Variant> &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale);
Ref<MeshDataResource> get_mesh_arrays(Array &arrs, const HashMap<StringName, Variant> &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale);
void add_colliders(Ref<MeshDataResource> mdr, Ref<ArrayMesh> mesh, const HashMap<StringName, Variant> &p_options, MeshDataResource::ColliderType collider_type, Vector3 scale);
Vector<Array> split_mesh_bones(Ref<ArrayMesh> mesh);
Array slice_mesh_bone(const Array &array, int bone_idx);
Array apply_transforms(Array &array, const Map<StringName, Variant> &p_options);
Array apply_transforms(Array &array, const HashMap<StringName, Variant> &p_options);
Ref<Shape> scale_shape(Ref<Shape> shape, const Vector3 &scale);
void save_mdr_copy_as_tres(const String &p_source_file, const Ref<MeshDataResource> &res, bool indexed = false, int index = 0);

View File

@ -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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
Error EditorImportColladaMdr::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
//MeshDataResource::ColliderType collider_type = static_cast<MeshDataResource::ColliderType>(static_cast<int>(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() {

View File

@ -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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL);
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr) override;
EditorImportColladaMdr();
~EditorImportColladaMdr();
private:
Ref<EditorSceneImporterCollada> _importer;
Ref<EditorSceneFormatImporterCollada> _importer;
};
#endif

View File

@ -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() {
}

View File

@ -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<EditorImportColladaMdr> _importer;
};

View File

@ -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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
Error EditorImportGLTFMdr::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
//MeshDataResource::ColliderType collider_type = static_cast<MeshDataResource::ColliderType>(static_cast<int>(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() {

View File

@ -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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL);
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr) override;
EditorImportGLTFMdr();
~EditorImportGLTFMdr();
private:
Ref<EditorSceneImporterGLTF> _importer;
Ref<EditorSceneFormatImporterGLTF> _importer;
};
#endif

View File

@ -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() {
}

View File

@ -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<EditorImportGLTFMdr> _importer;
};

View File

@ -75,7 +75,7 @@ void PropDataMeshData::_processor_process(Ref<PropData> prop_data, Node *node, c
ERR_FAIL_COND(!i);
Ref<PropDataMeshData> 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<SpatialMaterial> m;
m.instance();
m.instantiate();
i->set_material(m);
i->set_texture(get_texture());

View File

@ -79,7 +79,7 @@ void Prop2DDataMeshData::_processor_process(Ref<Prop2DData> prop_data, Node *nod
if (entry.is_valid()) {
m = entry;
} else {
m.instance();
m.instantiate();
}
m->set_mesh(i->get_mesh_data());

View File

@ -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) {
}