Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organize methods in Viewport and explicitly name 3D methods with 3D #51474

Merged
merged 1 commit into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/classes/Viewport.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions scene/3d/audio_stream_player_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions scene/3d/listener_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -99,7 +99,7 @@ void Listener3D::_notification(int p_what) {
}
}

get_viewport()->_listener_remove(this);
get_viewport()->_listener_3d_remove(this);

} break;
}
Expand All @@ -116,7 +116,7 @@ void Listener3D::make_current() {
return;
}

get_viewport()->_listener_set(this);
get_viewport()->_listener_3d_set(this);
}

void Listener3D::clear_current() {
Expand All @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions scene/debugger/scene_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion scene/main/scene_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading