diff --git a/editor/prop_editor_plugin.cpp b/editor/prop_editor_plugin.cpp index ff95a23..22d7da6 100644 --- a/editor/prop_editor_plugin.cpp +++ b/editor/prop_editor_plugin.cpp @@ -24,9 +24,23 @@ SOFTWARE. #include "../props/prop_data.h" #include "../singleton/prop_utils.h" -#include "core/os/input.h" #include "core/os/keyboard.h" +#include "core/version.h" + +#if VERSION_MAJOR < 4 +#include "core/os/input.h" + +#define CONNECT(sig, obj, target_method_class, method) connect(sig, obj, #method) +#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, obj, #method) + +#else +#include "core/input/input.h" + +#define CONNECT(sig, obj, target_method_class, method) connect(sig, callable_mp(obj, &target_method_class::method)) +#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, callable_mp(obj, &target_method_class::method)) +#endif + void PropEditorPlugin::convert_active_scene_to_prop_data() { SceneTree *st = SceneTree::get_singleton(); @@ -74,7 +88,6 @@ void PropEditorPlugin::_convert_selected_scene_to_prop_data(Variant param) { } PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) { - editor = p_node; editor->add_tool_menu_item("Convert active scene to PropData", this, "convert_active_scene_to_prop_data"); @@ -88,7 +101,7 @@ PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) { container->add_child(b); b->set_flat(true); - b->connect("pressed", this, "_quick_convert_button_pressed"); + b->CONNECT("pressed", this, PropEditorPlugin, _quick_convert_button_pressed); b->set_text("To Prop"); b->set_shortcut(ED_SHORTCUT("spatial_editor/quick_prop_convert", "Quick convert scene to PropData.", KEY_MASK_ALT + KEY_U)); diff --git a/prop_instance.cpp b/prop_instance.cpp index 6e3351e..57c82e4 100644 --- a/prop_instance.cpp +++ b/prop_instance.cpp @@ -40,7 +40,7 @@ void PropInstance::set_snap_axis(const Vector3 &value) { } void PropInstance::register_prop_mesh_data_instance(MeshDataInstance *instance) { - ERR_FAIL_COND(!ObjectDB::instance_validate(instance)); + //ERR_FAIL_COND(!ObjectDB::instance_validate(instance)); _mesh_data_instances.push_back(instance); @@ -49,7 +49,7 @@ void PropInstance::register_prop_mesh_data_instance(MeshDataInstance *instance) } void PropInstance::unregister_prop_mesh_data_instance(MeshDataInstance *instance) { - ERR_FAIL_COND(!ObjectDB::instance_validate(instance)); + //ERR_FAIL_COND(!ObjectDB::instance_validate(instance)); _mesh_data_instances.erase(instance); @@ -66,7 +66,7 @@ void PropInstance::bake() { for (int i = 0; i < _mesh_data_instances.size(); ++i) { MeshDataInstance *md = _mesh_data_instances.get(i); - ERR_CONTINUE(!ObjectDB::instance_validate(md)); + //ERR_CONTINUE(!ObjectDB::instance_validate(md)); Ref mdr = md->get_mesh(); @@ -149,7 +149,7 @@ PropInstance::PropInstance() { _snap_to_mesh = false; _snap_axis = Vector3(0, -1, 0); _job.instance(); - _job->connect("completed", this, "bake_finished", Vector(), Object::CONNECT_DEFERRED); + //_job->connect("completed", this, "bake_finished", Vector(), Object::CONNECT_DEFERRED); } PropInstance::~PropInstance() { _mesh_data_instances.clear(); diff --git a/props/prop_data.cpp b/props/prop_data.cpp index 6ae4c8b..83edcdc 100644 --- a/props/prop_data.cpp +++ b/props/prop_data.cpp @@ -26,6 +26,14 @@ SOFTWARE. #include "prop_data_light.h" #include "prop_data_prop.h" +#if VERSION_MAJOR < 4 +#include "servers/physics_server.h" +#else +#include "servers/physics_server_3d.h" + +#define Shape Shape3D +#endif + int PropData::get_id() const { return _id; } @@ -73,7 +81,11 @@ int PropData::get_prop_count() const { Vector PropData::get_props() { Vector r; for (int i = 0; i < _props.size(); i++) { +#if VERSION_MAJOR < 4 r.push_back(_props[i].get_ref_ptr()); +#else + r.push_back(_props[i]); +#endif } return r; } diff --git a/props/prop_data.h b/props/prop_data.h index 307e819..799ea3f 100644 --- a/props/prop_data.h +++ b/props/prop_data.h @@ -30,7 +30,7 @@ SOFTWARE. #include "core/reference.h" #include "core/vector.h" -#include "servers/physics_server.h" +#include "core/version.h" #include "prop_data_entry.h" @@ -78,7 +78,7 @@ private: bool _snap_to_mesh; Vector3 _snap_axis; - Vector > _props; + Vector> _props; }; #endif diff --git a/props/prop_data_entry.cpp b/props/prop_data_entry.cpp index d1b930f..7f8c0af 100644 --- a/props/prop_data_entry.cpp +++ b/props/prop_data_entry.cpp @@ -23,7 +23,15 @@ SOFTWARE. #include "prop_data_entry.h" #include "prop_data.h" + +#include "core/version.h" + +#if VERSION_MAJOR < 4 #include "scene/3d/spatial.h" +#else +#include "scene/3d/node_3d.h" +#define Spatial Node3D +#endif Transform PropDataEntry::get_transform() const { return _transform; diff --git a/props/prop_data_light.cpp b/props/prop_data_light.cpp index 4b963a2..e946956 100644 --- a/props/prop_data_light.cpp +++ b/props/prop_data_light.cpp @@ -23,7 +23,14 @@ SOFTWARE. #include "prop_data_light.h" #include "prop_data.h" + +#if VERSION_MAJOR < 4 #include "scene/3d/light.h" +#else +#include "scene/3d/light_3d.h" +#define OmniLight OmniLight3D +#define Light Light3D +#endif Color PropDataLight::get_light_color() const { return _light_color; diff --git a/singleton/prop_utils.cpp b/singleton/prop_utils.cpp index 4fea3cf..b4f19f7 100644 --- a/singleton/prop_utils.cpp +++ b/singleton/prop_utils.cpp @@ -26,15 +26,19 @@ SOFTWARE. #include "../props/prop_data_entry.h" #include "core/engine.h" +#include "core/version.h" + PropUtils *PropUtils::_instance; -Vector > PropUtils::_processors; +Vector> PropUtils::_processors; PropUtils *PropUtils::get_singleton() { return _instance; } Ref PropUtils::convert_tree(Node *root) { +#if VERSION_MAJOR < 4 ERR_FAIL_COND_V(!ObjectDB::instance_validate(root), Ref()); +#endif Ref data; data.instance(); @@ -46,7 +50,9 @@ Ref PropUtils::convert_tree(Node *root) { } void PropUtils::_convert_tree(Ref prop_data, Node *node, const Transform &transform) { +#if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(node)); +#endif for (int i = 0; i < PropUtils::_processors.size(); ++i) { Ref proc = PropUtils::_processors.get(i); @@ -84,7 +90,6 @@ void PropUtils::_convert_tree(Ref prop_data, Node *node, const Transfo } } else { for (int i = 0; i < node->get_child_count(); ++i) { - Node *child = node->get_child(i); if (Engine::get_singleton()->is_editor_hint()) {