diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/audio_stream_player_3d.cpp | 8 | ||||
-rw-r--r-- | scene/3d/camera_3d.cpp | 10 | ||||
-rw-r--r-- | scene/3d/collision_object_3d.cpp | 2 | ||||
-rw-r--r-- | scene/3d/node_3d.cpp | 6 | ||||
-rw-r--r-- | scene/3d/node_3d.h | 2 | ||||
-rw-r--r-- | scene/3d/ray_cast_3d.cpp | 2 | ||||
-rw-r--r-- | scene/3d/soft_body_3d.cpp | 2 | ||||
-rw-r--r-- | scene/3d/spring_arm_3d.cpp | 4 | ||||
-rw-r--r-- | scene/3d/visibility_notifier_3d.cpp | 8 | ||||
-rw-r--r-- | scene/3d/visual_instance_3d.cpp | 4 | ||||
-rw-r--r-- | scene/3d/world_environment.cpp | 50 | ||||
-rw-r--r-- | scene/main/scene_tree.cpp | 10 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 110 | ||||
-rw-r--r-- | scene/main/viewport.h | 16 |
14 files changed, 117 insertions, 117 deletions
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 097368853e..8d45d11497 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -385,8 +385,8 @@ void AudioStreamPlayer3D::_notification(int p_what) { linear_velocity = velocity_tracker->get_tracked_linear_velocity(); } - Ref<World3D> world = get_world(); - ERR_FAIL_COND(world.is_null()); + Ref<World3D> world_3d = get_world_3d(); + ERR_FAIL_COND(world_3d.is_null()); int new_output_count = 0; @@ -396,7 +396,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { //check if any area is diverting sound into a bus - PhysicsDirectSpaceState3D *space_state = PhysicsServer3D::get_singleton()->space_get_direct_state(world->get_space()); + PhysicsDirectSpaceState3D *space_state = PhysicsServer3D::get_singleton()->space_get_direct_state(world_3d->get_space()); PhysicsDirectSpaceState3D::ShapeResult sr[MAX_INTERSECT_AREAS]; @@ -419,7 +419,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { } List<Camera3D *> cameras; - world->get_camera_list(&cameras); + world_3d->get_camera_list(&cameras); for (List<Camera3D *>::Element *E = cameras.front(); E; E = E->next()) { diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index 706c49b43b..2fcb2715be 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -95,8 +95,8 @@ void Camera3D::_update_camera() { get_viewport()->_camera_transform_changed_notify(); - if (get_world().is_valid()) { - get_world()->_update_camera(this); + if (get_world_3d().is_valid()) { + get_world_3d()->_update_camera(this); } } @@ -144,12 +144,12 @@ void Camera3D::_notification(int p_what) { } break; case NOTIFICATION_BECAME_CURRENT: { if (viewport) { - viewport->find_world()->_register_camera(this); + viewport->find_world_3d()->_register_camera(this); } } break; case NOTIFICATION_LOST_CURRENT: { if (viewport) { - viewport->find_world()->_remove_camera(this); + viewport->find_world_3d()->_remove_camera(this); } } break; } @@ -743,7 +743,7 @@ void ClippedCamera3D::_notification(int p_what) { return; } - PhysicsDirectSpaceState3D *dspace = get_world()->get_direct_space_state(); + PhysicsDirectSpaceState3D *dspace = get_world_3d()->get_direct_space_state(); ERR_FAIL_COND(!dspace); // most likely physics set to threads Vector3 cam_fw = -get_global_transform().basis.get_axis(Vector3::AXIS_Z).normalized(); diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index e6cd7bfe7e..5d050e32b0 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -44,7 +44,7 @@ void CollisionObject3D::_notification(int p_what) { else PhysicsServer3D::get_singleton()->body_set_state(rid, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); - RID space = get_world()->get_space(); + RID space = get_world_3d()->get_space(); if (area) { PhysicsServer3D::get_singleton()->area_set_space(rid, space); } else diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index 0b7407e049..913a3ea49f 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -507,12 +507,12 @@ bool Node3D::is_set_as_toplevel() const { return data.toplevel; } -Ref<World3D> Node3D::get_world() const { +Ref<World3D> Node3D::get_world_3d() const { ERR_FAIL_COND_V(!is_inside_world(), Ref<World3D>()); ERR_FAIL_COND_V(!data.viewport, Ref<World3D>()); - return data.viewport->find_world(); + return data.viewport->find_world_3d(); } void Node3D::_propagate_visibility_changed() { @@ -756,7 +756,7 @@ void Node3D::_bind_methods() { ClassDB::bind_method(D_METHOD("is_set_as_toplevel"), &Node3D::is_set_as_toplevel); ClassDB::bind_method(D_METHOD("set_disable_scale", "disable"), &Node3D::set_disable_scale); ClassDB::bind_method(D_METHOD("is_scale_disabled"), &Node3D::is_scale_disabled); - ClassDB::bind_method(D_METHOD("get_world"), &Node3D::get_world); + ClassDB::bind_method(D_METHOD("get_world_3d"), &Node3D::get_world_3d); ClassDB::bind_method(D_METHOD("force_update_transform"), &Node3D::force_update_transform); diff --git a/scene/3d/node_3d.h b/scene/3d/node_3d.h index f97a8a97dc..a4191eb2b3 100644 --- a/scene/3d/node_3d.h +++ b/scene/3d/node_3d.h @@ -124,7 +124,7 @@ public: Node3D *get_parent_spatial() const; - Ref<World3D> get_world() const; + Ref<World3D> get_world_3d() const; void set_translation(const Vector3 &p_translation); void set_rotation(const Vector3 &p_euler_rad); diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp index a18da61656..304a5e1254 100644 --- a/scene/3d/ray_cast_3d.cpp +++ b/scene/3d/ray_cast_3d.cpp @@ -196,7 +196,7 @@ void RayCast3D::_notification(int p_what) { } void RayCast3D::_update_raycast_state() { - Ref<World3D> w3d = get_world(); + Ref<World3D> w3d = get_world_3d(); ERR_FAIL_COND(w3d.is_null()); PhysicsDirectSpaceState3D *dss = PhysicsServer3D::get_singleton()->space_get_direct_state(w3d->get_space()); diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp index 6092818252..850ffab292 100644 --- a/scene/3d/soft_body_3d.cpp +++ b/scene/3d/soft_body_3d.cpp @@ -270,7 +270,7 @@ void SoftBody3D::_notification(int p_what) { add_change_receptor(this); } - RID space = get_world()->get_space(); + RID space = get_world_3d()->get_space(); PhysicsServer3D::get_singleton()->soft_body_set_space(physics_rid, space); prepare_physics_server(); } break; diff --git a/scene/3d/spring_arm_3d.cpp b/scene/3d/spring_arm_3d.cpp index 0ffde7aa8f..1410b730fd 100644 --- a/scene/3d/spring_arm_3d.cpp +++ b/scene/3d/spring_arm_3d.cpp @@ -147,7 +147,7 @@ void SpringArm3D::process_spring() { if (shape.is_null()) { motion = Vector3(cast_direction * (spring_length)); PhysicsDirectSpaceState3D::RayResult r; - bool intersected = get_world()->get_direct_space_state()->intersect_ray(get_global_transform().origin, get_global_transform().origin + motion, r, excluded_objects, mask); + bool intersected = get_world_3d()->get_direct_space_state()->intersect_ray(get_global_transform().origin, get_global_transform().origin + motion, r, excluded_objects, mask); if (intersected) { float dist = get_global_transform().origin.distance_to(r.position); dist -= margin; @@ -155,7 +155,7 @@ void SpringArm3D::process_spring() { } } else { motion = Vector3(cast_direction * spring_length); - get_world()->get_direct_space_state()->cast_motion(shape->get_rid(), get_global_transform(), motion, 0, motion_delta, motion_delta_unsafe, excluded_objects, mask); + get_world_3d()->get_direct_space_state()->cast_motion(shape->get_rid(), get_global_transform(), motion, 0, motion_delta, motion_delta_unsafe, excluded_objects, mask); } current_spring_length = spring_length * motion_delta; diff --git a/scene/3d/visibility_notifier_3d.cpp b/scene/3d/visibility_notifier_3d.cpp index 2f657fe7b1..2707a0a514 100644 --- a/scene/3d/visibility_notifier_3d.cpp +++ b/scene/3d/visibility_notifier_3d.cpp @@ -68,7 +68,7 @@ void VisibilityNotifier3D::set_aabb(const AABB &p_aabb) { aabb = p_aabb; if (is_inside_world()) { - get_world()->_update_notifier(this, get_global_transform().xform(aabb)); + get_world_3d()->_update_notifier(this, get_global_transform().xform(aabb)); } _change_notify("aabb"); @@ -85,15 +85,15 @@ void VisibilityNotifier3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_WORLD: { - get_world()->_register_notifier(this, get_global_transform().xform(aabb)); + get_world_3d()->_register_notifier(this, get_global_transform().xform(aabb)); } break; case NOTIFICATION_TRANSFORM_CHANGED: { - get_world()->_update_notifier(this, get_global_transform().xform(aabb)); + get_world_3d()->_update_notifier(this, get_global_transform().xform(aabb)); } break; case NOTIFICATION_EXIT_WORLD: { - get_world()->_remove_notifier(this); + get_world_3d()->_remove_notifier(this); } break; } } diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index 604bc53422..ce8672c1dd 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -60,8 +60,8 @@ void VisualInstance3D::_notification(int p_what) { if (skeleton) RenderingServer::get_singleton()->instance_attach_skeleton( instance, skeleton->get_skeleton() ); */ - ERR_FAIL_COND(get_world().is_null()); - RenderingServer::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario()); + ERR_FAIL_COND(get_world_3d().is_null()); + RenderingServer::get_singleton()->instance_set_scenario(instance, get_world_3d()->get_scenario()); _update_visibility(); } break; diff --git a/scene/3d/world_environment.cpp b/scene/3d/world_environment.cpp index 8cf4554653..8dbb709ae4 100644 --- a/scene/3d/world_environment.cpp +++ b/scene/3d/world_environment.cpp @@ -36,50 +36,50 @@ void WorldEnvironment::_notification(int p_what) { if (p_what == Node3D::NOTIFICATION_ENTER_WORLD || p_what == Node3D::NOTIFICATION_ENTER_TREE) { if (environment.is_valid()) { - if (get_viewport()->find_world()->get_environment().is_valid()) { + if (get_viewport()->find_world_3d()->get_environment().is_valid()) { WARN_PRINT("World already has an environment (Another WorldEnvironment?), overriding."); } - get_viewport()->find_world()->set_environment(environment); - add_to_group("_world_environment_" + itos(get_viewport()->find_world()->get_scenario().get_id())); + get_viewport()->find_world_3d()->set_environment(environment); + add_to_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); } if (camera_effects.is_valid()) { - if (get_viewport()->find_world()->get_camera_effects().is_valid()) { + if (get_viewport()->find_world_3d()->get_camera_effects().is_valid()) { WARN_PRINT("World already has a camera effects (Another WorldEnvironment?), overriding."); } - get_viewport()->find_world()->set_camera_effects(camera_effects); - add_to_group("_world_camera_effects_" + itos(get_viewport()->find_world()->get_scenario().get_id())); + get_viewport()->find_world_3d()->set_camera_effects(camera_effects); + add_to_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); } } else if (p_what == Node3D::NOTIFICATION_EXIT_WORLD || p_what == Node3D::NOTIFICATION_EXIT_TREE) { - if (environment.is_valid() && get_viewport()->find_world()->get_environment() == environment) { - get_viewport()->find_world()->set_environment(Ref<Environment>()); - remove_from_group("_world_environment_" + itos(get_viewport()->find_world()->get_scenario().get_id())); + if (environment.is_valid() && get_viewport()->find_world_3d()->get_environment() == environment) { + get_viewport()->find_world_3d()->set_environment(Ref<Environment>()); + remove_from_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); } - if (camera_effects.is_valid() && get_viewport()->find_world()->get_camera_effects() == camera_effects) { - get_viewport()->find_world()->set_camera_effects(Ref<CameraEffects>()); - remove_from_group("_world_camera_effects_" + itos(get_viewport()->find_world()->get_scenario().get_id())); + if (camera_effects.is_valid() && get_viewport()->find_world_3d()->get_camera_effects() == camera_effects) { + get_viewport()->find_world_3d()->set_camera_effects(Ref<CameraEffects>()); + remove_from_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); } } } void WorldEnvironment::set_environment(const Ref<Environment> &p_environment) { - if (is_inside_tree() && environment.is_valid() && get_viewport()->find_world()->get_environment() == environment) { - get_viewport()->find_world()->set_environment(Ref<Environment>()); - remove_from_group("_world_environment_" + itos(get_viewport()->find_world()->get_scenario().get_id())); + if (is_inside_tree() && environment.is_valid() && get_viewport()->find_world_3d()->get_environment() == environment) { + get_viewport()->find_world_3d()->set_environment(Ref<Environment>()); + remove_from_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); //clean up } environment = p_environment; if (is_inside_tree() && environment.is_valid()) { - if (get_viewport()->find_world()->get_environment().is_valid()) { + if (get_viewport()->find_world_3d()->get_environment().is_valid()) { WARN_PRINT("World already has an environment (Another WorldEnvironment?), overriding."); } - get_viewport()->find_world()->set_environment(environment); - add_to_group("_world_environment_" + itos(get_viewport()->find_world()->get_scenario().get_id())); + get_viewport()->find_world_3d()->set_environment(environment); + add_to_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); } update_configuration_warning(); @@ -92,19 +92,19 @@ Ref<Environment> WorldEnvironment::get_environment() const { void WorldEnvironment::set_camera_effects(const Ref<CameraEffects> &p_camera_effects) { - if (is_inside_tree() && camera_effects.is_valid() && get_viewport()->find_world()->get_camera_effects() == camera_effects) { - get_viewport()->find_world()->set_camera_effects(Ref<CameraEffects>()); - remove_from_group("_world_camera_effects_" + itos(get_viewport()->find_world()->get_scenario().get_id())); + if (is_inside_tree() && camera_effects.is_valid() && get_viewport()->find_world_3d()->get_camera_effects() == camera_effects) { + get_viewport()->find_world_3d()->set_camera_effects(Ref<CameraEffects>()); + remove_from_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); //clean up } camera_effects = p_camera_effects; if (is_inside_tree() && camera_effects.is_valid()) { - if (get_viewport()->find_world()->get_camera_effects().is_valid()) { + if (get_viewport()->find_world_3d()->get_camera_effects().is_valid()) { WARN_PRINT("World already has an camera_effects (Another WorldEnvironment?), overriding."); } - get_viewport()->find_world()->set_camera_effects(camera_effects); - add_to_group("_world_camera_effects_" + itos(get_viewport()->find_world()->get_scenario().get_id())); + get_viewport()->find_world_3d()->set_camera_effects(camera_effects); + add_to_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); } update_configuration_warning(); @@ -125,7 +125,7 @@ String WorldEnvironment::get_configuration_warning() const { return String(); List<Node *> nodes; - get_tree()->get_nodes_in_group("_world_environment_" + itos(get_viewport()->find_world()->get_scenario().get_id()), &nodes); + get_tree()->get_nodes_in_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id()), &nodes); if (nodes.size() > 1) { return TTR("Only one WorldEnvironment is allowed per scene (or set of instanced scenes)."); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 0418b20e9c..e6c70207b6 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; @@ -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 72b1a877c1..89af62f120 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", "get_world"); 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 0cbc957307..ed179f9491 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -254,8 +254,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; @@ -431,7 +431,7 @@ private: void _gui_set_root_order_dirty(); - void _own_world_changed(); + void _own_world_3d_changed(); friend class Window; @@ -478,10 +478,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; @@ -520,8 +520,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); |