diff options
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/scene_tree.cpp | 14 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 110 | ||||
-rw-r--r-- | scene/main/viewport.h | 16 |
3 files changed, 70 insertions, 70 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 22cd1c98ab..7afc1b2edd 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -504,7 +504,7 @@ bool SceneTree::idle(float p_time) { String env_path = ProjectSettings::get_singleton()->get("rendering/environment/default_environment"); env_path = env_path.strip_edges(); //user may have added a space or two String cpath; - Ref<Environment> fallback = get_root()->get_world()->get_fallback_environment(); + Ref<Environment> fallback = get_root()->get_world_3d()->get_fallback_environment(); if (fallback.is_valid()) { cpath = fallback->get_path(); } @@ -519,7 +519,7 @@ bool SceneTree::idle(float p_time) { } else { fallback.unref(); } - get_root()->get_world()->set_fallback_environment(fallback); + get_root()->get_world_3d()->set_fallback_environment(fallback); } } @@ -1409,8 +1409,8 @@ SceneTree::SceneTree() { root = memnew(Window); root->set_name("root"); - if (!root->get_world().is_valid()) - root->set_world(Ref<World3D>(memnew(World3D))); + if (!root->get_world_3d().is_valid()) + root->set_world_3d(Ref<World3D>(memnew(World3D))); // Initialize network state multiplayer_poll = true; @@ -1422,11 +1422,11 @@ SceneTree::SceneTree() { current_scene = nullptr; int msaa_mode = GLOBAL_DEF("rendering/quality/screen_filters/msaa", 0); - ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/screen_filters/msaa", PropertyInfo(Variant::INT, "rendering/quality/screen_filters/msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/screen_filters/msaa", PropertyInfo(Variant::INT, "rendering/quality/screen_filters/msaa", PROPERTY_HINT_ENUM, "Disabled (Fastest),2x (Fast),4x (Average),8x (Slow),16x (Slower)")); root->set_msaa(Viewport::MSAA(msaa_mode)); int ssaa_mode = GLOBAL_DEF("rendering/quality/screen_filters/screen_space_aa", 0); - ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/screen_filters/screen_space_aa", PropertyInfo(Variant::INT, "rendering/quality/screen_filters/screen_space_aa", PROPERTY_HINT_ENUM, "Disabled,FXAA")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/screen_filters/screen_space_aa", PropertyInfo(Variant::INT, "rendering/quality/screen_filters/screen_space_aa", PROPERTY_HINT_ENUM, "Disabled (Fastest),FXAA (Fast)")); root->set_screen_space_aa(Viewport::ScreenSpaceAA(ssaa_mode)); { //load default fallback environment @@ -1447,7 +1447,7 @@ SceneTree::SceneTree() { if (env_path != String()) { Ref<Environment> env = ResourceLoader::load(env_path); if (env.is_valid()) { - root->get_world()->set_fallback_environment(env); + root->get_world_3d()->set_fallback_environment(env); } else { if (Engine::get_singleton()->is_editor_hint()) { //file was erased, clear the field. diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index b0718eed79..e9827d521b 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -215,7 +215,7 @@ void Viewport::update_worlds() { find_world_2d()->_update_viewport(this, xformed_rect); find_world_2d()->_update(); - find_world()->_update(get_tree()->get_frame()); + find_world_3d()->_update(get_tree()->get_frame()); } void Viewport::_collision_object_input_event(CollisionObject3D *p_object, Camera3D *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape) { @@ -422,22 +422,22 @@ void Viewport::_sub_window_remove(Window *p_window) { RenderingServer::get_singleton()->viewport_set_parent_viewport(p_window->viewport, p_window->parent ? p_window->parent->viewport : RID()); } -void Viewport::_own_world_changed() { - ERR_FAIL_COND(world.is_null()); - ERR_FAIL_COND(own_world.is_null()); +void Viewport::_own_world_3d_changed() { + ERR_FAIL_COND(world_3d.is_null()); + ERR_FAIL_COND(own_world_3d.is_null()); if (is_inside_tree()) { _propagate_exit_world(this); } - own_world = world->duplicate(); + own_world_3d = world_3d->duplicate(); if (is_inside_tree()) { _propagate_enter_world(this); } if (is_inside_tree()) { - RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario()); + RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world_3d()->get_scenario()); } _update_listener(); @@ -459,7 +459,7 @@ void Viewport::_notification(int p_what) { } current_canvas = find_world_2d()->get_canvas(); - RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario()); + RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world_3d()->get_scenario()); RenderingServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas); _update_listener(); @@ -474,14 +474,14 @@ void Viewport::_notification(int p_what) { contact_2d_debug = RenderingServer::get_singleton()->canvas_item_create(); RenderingServer::get_singleton()->canvas_item_set_parent(contact_2d_debug, find_world_2d()->get_canvas()); //3D - PhysicsServer3D::get_singleton()->space_set_debug_contacts(find_world()->get_space(), get_tree()->get_collision_debug_contact_count()); + PhysicsServer3D::get_singleton()->space_set_debug_contacts(find_world_3d()->get_space(), get_tree()->get_collision_debug_contact_count()); contact_3d_debug_multimesh = RenderingServer::get_singleton()->multimesh_create(); RenderingServer::get_singleton()->multimesh_allocate(contact_3d_debug_multimesh, get_tree()->get_collision_debug_contact_count(), RS::MULTIMESH_TRANSFORM_3D, true); RenderingServer::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, 0); RenderingServer::get_singleton()->multimesh_set_mesh(contact_3d_debug_multimesh, get_tree()->get_debug_contact_mesh()->get_rid()); contact_3d_debug_instance = RenderingServer::get_singleton()->instance_create(); RenderingServer::get_singleton()->instance_set_base(contact_3d_debug_instance, contact_3d_debug_multimesh); - RenderingServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world()->get_scenario()); + RenderingServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world_3d()->get_scenario()); //RenderingServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, RS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true); } @@ -576,8 +576,8 @@ void Viewport::_notification(int p_what) { if (get_tree()->is_debugging_collisions_hint() && contact_3d_debug_multimesh.is_valid()) { - Vector<Vector3> points = PhysicsServer3D::get_singleton()->space_get_contacts(find_world()->get_space()); - int point_count = PhysicsServer3D::get_singleton()->space_get_contact_count(find_world()->get_space()); + Vector<Vector3> points = PhysicsServer3D::get_singleton()->space_get_contacts(find_world_3d()->get_space()); + int point_count = PhysicsServer3D::get_singleton()->space_get_contact_count(find_world_3d()->get_space()); RS::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, point_count); } @@ -805,7 +805,7 @@ void Viewport::_notification(int p_what) { Vector3 from = camera->project_ray_origin(pos); Vector3 dir = camera->project_ray_normal(pos); - PhysicsDirectSpaceState3D *space = PhysicsServer3D::get_singleton()->space_get_direct_state(find_world()->get_space()); + PhysicsDirectSpaceState3D *space = PhysicsServer3D::get_singleton()->space_get_direct_state(find_world_3d()->get_space()); if (space) { bool col = space->intersect_ray(from, from + dir * 10000, result, Set<RID>(), 0xFFFFFFFF, true, true, true); @@ -1185,7 +1185,7 @@ void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) { return; if (parent && parent->find_world_2d() == p_world_2d) { - WARN_PRINT("Unable to use parent world as world_2d"); + WARN_PRINT("Unable to use parent world_3d as world_2d"); return; } @@ -1197,7 +1197,7 @@ void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) { if (p_world_2d.is_valid()) world_2d = p_world_2d; else { - WARN_PRINT("Invalid world"); + WARN_PRINT("Invalid world_3d"); world_2d = Ref<World2D>(memnew(World2D)); } @@ -1235,7 +1235,7 @@ void Viewport::_propagate_enter_world(Node *p_node) { Viewport *v = Object::cast_to<Viewport>(p_node); if (v) { - if (v->world.is_valid() || v->own_world.is_valid()) + if (v->world_3d.is_valid() || v->own_world_3d.is_valid()) return; } #ifndef _3D_DISABLED @@ -1275,7 +1275,7 @@ void Viewport::_propagate_exit_world(Node *p_node) { Viewport *v = Object::cast_to<Viewport>(p_node); if (v) { - if (v->world.is_valid() || v->own_world.is_valid()) + if (v->world_3d.is_valid() || v->own_world_3d.is_valid()) return; } #ifndef _3D_DISABLED @@ -1289,26 +1289,26 @@ void Viewport::_propagate_exit_world(Node *p_node) { } } -void Viewport::set_world(const Ref<World3D> &p_world) { +void Viewport::set_world_3d(const Ref<World3D> &p_world_3d) { - if (world == p_world) + if (world_3d == p_world_3d) return; if (is_inside_tree()) _propagate_exit_world(this); - if (own_world.is_valid() && world.is_valid()) { - world->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_changed)); + if (own_world_3d.is_valid() && world_3d.is_valid()) { + world_3d->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_3d_changed)); } - world = p_world; + world_3d = p_world_3d; - if (own_world.is_valid()) { - if (world.is_valid()) { - own_world = world->duplicate(); - world->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_changed)); + if (own_world_3d.is_valid()) { + if (world_3d.is_valid()) { + own_world_3d = world_3d->duplicate(); + world_3d->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_3d_changed)); } else { - own_world = Ref<World3D>(memnew(World3D)); + own_world_3d = Ref<World3D>(memnew(World3D)); } } @@ -1316,15 +1316,15 @@ void Viewport::set_world(const Ref<World3D> &p_world) { _propagate_enter_world(this); if (is_inside_tree()) { - RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario()); + RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world_3d()->get_scenario()); } _update_listener(); } -Ref<World3D> Viewport::get_world() const { +Ref<World3D> Viewport::get_world_3d() const { - return world; + return world_3d; } Ref<World2D> Viewport::get_world_2d() const { @@ -1332,14 +1332,14 @@ Ref<World2D> Viewport::get_world_2d() const { return world_2d; } -Ref<World3D> Viewport::find_world() const { +Ref<World3D> Viewport::find_world_3d() const { - if (own_world.is_valid()) - return own_world; - else if (world.is_valid()) - return world; + if (own_world_3d.is_valid()) + return own_world_3d; + else if (world_3d.is_valid()) + return world_3d; else if (parent) - return parent->find_world(); + return parent->find_world_3d(); else return Ref<World3D>(); } @@ -3077,25 +3077,25 @@ void Viewport::unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coor } } -void Viewport::set_use_own_world(bool p_world) { +void Viewport::set_use_own_world_3d(bool p_world_3d) { - if (p_world == own_world.is_valid()) + if (p_world_3d == own_world_3d.is_valid()) return; if (is_inside_tree()) _propagate_exit_world(this); - if (!p_world) { - own_world = Ref<World3D>(); - if (world.is_valid()) { - world->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_changed)); + if (!p_world_3d) { + own_world_3d = Ref<World3D>(); + if (world_3d.is_valid()) { + world_3d->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_3d_changed)); } } else { - if (world.is_valid()) { - own_world = world->duplicate(); - world->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_changed)); + if (world_3d.is_valid()) { + own_world_3d = world_3d->duplicate(); + world_3d->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_3d_changed)); } else { - own_world = Ref<World3D>(memnew(World3D)); + own_world_3d = Ref<World3D>(memnew(World3D)); } } @@ -3103,15 +3103,15 @@ void Viewport::set_use_own_world(bool p_world) { _propagate_enter_world(this); if (is_inside_tree()) { - RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario()); + RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world_3d()->get_scenario()); } _update_listener(); } -bool Viewport::is_using_own_world() const { +bool Viewport::is_using_own_world_3d() const { - return own_world.is_valid(); + return own_world_3d.is_valid(); } void Viewport::set_physics_object_picking(bool p_enable) { @@ -3366,9 +3366,9 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_world_2d", "world_2d"), &Viewport::set_world_2d); ClassDB::bind_method(D_METHOD("get_world_2d"), &Viewport::get_world_2d); ClassDB::bind_method(D_METHOD("find_world_2d"), &Viewport::find_world_2d); - ClassDB::bind_method(D_METHOD("set_world", "world"), &Viewport::set_world); - ClassDB::bind_method(D_METHOD("get_world"), &Viewport::get_world); - ClassDB::bind_method(D_METHOD("find_world"), &Viewport::find_world); + ClassDB::bind_method(D_METHOD("set_world_3d", "world_3d"), &Viewport::set_world_3d); + ClassDB::bind_method(D_METHOD("get_world_3d"), &Viewport::get_world_3d); + ClassDB::bind_method(D_METHOD("find_world_3d"), &Viewport::find_world_3d); ClassDB::bind_method(D_METHOD("set_canvas_transform", "xform"), &Viewport::set_canvas_transform); ClassDB::bind_method(D_METHOD("get_canvas_transform"), &Viewport::get_canvas_transform); @@ -3404,8 +3404,8 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("update_worlds"), &Viewport::update_worlds); - ClassDB::bind_method(D_METHOD("set_use_own_world", "enable"), &Viewport::set_use_own_world); - ClassDB::bind_method(D_METHOD("is_using_own_world"), &Viewport::is_using_own_world); + ClassDB::bind_method(D_METHOD("set_use_own_world_3d", "enable"), &Viewport::set_use_own_world_3d); + ClassDB::bind_method(D_METHOD("is_using_own_world_3d"), &Viewport::is_using_own_world_3d); ClassDB::bind_method(D_METHOD("get_camera"), &Viewport::get_camera); @@ -3453,8 +3453,8 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_default_canvas_item_texture_repeat", "mode"), &Viewport::set_default_canvas_item_texture_repeat); ClassDB::bind_method(D_METHOD("get_default_canvas_item_texture_repeat"), &Viewport::get_default_canvas_item_texture_repeat); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world"), "set_use_own_world", "is_using_own_world"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world", PROPERTY_HINT_RESOURCE_TYPE, "World"), "set_world", "get_world"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world_3d"), "set_use_own_world_3d", "is_using_own_world_3d"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_3d", PROPERTY_HINT_RESOURCE_TYPE, "World3D"), "set_world_3d", "get_world_3d"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_2d", PROPERTY_HINT_RESOURCE_TYPE, "World2D", 0), "set_world_2d", "get_world_2d"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transparent_bg"), "set_transparent_background", "has_transparent_background"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "handle_input_locally"), "set_handle_input_locally", "is_handling_input_locally"); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 7e2df9fe42..7da57347fd 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -253,8 +253,8 @@ private: Map<ObjectID, uint64_t> physics_2d_mouseover; Ref<World2D> world_2d; - Ref<World3D> world; - Ref<World3D> own_world; + Ref<World3D> world_3d; + Ref<World3D> own_world_3d; Rect2i to_screen_rect; StringName input_group; @@ -430,7 +430,7 @@ private: void _gui_set_root_order_dirty(); - void _own_world_changed(); + void _own_world_3d_changed(); friend class Window; @@ -477,10 +477,10 @@ public: Rect2 get_visible_rect() const; RID get_viewport_rid() const; - void set_world(const Ref<World3D> &p_world); + void set_world_3d(const Ref<World3D> &p_world_3d); void set_world_2d(const Ref<World2D> &p_world_2d); - Ref<World3D> get_world() const; - Ref<World3D> find_world() const; + Ref<World3D> get_world_3d() const; + Ref<World3D> find_world_3d() const; Ref<World2D> get_world_2d() const; Ref<World2D> find_world_2d() const; @@ -519,8 +519,8 @@ public: Vector2 get_camera_coords(const Vector2 &p_viewport_coords) const; Vector2 get_camera_rect_size() const; - void set_use_own_world(bool p_world); - bool is_using_own_world() const; + void set_use_own_world_3d(bool p_world_3d); + bool is_using_own_world_3d() const; void input_text(const String &p_text); void input(const Ref<InputEvent> &p_event, bool p_local_coords = false); |