Fix compile for 4.0.

This commit is contained in:
Relintai 2020-07-29 00:03:05 +02:00
parent 969f3796d6
commit 0ed644e4a4
7 changed files with 56 additions and 11 deletions

View File

@ -24,9 +24,23 @@ SOFTWARE.
#include "../props/prop_data.h" #include "../props/prop_data.h"
#include "../singleton/prop_utils.h" #include "../singleton/prop_utils.h"
#include "core/os/input.h"
#include "core/os/keyboard.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() { void PropEditorPlugin::convert_active_scene_to_prop_data() {
SceneTree *st = SceneTree::get_singleton(); SceneTree *st = SceneTree::get_singleton();
@ -74,7 +88,6 @@ void PropEditorPlugin::_convert_selected_scene_to_prop_data(Variant param) {
} }
PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) { PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) {
editor = p_node; editor = p_node;
editor->add_tool_menu_item("Convert active scene to PropData", this, "convert_active_scene_to_prop_data"); 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); container->add_child(b);
b->set_flat(true); 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_text("To Prop");
b->set_shortcut(ED_SHORTCUT("spatial_editor/quick_prop_convert", "Quick convert scene to PropData.", KEY_MASK_ALT + KEY_U)); b->set_shortcut(ED_SHORTCUT("spatial_editor/quick_prop_convert", "Quick convert scene to PropData.", KEY_MASK_ALT + KEY_U));

View File

@ -40,7 +40,7 @@ void PropInstance::set_snap_axis(const Vector3 &value) {
} }
void PropInstance::register_prop_mesh_data_instance(MeshDataInstance *instance) { 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); _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) { 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); _mesh_data_instances.erase(instance);
@ -66,7 +66,7 @@ void PropInstance::bake() {
for (int i = 0; i < _mesh_data_instances.size(); ++i) { for (int i = 0; i < _mesh_data_instances.size(); ++i) {
MeshDataInstance *md = _mesh_data_instances.get(i); MeshDataInstance *md = _mesh_data_instances.get(i);
ERR_CONTINUE(!ObjectDB::instance_validate(md)); //ERR_CONTINUE(!ObjectDB::instance_validate(md));
Ref<MeshDataResource> mdr = md->get_mesh(); Ref<MeshDataResource> mdr = md->get_mesh();
@ -149,7 +149,7 @@ PropInstance::PropInstance() {
_snap_to_mesh = false; _snap_to_mesh = false;
_snap_axis = Vector3(0, -1, 0); _snap_axis = Vector3(0, -1, 0);
_job.instance(); _job.instance();
_job->connect("completed", this, "bake_finished", Vector<Variant>(), Object::CONNECT_DEFERRED); //_job->connect("completed", this, "bake_finished", Vector<Variant>(), Object::CONNECT_DEFERRED);
} }
PropInstance::~PropInstance() { PropInstance::~PropInstance() {
_mesh_data_instances.clear(); _mesh_data_instances.clear();

View File

@ -26,6 +26,14 @@ SOFTWARE.
#include "prop_data_light.h" #include "prop_data_light.h"
#include "prop_data_prop.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 { int PropData::get_id() const {
return _id; return _id;
} }
@ -73,7 +81,11 @@ int PropData::get_prop_count() const {
Vector<Variant> PropData::get_props() { Vector<Variant> PropData::get_props() {
Vector<Variant> r; Vector<Variant> r;
for (int i = 0; i < _props.size(); i++) { for (int i = 0; i < _props.size(); i++) {
#if VERSION_MAJOR < 4
r.push_back(_props[i].get_ref_ptr()); r.push_back(_props[i].get_ref_ptr());
#else
r.push_back(_props[i]);
#endif
} }
return r; return r;
} }

View File

@ -30,7 +30,7 @@ SOFTWARE.
#include "core/reference.h" #include "core/reference.h"
#include "core/vector.h" #include "core/vector.h"
#include "servers/physics_server.h" #include "core/version.h"
#include "prop_data_entry.h" #include "prop_data_entry.h"
@ -78,7 +78,7 @@ private:
bool _snap_to_mesh; bool _snap_to_mesh;
Vector3 _snap_axis; Vector3 _snap_axis;
Vector<Ref<PropDataEntry> > _props; Vector<Ref<PropDataEntry>> _props;
}; };
#endif #endif

View File

@ -23,7 +23,15 @@ SOFTWARE.
#include "prop_data_entry.h" #include "prop_data_entry.h"
#include "prop_data.h" #include "prop_data.h"
#include "core/version.h"
#if VERSION_MAJOR < 4
#include "scene/3d/spatial.h" #include "scene/3d/spatial.h"
#else
#include "scene/3d/node_3d.h"
#define Spatial Node3D
#endif
Transform PropDataEntry::get_transform() const { Transform PropDataEntry::get_transform() const {
return _transform; return _transform;

View File

@ -23,7 +23,14 @@ SOFTWARE.
#include "prop_data_light.h" #include "prop_data_light.h"
#include "prop_data.h" #include "prop_data.h"
#if VERSION_MAJOR < 4
#include "scene/3d/light.h" #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 { Color PropDataLight::get_light_color() const {
return _light_color; return _light_color;

View File

@ -26,15 +26,19 @@ SOFTWARE.
#include "../props/prop_data_entry.h" #include "../props/prop_data_entry.h"
#include "core/engine.h" #include "core/engine.h"
#include "core/version.h"
PropUtils *PropUtils::_instance; PropUtils *PropUtils::_instance;
Vector<Ref<PropDataEntry> > PropUtils::_processors; Vector<Ref<PropDataEntry>> PropUtils::_processors;
PropUtils *PropUtils::get_singleton() { PropUtils *PropUtils::get_singleton() {
return _instance; return _instance;
} }
Ref<PropData> PropUtils::convert_tree(Node *root) { Ref<PropData> PropUtils::convert_tree(Node *root) {
#if VERSION_MAJOR < 4
ERR_FAIL_COND_V(!ObjectDB::instance_validate(root), Ref<PropData>()); ERR_FAIL_COND_V(!ObjectDB::instance_validate(root), Ref<PropData>());
#endif
Ref<PropData> data; Ref<PropData> data;
data.instance(); data.instance();
@ -46,7 +50,9 @@ Ref<PropData> PropUtils::convert_tree(Node *root) {
} }
void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transform &transform) { void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transform &transform) {
#if VERSION_MAJOR < 4
ERR_FAIL_COND(!ObjectDB::instance_validate(node)); ERR_FAIL_COND(!ObjectDB::instance_validate(node));
#endif
for (int i = 0; i < PropUtils::_processors.size(); ++i) { for (int i = 0; i < PropUtils::_processors.size(); ++i) {
Ref<PropDataEntry> proc = PropUtils::_processors.get(i); Ref<PropDataEntry> proc = PropUtils::_processors.get(i);
@ -84,7 +90,6 @@ void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transfo
} }
} else { } else {
for (int i = 0; i < node->get_child_count(); ++i) { for (int i = 0; i < node->get_child_count(); ++i) {
Node *child = node->get_child(i); Node *child = node->get_child(i);
if (Engine::get_singleton()->is_editor_hint()) { if (Engine::get_singleton()->is_editor_hint()) {