Merge pull request #51474 from aaronfranke/organize-viewport
Organize methods in Viewport and explicitly name 3D methods with 3D
This commit is contained in:
commit
d915c187d0
9 changed files with 526 additions and 564 deletions
|
@ -169,7 +169,7 @@
|
|||
<member name="audio_listener_enable_2d" type="bool" setter="set_as_audio_listener_2d" getter="is_audio_listener_2d" default="false">
|
||||
If [code]true[/code], the viewport will process 2D audio streams.
|
||||
</member>
|
||||
<member name="audio_listener_enable_3d" type="bool" setter="set_as_audio_listener" getter="is_audio_listener" default="false">
|
||||
<member name="audio_listener_enable_3d" type="bool" setter="set_as_audio_listener_3d" getter="is_audio_listener_3d" default="false">
|
||||
If [code]true[/code], the viewport will process 3D audio streams.
|
||||
</member>
|
||||
<member name="canvas_item_default_texture_filter" type="int" setter="set_default_canvas_item_texture_filter" getter="get_default_canvas_item_texture_filter" enum="Viewport.DefaultCanvasItemTextureFilter" default="1">
|
||||
|
|
|
@ -565,7 +565,7 @@ void EditorNode::_notification(int p_what) {
|
|||
Engine::get_singleton()->set_editor_hint(true);
|
||||
|
||||
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec")));
|
||||
get_tree()->get_root()->set_as_audio_listener(false);
|
||||
get_tree()->get_root()->set_as_audio_listener_3d(false);
|
||||
get_tree()->get_root()->set_as_audio_listener_2d(false);
|
||||
get_tree()->get_root()->set_snap_2d_transforms_to_pixel(false);
|
||||
get_tree()->get_root()->set_snap_2d_vertices_to_pixel(false);
|
||||
|
|
|
@ -3187,7 +3187,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
|
|||
int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER);
|
||||
bool current = view_menu->get_popup()->is_item_checked(idx);
|
||||
current = !current;
|
||||
viewport->set_as_audio_listener(current);
|
||||
viewport->set_as_audio_listener_3d(current);
|
||||
view_menu->get_popup()->set_item_checked(idx, current);
|
||||
|
||||
} break;
|
||||
|
@ -3634,7 +3634,7 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) {
|
|||
bool listener = p_state["listener"];
|
||||
|
||||
int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER);
|
||||
viewport->set_as_audio_listener(listener);
|
||||
viewport->set_as_audio_listener_3d(listener);
|
||||
view_menu->get_popup()->set_item_checked(idx, listener);
|
||||
}
|
||||
if (p_state.has("doppler")) {
|
||||
|
@ -3718,7 +3718,7 @@ Dictionary Node3DEditorViewport::get_state() const {
|
|||
} else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS))) {
|
||||
d["display_mode"] = VIEW_DISPLAY_SHADELESS;
|
||||
}
|
||||
d["listener"] = viewport->is_audio_listener();
|
||||
d["listener"] = viewport->is_audio_listener_3d();
|
||||
d["doppler"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER));
|
||||
d["gizmos"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_GIZMOS));
|
||||
d["information"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION));
|
||||
|
@ -4363,7 +4363,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
|
|||
|
||||
if (p_index == 0) {
|
||||
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER), true);
|
||||
viewport->set_as_audio_listener(true);
|
||||
viewport->set_as_audio_listener_3d(true);
|
||||
}
|
||||
|
||||
name = "";
|
||||
|
@ -6820,7 +6820,7 @@ void Node3DEditor::clear() {
|
|||
|
||||
for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
|
||||
viewports[i]->view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(Node3DEditorViewport::VIEW_AUDIO_LISTENER), i == 0);
|
||||
viewports[i]->viewport->set_as_audio_listener(i == 0);
|
||||
viewports[i]->viewport->set_as_audio_listener_3d(i == 0);
|
||||
}
|
||||
|
||||
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_GRID), true);
|
||||
|
|
|
@ -407,14 +407,14 @@ void AudioStreamPlayer3D::_notification(int p_what) {
|
|||
for (const Set<Camera3D *>::Element *E = world_3d->get_cameras().front(); E; E = E->next()) {
|
||||
Camera3D *camera = E->get();
|
||||
Viewport *vp = camera->get_viewport();
|
||||
if (!vp->is_audio_listener()) {
|
||||
if (!vp->is_audio_listener_3d()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool listener_is_camera = true;
|
||||
Node3D *listener_node = camera;
|
||||
|
||||
Listener3D *listener = vp->get_listener();
|
||||
Listener3D *listener = vp->get_listener_3d();
|
||||
if (listener) {
|
||||
listener_node = listener;
|
||||
listener_is_camera = false;
|
||||
|
|
|
@ -73,14 +73,14 @@ void Listener3D::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
|
||||
void Listener3D::_update_listener() {
|
||||
if (is_inside_tree() && is_current()) {
|
||||
get_viewport()->_listener_transform_changed_notify();
|
||||
get_viewport()->_listener_transform_3d_changed_notify();
|
||||
}
|
||||
}
|
||||
|
||||
void Listener3D::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_WORLD: {
|
||||
bool first_listener = get_viewport()->_listener_add(this);
|
||||
bool first_listener = get_viewport()->_listener_3d_add(this);
|
||||
if (!get_tree()->is_node_being_edited(this) && (current || first_listener)) {
|
||||
make_current();
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void Listener3D::_notification(int p_what) {
|
|||
}
|
||||
}
|
||||
|
||||
get_viewport()->_listener_remove(this);
|
||||
get_viewport()->_listener_3d_remove(this);
|
||||
|
||||
} break;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ void Listener3D::make_current() {
|
|||
return;
|
||||
}
|
||||
|
||||
get_viewport()->_listener_set(this);
|
||||
get_viewport()->_listener_3d_set(this);
|
||||
}
|
||||
|
||||
void Listener3D::clear_current() {
|
||||
|
@ -125,15 +125,15 @@ void Listener3D::clear_current() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (get_viewport()->get_listener() == this) {
|
||||
get_viewport()->_listener_set(nullptr);
|
||||
get_viewport()->_listener_make_next_current(this);
|
||||
if (get_viewport()->get_listener_3d() == this) {
|
||||
get_viewport()->_listener_3d_set(nullptr);
|
||||
get_viewport()->_listener_3d_make_next_current(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool Listener3D::is_current() const {
|
||||
if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) {
|
||||
return get_viewport()->get_listener() == this;
|
||||
return get_viewport()->get_listener_3d() == this;
|
||||
} else {
|
||||
return current;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra
|
|||
} else if (p_msg == "override_camera_3D:set") {
|
||||
ERR_FAIL_COND_V(p_args.size() < 1, ERR_INVALID_DATA);
|
||||
bool enable = p_args[0];
|
||||
scene_tree->get_root()->enable_camera_override(enable);
|
||||
scene_tree->get_root()->enable_camera_3d_override(enable);
|
||||
|
||||
} else if (p_msg == "override_camera_3D:transform") {
|
||||
ERR_FAIL_COND_V(p_args.size() < 5, ERR_INVALID_DATA);
|
||||
|
@ -104,11 +104,11 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra
|
|||
float near = p_args[3];
|
||||
float far = p_args[4];
|
||||
if (is_perspective) {
|
||||
scene_tree->get_root()->set_camera_override_perspective(size_or_fov, near, far);
|
||||
scene_tree->get_root()->set_camera_3d_override_perspective(size_or_fov, near, far);
|
||||
} else {
|
||||
scene_tree->get_root()->set_camera_override_orthogonal(size_or_fov, near, far);
|
||||
scene_tree->get_root()->set_camera_3d_override_orthogonal(size_or_fov, near, far);
|
||||
}
|
||||
scene_tree->get_root()->set_camera_override_transform(transform);
|
||||
scene_tree->get_root()->set_camera_3d_override_transform(transform);
|
||||
|
||||
} else if (p_msg == "set_object_property") {
|
||||
ERR_FAIL_COND_V(p_args.size() < 3, ERR_INVALID_DATA);
|
||||
|
|
|
@ -1341,7 +1341,7 @@ SceneTree::SceneTree() {
|
|||
set_multiplayer(Ref<MultiplayerAPI>(memnew(MultiplayerAPI)));
|
||||
|
||||
//root->set_world_2d( Ref<World2D>( memnew( World2D )));
|
||||
root->set_as_audio_listener(true);
|
||||
root->set_as_audio_listener_3d(true);
|
||||
root->set_as_audio_listener_2d(true);
|
||||
current_scene = nullptr;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -194,39 +194,13 @@ private:
|
|||
|
||||
Viewport *parent = nullptr;
|
||||
|
||||
Listener3D *listener = nullptr;
|
||||
Set<Listener3D *> listeners;
|
||||
|
||||
struct CameraOverrideData {
|
||||
Transform3D transform;
|
||||
enum Projection {
|
||||
PROJECTION_PERSPECTIVE,
|
||||
PROJECTION_ORTHOGONAL
|
||||
};
|
||||
Projection projection = Projection::PROJECTION_PERSPECTIVE;
|
||||
float fov = 0.0;
|
||||
float size = 0.0;
|
||||
float z_near = 0.0;
|
||||
float z_far = 0.0;
|
||||
RID rid;
|
||||
|
||||
operator bool() const {
|
||||
return rid != RID();
|
||||
}
|
||||
} camera_override;
|
||||
|
||||
Camera3D *camera_3d = nullptr;
|
||||
Camera2D *camera_2d = nullptr;
|
||||
Set<Camera3D *> cameras;
|
||||
Set<CanvasLayer *> canvas_layers;
|
||||
|
||||
RID viewport;
|
||||
RID current_canvas;
|
||||
RID subwindow_canvas;
|
||||
|
||||
bool audio_listener = false;
|
||||
RID internal_listener;
|
||||
|
||||
bool audio_listener_2d = false;
|
||||
RID internal_listener_2d;
|
||||
|
||||
|
@ -240,7 +214,6 @@ private:
|
|||
Size2i size = Size2i(512, 512);
|
||||
Size2i size_2d_override;
|
||||
bool size_allocated = false;
|
||||
bool use_xr = false;
|
||||
|
||||
RID contact_2d_debug;
|
||||
RID contact_3d_debug_multimesh;
|
||||
|
@ -274,8 +247,6 @@ private:
|
|||
|
||||
} physics_last_mouse_state;
|
||||
|
||||
void _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);
|
||||
|
||||
bool handle_input_locally = true;
|
||||
bool local_input_handled = false;
|
||||
|
||||
|
@ -287,8 +258,6 @@ private:
|
|||
void _cleanup_mouseover_colliders(bool p_clean_all_frames, bool p_paused_only, uint64_t p_frame_reference = 0);
|
||||
|
||||
Ref<World2D> world_2d;
|
||||
Ref<World3D> world_3d;
|
||||
Ref<World3D> own_world_3d;
|
||||
|
||||
Rect2i to_screen_rect;
|
||||
StringName input_group;
|
||||
|
@ -296,13 +265,10 @@ private:
|
|||
StringName unhandled_input_group;
|
||||
StringName unhandled_key_input_group;
|
||||
|
||||
void _update_listener();
|
||||
void _update_listener_2d();
|
||||
|
||||
bool disable_3d = false;
|
||||
|
||||
void _propagate_enter_world(Node *p_node);
|
||||
void _propagate_exit_world(Node *p_node);
|
||||
void _propagate_viewport_notification(Node *p_node, int p_what);
|
||||
|
||||
void _update_global_transform();
|
||||
|
@ -443,20 +409,6 @@ private:
|
|||
|
||||
bool _gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_check);
|
||||
|
||||
friend class Listener3D;
|
||||
void _listener_transform_changed_notify();
|
||||
void _listener_set(Listener3D *p_listener);
|
||||
bool _listener_add(Listener3D *p_listener); //true if first
|
||||
void _listener_remove(Listener3D *p_listener);
|
||||
void _listener_make_next_current(Listener3D *p_exclude);
|
||||
|
||||
friend class Camera3D;
|
||||
void _camera_3d_transform_changed_notify();
|
||||
void _camera_3d_set(Camera3D *p_camera);
|
||||
bool _camera_3d_add(Camera3D *p_camera); //true if first
|
||||
void _camera_3d_remove(Camera3D *p_camera);
|
||||
void _camera_3d_make_next_current(Camera3D *p_exclude);
|
||||
|
||||
friend class Camera2D;
|
||||
void _camera_2d_set(Camera2D *p_camera_2d);
|
||||
|
||||
|
@ -471,8 +423,6 @@ private:
|
|||
|
||||
void _gui_set_root_order_dirty();
|
||||
|
||||
void _own_world_3d_changed();
|
||||
|
||||
friend class Window;
|
||||
|
||||
void _sub_window_update_order();
|
||||
|
@ -500,38 +450,16 @@ protected:
|
|||
public:
|
||||
uint64_t get_processed_events_count() const { return event_count; }
|
||||
|
||||
Listener3D *get_listener() const;
|
||||
Camera3D *get_camera_3d() const;
|
||||
Camera2D *get_camera_2d() const;
|
||||
|
||||
void enable_camera_override(bool p_enable);
|
||||
bool is_camera_override_enabled() const;
|
||||
|
||||
void set_camera_override_transform(const Transform3D &p_transform);
|
||||
Transform3D get_camera_override_transform() const;
|
||||
|
||||
void set_camera_override_perspective(float p_fovy_degrees, float p_z_near, float p_z_far);
|
||||
void set_camera_override_orthogonal(float p_size, float p_z_near, float p_z_far);
|
||||
|
||||
void set_as_audio_listener(bool p_enable);
|
||||
bool is_audio_listener() const;
|
||||
|
||||
void set_as_audio_listener_2d(bool p_enable);
|
||||
bool is_audio_listener_2d() const;
|
||||
|
||||
void set_disable_3d(bool p_disable);
|
||||
bool is_3d_disabled() const;
|
||||
|
||||
void update_canvas_items();
|
||||
|
||||
Rect2 get_visible_rect() const;
|
||||
RID get_viewport_rid() const;
|
||||
|
||||
void set_world_3d(const Ref<World3D> &p_world_3d);
|
||||
void set_world_2d(const Ref<World2D> &p_world_2d);
|
||||
Ref<World3D> get_world_3d() const;
|
||||
Ref<World3D> find_world_3d() const;
|
||||
|
||||
Ref<World2D> get_world_2d() const;
|
||||
Ref<World2D> find_world_2d() const;
|
||||
|
||||
|
@ -552,9 +480,6 @@ public:
|
|||
void set_transparent_background(bool p_enable);
|
||||
bool has_transparent_background() const;
|
||||
|
||||
void set_use_xr(bool p_use_xr);
|
||||
bool is_using_xr();
|
||||
|
||||
Ref<ViewportTexture> get_texture() const;
|
||||
|
||||
void set_shadow_atlas_size(int p_size);
|
||||
|
@ -584,9 +509,6 @@ public:
|
|||
Vector2 get_camera_coords(const Vector2 &p_viewport_coords) const;
|
||||
Vector2 get_camera_rect_size() 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);
|
||||
void unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coords = false);
|
||||
|
@ -654,6 +576,78 @@ public:
|
|||
|
||||
void pass_mouse_focus_to(Viewport *p_viewport, Control *p_control);
|
||||
|
||||
bool use_xr = false;
|
||||
friend class Listener3D;
|
||||
Listener3D *listener_3d = nullptr;
|
||||
Set<Listener3D *> listener_3d_set;
|
||||
bool audio_listener_3d = false;
|
||||
RID internal_listener_3d;
|
||||
Listener3D *get_listener_3d() const;
|
||||
void set_as_audio_listener_3d(bool p_enable);
|
||||
bool is_audio_listener_3d() const;
|
||||
void _update_listener_3d();
|
||||
void _listener_transform_3d_changed_notify();
|
||||
void _listener_3d_set(Listener3D *p_listener);
|
||||
bool _listener_3d_add(Listener3D *p_listener); //true if first
|
||||
void _listener_3d_remove(Listener3D *p_listener);
|
||||
void _listener_3d_make_next_current(Listener3D *p_exclude);
|
||||
|
||||
void _collision_object_3d_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);
|
||||
|
||||
struct Camera3DOverrideData {
|
||||
Transform3D transform;
|
||||
enum Projection {
|
||||
PROJECTION_PERSPECTIVE,
|
||||
PROJECTION_ORTHOGONAL
|
||||
};
|
||||
Projection projection = Projection::PROJECTION_PERSPECTIVE;
|
||||
real_t fov = 0.0;
|
||||
real_t size = 0.0;
|
||||
real_t z_near = 0.0;
|
||||
real_t z_far = 0.0;
|
||||
RID rid;
|
||||
|
||||
operator bool() const {
|
||||
return rid != RID();
|
||||
}
|
||||
} camera_3d_override;
|
||||
|
||||
friend class Camera3D;
|
||||
Camera3D *camera_3d = nullptr;
|
||||
Set<Camera3D *> camera_3d_set;
|
||||
Camera3D *get_camera_3d() const;
|
||||
void _camera_3d_transform_changed_notify();
|
||||
void _camera_3d_set(Camera3D *p_camera);
|
||||
bool _camera_3d_add(Camera3D *p_camera); //true if first
|
||||
void _camera_3d_remove(Camera3D *p_camera);
|
||||
void _camera_3d_make_next_current(Camera3D *p_exclude);
|
||||
|
||||
void enable_camera_3d_override(bool p_enable);
|
||||
bool is_camera_3d_override_enabled() const;
|
||||
|
||||
void set_camera_3d_override_transform(const Transform3D &p_transform);
|
||||
Transform3D get_camera_3d_override_transform() const;
|
||||
|
||||
void set_camera_3d_override_perspective(real_t p_fovy_degrees, real_t p_z_near, real_t p_z_far);
|
||||
void set_camera_3d_override_orthogonal(real_t p_size, real_t p_z_near, real_t p_z_far);
|
||||
|
||||
void set_disable_3d(bool p_disable);
|
||||
bool is_3d_disabled() const;
|
||||
|
||||
Ref<World3D> world_3d;
|
||||
Ref<World3D> own_world_3d;
|
||||
void set_world_3d(const Ref<World3D> &p_world_3d);
|
||||
Ref<World3D> get_world_3d() const;
|
||||
Ref<World3D> find_world_3d() const;
|
||||
void _own_world_3d_changed();
|
||||
void set_use_own_world_3d(bool p_world_3d);
|
||||
bool is_using_own_world_3d() const;
|
||||
void _propagate_enter_world_3d(Node *p_node);
|
||||
void _propagate_exit_world_3d(Node *p_node);
|
||||
|
||||
void set_use_xr(bool p_use_xr);
|
||||
bool is_using_xr();
|
||||
|
||||
Viewport();
|
||||
~Viewport();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue