diff --git a/SCsub b/SCsub index 6b56edc..51e2202 100644 --- a/SCsub +++ b/SCsub @@ -4,6 +4,8 @@ Import('env') module_env = env.Clone() +import version + if os.path.isdir('../mesh_data_resource'): module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) @@ -37,7 +39,6 @@ sources = [ "props/prop_data_scene.cpp", "props/prop_data_light.cpp", "props/prop_data_prop.cpp", - "props/prop_data_portal.cpp", "props/prop_data_tiled_wall.cpp", "clutter/ground_clutter.cpp", @@ -65,6 +66,9 @@ sources = [ "material_cache/prop_material_cache.cpp" ] +if version.minor >= 4: + sources.append("props/prop_data_portal.cpp") + if has_texture_packer: sources.append("material_cache/prop_material_cache_pcm.cpp") diff --git a/editor/prop_editor_plugin.cpp b/editor/prop_editor_plugin.cpp index ec66ab3..1b3b478 100644 --- a/editor/prop_editor_plugin.cpp +++ b/editor/prop_editor_plugin.cpp @@ -82,6 +82,7 @@ void PropEditorPlugin::convert_scene(Node *root, const String &path) { } void PropEditorPlugin::find_room_points(Variant param) { +#if VERSION_MINOR >= 4 SceneTree *st = SceneTree::get_singleton(); if (st) { @@ -91,6 +92,7 @@ void PropEditorPlugin::find_room_points(Variant param) { PropUtils::get_singleton()->generate_room_points_node(scene); } } +#endif } void PropEditorPlugin::_quick_convert_button_pressed() { @@ -110,7 +112,9 @@ PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) { #if VERSION_MAJOR < 4 editor->add_tool_menu_item("Convert active scene to PropData", this, "convert_active_scene_to_prop_data"); editor->add_tool_menu_item("Convert selected scene(s) to PropData", this, "convert_selected_scene_to_prop_data"); +#if VERSION_MINOR >= 4 editor->add_tool_menu_item("(Prop) Find room points.", this, "find_room_points"); +#endif #else #endif diff --git a/register_types.cpp b/register_types.cpp index 22bff98..234b90c 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -36,11 +36,14 @@ SOFTWARE. #include "props/prop_data.h" #include "props/prop_data_entry.h" #include "props/prop_data_light.h" -#include "props/prop_data_portal.h" #include "props/prop_data_prop.h" #include "props/prop_data_scene.h" #include "props/prop_data_tiled_wall.h" +#if VERSION_MINOR >= 4 +#include "props/prop_data_portal.h" +#endif + #include "clutter/ground_clutter.h" #include "clutter/ground_clutter_foliage.h" @@ -85,9 +88,12 @@ void register_props_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); +#if VERSION_MINOR >= 4 + ClassDB::register_class(); +#endif + ClassDB::register_class(); ClassDB::register_class(); @@ -129,8 +135,10 @@ void register_props_types() { Ref scene_processor = Ref(memnew(PropDataScene)); PropUtils::add_processor(scene_processor); +#if VERSION_MINOR >= 4 Ref portal_processor = Ref(memnew(PropDataPortal)); PropUtils::add_processor(portal_processor); +#endif Ref tiled_wall_processor = Ref(memnew(PropDataTiledWall)); PropUtils::add_processor(tiled_wall_processor); diff --git a/singleton/prop_utils.cpp b/singleton/prop_utils.cpp index 7a69f95..dffa3bc 100644 --- a/singleton/prop_utils.cpp +++ b/singleton/prop_utils.cpp @@ -25,15 +25,16 @@ SOFTWARE. #include "../props/prop_data.h" #include "../props/prop_data_entry.h" -#include "scene/3d/room.h" - #include "core/version.h" + +#if VERSION_MINOR >= 4 +#include "core/math/quick_hull.h" +#include "scene/3d/portal.h" #include "scene/3d/room.h" #include "scene/3d/room_manager.h" +#endif -#include "core/math/quick_hull.h" #include "scene/3d/mesh_instance.h" -#include "scene/3d/portal.h" #if MESH_DATA_RESOURCE_PRESENT #include "../../mesh_data_resource/nodes/mesh_data_instance.h" @@ -46,7 +47,7 @@ SOFTWARE. #endif PropUtils *PropUtils::_instance; -Vector> PropUtils::_processors; +Vector > PropUtils::_processors; PropUtils *PropUtils::get_singleton() { return _instance; @@ -106,6 +107,7 @@ void PropUtils::_convert_tree(Ref prop_data, Node *node, const Transfo } } } else { +#if VERSION_MINOR >= 4 //only handle the first encountered room per prop if (!prop_data->get_is_room()) { Room *r = Object::cast_to(sp); @@ -118,6 +120,7 @@ void PropUtils::_convert_tree(Ref prop_data, Node *node, const Transfo prop_data->set_room_bounds(points); } } +#endif for (int i = 0; i < node->get_child_count(); ++i) { Node *child = node->get_child(i); @@ -134,6 +137,7 @@ void PropUtils::_convert_tree(Ref prop_data, Node *node, const Transfo } } +#if VERSION_MINOR >= 4 bool PropUtils::generate_room_points_node(Node *node) { ERR_FAIL_COND_V(!ObjectDB::instance_validate(node), false); @@ -157,7 +161,7 @@ bool PropUtils::generate_room_points_node(Node *node) { void PropUtils::generate_room_points(Room *room) { ERR_FAIL_COND(!ObjectDB::instance_validate(room)); - Vector> mesh_arrays; + Vector > mesh_arrays; get_mesh_arrays(room, &mesh_arrays); @@ -302,7 +306,7 @@ bool PropUtils::is_plane_unique(const PoolVector &planes, const Plane &p) return true; } -void PropUtils::get_mesh_arrays(Node *node, Vector> *arrs) { +void PropUtils::get_mesh_arrays(Node *node, Vector > *arrs) { ERR_FAIL_COND(!ObjectDB::instance_validate(node)); for (int i = 0; i < node->get_child_count(); ++i) { @@ -456,6 +460,8 @@ void PropUtils::get_mesh_arrays(Node *node, Vector> *arrs) { } } +#endif + int PropUtils::add_processor(const Ref &processor) { ERR_FAIL_COND_V(!processor.is_valid(), 0); diff --git a/singleton/prop_utils.h b/singleton/prop_utils.h index f86b442..6fb147f 100644 --- a/singleton/prop_utils.h +++ b/singleton/prop_utils.h @@ -41,7 +41,10 @@ SOFTWARE. class PropData; class PropDataEntry; + +#if VERSION_MINOR >= 4 class Room; +#endif class PropUtils : public Object { GDCLASS(PropUtils, Object); @@ -52,11 +55,12 @@ public: Ref convert_tree(Node *root); void _convert_tree(Ref prop_data, Node *node, const Transform &transform); +#if VERSION_MINOR >= 4 bool generate_room_points_node(Node *node); void generate_room_points(Room *room); void get_mesh_arrays(Node *node, Vector> *arrs); bool is_plane_unique(const PoolVector &planes, const Plane &p); - +#endif static int add_processor(const Ref &processor); static Ref get_processor(const int index); diff --git a/tiled_wall/tiled_wall.cpp b/tiled_wall/tiled_wall.cpp index 294e021..b1488ee 100644 --- a/tiled_wall/tiled_wall.cpp +++ b/tiled_wall/tiled_wall.cpp @@ -2,7 +2,6 @@ #include "core/version.h" -#include "core/version.h" #include "scene/resources/texture.h" #if VERSION_MAJOR < 4 @@ -290,8 +289,10 @@ TiledWall::TiledWall() { _physics_body_rid = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC); +#if VERSION_MINOR >= 4 //temporary set_portal_mode(PORTAL_MODE_GLOBAL); +#endif _mesher.instance(); }