From fb70332ecd78ba42ac3bcefe4381b5b3d908c113 Mon Sep 17 00:00:00 2001 From: Lean Mendoza Date: Tue, 12 Nov 2024 15:44:26 +0100 Subject: [PATCH] refactor: bump `gdext` to previous version of setting MSRV 1.78 (#486) * refactor: bump `gdext` to previous version of setting MSRV 1.78 * fix --- .github/actions/import-assets/action.yml | 4 +- README.md | 4 +- .../player_collider_filter.tscn | 6 + lib/Cargo.toml | 2 +- lib/src/analytics/metrics.rs | 4 +- lib/src/auth/dcl_player_identity.rs | 33 ++-- lib/src/av/video_context.rs | 4 +- lib/src/avatars/avatar_scene.rs | 13 +- lib/src/avatars/avatar_type.rs | 7 +- lib/src/avatars/dcl_user_profile.rs | 2 +- lib/src/avatars/item.rs | 5 +- lib/src/comms/adapter/archipelago.rs | 18 +-- lib/src/comms/adapter/ws_room.rs | 18 +-- lib/src/comms/communication_manager.rs | 31 ++-- lib/src/comms/voice_chat.rs | 13 +- lib/src/content/audio.rs | 6 +- lib/src/content/content_mapping.rs | 1 - lib/src/content/content_provider.rs | 2 +- lib/src/content/gltf.rs | 31 ++-- lib/src/content/texture.rs | 10 +- lib/src/content/thread_safety.rs | 4 +- lib/src/content/wearable_entities.rs | 4 +- lib/src/dcl/common/wearable.rs | 2 +- lib/src/dcl/components/mod.rs | 18 +-- lib/src/dcl/components/proto_components.rs | 36 ++--- lib/src/godot_classes/animator_controller.rs | 117 +++++++------- lib/src/godot_classes/dcl_audio_source.rs | 1 - lib/src/godot_classes/dcl_audio_stream.rs | 5 +- lib/src/godot_classes/dcl_avatar.rs | 35 +++-- .../dcl_avatar_modifier_area_3d.rs | 5 +- lib/src/godot_classes/dcl_camera_3d.rs | 1 - .../godot_classes/dcl_camera_mode_area_3d.rs | 1 - lib/src/godot_classes/dcl_config.rs | 9 +- lib/src/godot_classes/dcl_confirm_dialog.rs | 33 ++-- lib/src/godot_classes/dcl_ether.rs | 1 - lib/src/godot_classes/dcl_global.rs | 31 ++-- lib/src/godot_classes/dcl_gltf_container.rs | 11 +- lib/src/godot_classes/dcl_hashing.rs | 1 - lib/src/godot_classes/dcl_node_entity_3d.rs | 1 - lib/src/godot_classes/dcl_realm.rs | 1 - lib/src/godot_classes/dcl_scene_node.rs | 1 - lib/src/godot_classes/dcl_tokio_rpc.rs | 5 +- lib/src/godot_classes/dcl_ui_background.rs | 148 +++++++++--------- lib/src/godot_classes/dcl_ui_control.rs | 26 ++- lib/src/godot_classes/dcl_ui_dropdown.rs | 55 +++---- lib/src/godot_classes/dcl_ui_input.rs | 103 +++++------- lib/src/godot_classes/dcl_ui_text.rs | 97 ++++++------ lib/src/godot_classes/dcl_video_player.rs | 5 +- lib/src/godot_classes/font.rs | 2 +- lib/src/godot_classes/magic_link.rs | 17 +- lib/src/godot_classes/mod.rs | 4 +- lib/src/godot_classes/portables/mod.rs | 1 - lib/src/godot_classes/promise.rs | 10 +- lib/src/godot_classes/resource_locker.rs | 28 ++-- .../rpc_sender/dcl_rpc_sender.rs | 5 +- lib/src/http_request/request_response.rs | 4 +- .../http_request/rust_http_queue_requester.rs | 2 +- lib/src/realm/dcl_scene_entity_definition.rs | 2 +- .../scene_runner/components/audio_stream.rs | 6 +- .../scene_runner/components/avatar_shape.rs | 2 +- lib/src/scene_runner/components/billboard.rs | 2 +- lib/src/scene_runner/components/material.rs | 15 +- .../scene_runner/components/mesh_collider.rs | 26 +-- .../scene_runner/components/mesh_renderer.rs | 6 +- lib/src/scene_runner/components/raycast.rs | 4 +- lib/src/scene_runner/components/text_shape.rs | 30 ++-- .../scene_runner/components/ui/scene_ui.rs | 24 ++- .../components/ui/ui_background.rs | 11 +- .../scene_runner/components/ui/ui_dropdown.rs | 8 +- .../scene_runner/components/ui/ui_input.rs | 11 +- lib/src/scene_runner/components/ui/ui_text.rs | 11 +- .../scene_runner/components/video_player.rs | 8 +- .../scene_runner/global_get_node_helper.rs | 8 +- lib/src/scene_runner/godot_dcl_scene.rs | 23 +-- lib/src/scene_runner/input.rs | 2 +- lib/src/scene_runner/rpc_calls/mod.rs | 2 +- lib/src/scene_runner/scene.rs | 4 +- lib/src/scene_runner/scene_manager.rs | 39 ++--- lib/src/scene_runner/update_scene.rs | 2 +- lib/src/test_runner/test_suite.rs | 4 +- lib/src/test_runner/testing_tools.rs | 13 +- lib/src/tools/network_inspector.rs | 11 +- rust-toolchain.toml | 2 + 83 files changed, 636 insertions(+), 684 deletions(-) create mode 100644 godot/src/decentraland_components/player_collider_filter.tscn create mode 100644 rust-toolchain.toml diff --git a/.github/actions/import-assets/action.yml b/.github/actions/import-assets/action.yml index 4f5f8c08b..9eea8e820 100644 --- a/.github/actions/import-assets/action.yml +++ b/.github/actions/import-assets/action.yml @@ -9,7 +9,7 @@ runs: uses: actions/cache@v3 with: path: godot/.godot - key: ${{ runner.os }}-godot-assets-cache-4.3-bump + key: ${{ runner.os }}-godot-assets-cache-4.3 # Step 2: Run the command that generates/uses the assets - name: Import assets @@ -21,4 +21,4 @@ runs: uses: actions/cache@v3 with: path: godot/.godot - key: ${{ runner.os }}-godot-assets-cache-4.3-bump \ No newline at end of file + key: ${{ runner.os }}-godot-assets-cache-4.3 diff --git a/README.md b/README.md index 07e8f5f27..6565062cb 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ - **MacOS**: `brew install ffmpeg@6 pkg-config` - **Windows**: - download and unzip `https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full-shared.7z` - - set `LIBCLANG_PATH` = `path to LLVM\x64\bin` (this is packaged with visual studio, or can be downloaded separately) - set `FFMPEG_DIR` = `root folder where ffmpeg has been unzipped` - add `ffmpeg\bin` to your `PATH` + - set `LIBCLANG_PATH` = `path to LLVM\x64\bin` (this is packaged with visual studio, or can be downloaded separately) - the `.github/workflows/ci.yml` file can be useful to guide you 4. Run `cargo run -- install --platforms linux` in the repo root folder (change linux to your target platform). @@ -34,7 +34,7 @@ Execute the following commands for building Godot: ```bash # Run Docker -docker run -v {godot-explorer-repo-path}:/app/ -it kuruk/dcl-godot-android-builder:latest +docker run -v {godot-explorer-repo-path}:/app/ -it quay.io/decentraland/dcl-godot-android-builder:99091016236094cb776bd9cb1298602e56b8cdab # Compile for Android cd lib diff --git a/godot/src/decentraland_components/player_collider_filter.tscn b/godot/src/decentraland_components/player_collider_filter.tscn new file mode 100644 index 000000000..35f20934c --- /dev/null +++ b/godot/src/decentraland_components/player_collider_filter.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://b4tld1cqcvql5"] + +[ext_resource type="Script" path="res://src/decentraland_components/player_collider_filter.gd" id="1_pn4dy"] + +[node name="PlayerColliderFilter" type="Node"] +script = ExtResource("1_pn4dy") diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 1b5df37f1..0d849c763 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -8,7 +8,7 @@ publish = false crate-type = ["cdylib"] [dependencies] -godot = { git = "https://github.com/dclexplorer/gdext", branch = "master", features=["experimental-threads", "serde"] } +godot = { git = "https://github.com/godot-rust/gdext", rev ="cb41673a0ab802145543a8f371abfcb1f0be10f9", features=["experimental-threads", "serde"] } rand = "0.8" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0.92", features = ["raw_value"] } diff --git a/lib/src/analytics/metrics.rs b/lib/src/analytics/metrics.rs index 5fcac64e6..7cec44a49 100644 --- a/lib/src/analytics/metrics.rs +++ b/lib/src/analytics/metrics.rs @@ -62,10 +62,10 @@ impl INode for Metrics { timer.set_one_shot(false); timer.set_autostart(true); - let callable = self.base.callable("timer_timeout"); + let callable = self.base().callable("timer_timeout"); timer.connect("timeout".into(), callable); - self.base.add_child(timer.upcast()); + self.base_mut().add_child(timer.upcast()); } fn process(&mut self, delta: f64) { diff --git a/lib/src/auth/dcl_player_identity.rs b/lib/src/auth/dcl_player_identity.rs index 39acae11e..b5a3ad29b 100644 --- a/lib/src/auth/dcl_player_identity.rs +++ b/lib/src/auth/dcl_player_identity.rs @@ -39,7 +39,6 @@ pub struct DclPlayerIdentity { #[var] is_guest: bool, - #[base] base: Base, } @@ -89,7 +88,7 @@ impl DclPlayerIdentity { "error {e} invalid data ephemeral_auth_chain {:?}", ephemeral_auth_chain ); - self.base.call_deferred( + self.base_mut().call_deferred( "_error_getting_wallet".into(), &["Error parsing ephemeral_auth_chain".to_variant()], ); @@ -114,7 +113,7 @@ impl DclPlayerIdentity { self.ephemeral_auth_chain = Some(ephemeral_auth_chain); let address = self.get_address(); - self.base.call_deferred( + self.base_mut().call_deferred( "emit_signal".into(), &[ "wallet_connected".to_variant(), @@ -144,7 +143,7 @@ impl DclPlayerIdentity { let address = format!("{:#x}", self.get_address()); - self.base.call_deferred( + self.base_mut().call_deferred( "emit_signal".into(), &[ "wallet_connected".to_variant(), @@ -178,7 +177,7 @@ impl DclPlayerIdentity { self.magic_auth = false; - let instance_id = self.base.instance_id(); + let instance_id = self.base().instance_id(); let sender = DclGlobal::singleton() .bind() .get_dcl_tokio_rpc() @@ -226,7 +225,7 @@ impl DclPlayerIdentity { self.magic_auth = true; - let instance_id = self.base.instance_id(); + let instance_id = self.base().instance_id(); let sender = DclGlobal::singleton() .bind() .get_dcl_tokio_rpc() @@ -328,17 +327,17 @@ impl DclPlayerIdentity { }; if let Some(CurrentWallet::Local { wallet: _, keys }) = &self.wallet { - dict.insert( + let _ = dict.insert( "local_wallet", PackedByteArray::from_iter(keys.iter().cloned()).to_variant(), ); } - dict.insert("magic_auth", self.magic_auth.to_variant()); + let _ = dict.insert("magic_auth", self.magic_auth.to_variant()); - dict.insert("account_address", self.get_address_str().to_variant()); - dict.insert("chain_id", chain_id.to_variant()); - dict.insert( + let _ = dict.insert("account_address", self.get_address_str().to_variant()); + let _ = dict.insert("chain_id", chain_id.to_variant()); + let _ = dict.insert( "ephemeral_auth_chain", serde_json::to_string(&self.ephemeral_auth_chain.as_ref().unwrap()) .expect("serialize ephemeral auth chain") @@ -361,7 +360,7 @@ impl DclPlayerIdentity { let profile = DclUserProfile::from_gd(profile); self.profile = Some(profile.clone()); - self.base.call_deferred( + self.base_mut().call_deferred( "emit_signal".into(), &["profile_changed".to_variant(), profile.to_variant()], ); @@ -371,7 +370,7 @@ impl DclPlayerIdentity { pub fn set_profile(&mut self, profile: Gd) { self.profile = Some(profile.clone()); - self.base.call_deferred( + self.base_mut().call_deferred( "emit_signal".into(), &["profile_changed".to_variant(), profile.to_variant()], ); @@ -392,7 +391,7 @@ impl DclPlayerIdentity { metadata: GString, method: GString, ) -> Gd { - let promise = Promise::alloc_gd(); + let promise = Promise::new_alloc(); let promise_instance_id = promise.instance_id(); if let Some(handle) = TokioRuntime::static_clone_handle() { @@ -439,7 +438,7 @@ impl DclPlayerIdentity { new_profile: Gd, has_new_snapshots: bool, ) -> Gd { - let promise = Promise::alloc_gd(); + let promise = Promise::new_alloc(); let promise_instance_id = promise.instance_id(); let current_profile = if let Some(profile) = self.profile.clone() { @@ -517,7 +516,7 @@ impl DclPlayerIdentity { let new_profile = DclUserProfile::from_gd(profile); self.profile = Some(new_profile.clone()); - self.base.call_deferred( + self.base_mut().call_deferred( "emit_signal".into(), &["profile_changed".to_variant(), new_profile.to_variant()], ); @@ -561,7 +560,7 @@ impl DclPlayerIdentity { self.wallet = None; self.ephemeral_auth_chain = None; self.profile = None; - self.base + self.base_mut() .call_deferred("emit_signal".into(), &["logout".to_variant()]); } diff --git a/lib/src/av/video_context.rs b/lib/src/av/video_context.rs index 810477542..386e01f62 100644 --- a/lib/src/av/video_context.rs +++ b/lib/src/av/video_context.rs @@ -175,7 +175,7 @@ impl FfmpegContext for VideoContext { self.video_info.width as i32, self.video_info.height as i32, false, - Format::FORMAT_RGBA8, + Format::RGBA8, data_arr, ) .unwrap(); @@ -187,7 +187,7 @@ impl FfmpegContext for VideoContext { self.video_info.width as i32, self.video_info.height as i32, false, - Format::FORMAT_RGBA8, + Format::RGBA8, data_arr, ); self.texture.update(image); diff --git a/lib/src/avatars/avatar_scene.rs b/lib/src/avatars/avatar_scene.rs index cd85c4b36..35cb60ccb 100644 --- a/lib/src/avatars/avatar_scene.rs +++ b/lib/src/avatars/avatar_scene.rs @@ -31,7 +31,6 @@ type AvatarAlias = u32; #[derive(GodotClass)] #[class(base=Node)] pub struct AvatarScene { - #[base] base: Base, // map alias to the entity_id @@ -60,7 +59,7 @@ impl INode for AvatarScene { fn ready(&mut self) { DclGlobal::singleton().bind_mut().scene_runner.connect( "scene_spawned".into(), - self.base.callable("on_scene_spawned"), + self.base().callable("on_scene_spawned"), ); } } @@ -133,7 +132,7 @@ impl AvatarScene { .bind_mut() .set_movement_type(AvatarMovementType::LerpTwoPoints as i32); - let instance_id = self.base.instance_id(); + let instance_id = self.base().instance_id(); let avatar_entity_id = entity_id; let avatar_changed_scene_callable = Callable::from_fn("on_avatar_changed_scene", move |args: &[&Variant]| { @@ -184,7 +183,7 @@ impl AvatarScene { new_avatar.connect("change_scene_id".into(), avatar_changed_scene_callable); new_avatar.connect("emote_triggered".into(), emote_triggered_callable); - self.base.add_child(new_avatar.clone().upcast()); + self.base_mut().add_child(new_avatar.clone().upcast()); self.avatar_godot_scene.insert(entity_id, new_avatar); } @@ -201,7 +200,7 @@ impl AvatarScene { } #[func] - pub fn on_scene_spawned(&mut self) { + pub fn on_scene_spawned(&mut self, _scene_id: i32, _entity_id: GString) { for (_, avatar) in self.avatar_godot_scene.iter_mut() { avatar.bind_mut().on_parcel_scenes_changed(); } @@ -323,7 +322,7 @@ impl AvatarScene { let avatars = std::mem::take(&mut self.avatar_godot_scene); for (_, mut avatar) in avatars { - self.base.remove_child(avatar.clone().upcast()); + self.base_mut().remove_child(avatar.clone().upcast()); avatar.queue_free() } } @@ -338,7 +337,7 @@ impl AvatarScene { self.last_updated_profile.remove(&entity_id); avatar.queue_free(); - self.base.remove_child(avatar.upcast()); + self.base_mut().remove_child(avatar.upcast()); // Push dirty state in all the scenes let mut scene_runner = DclGlobal::singleton().bind().scene_runner.clone(); diff --git a/lib/src/avatars/avatar_type.rs b/lib/src/avatars/avatar_type.rs index b2abc019a..bcbbe5130 100644 --- a/lib/src/avatars/avatar_type.rs +++ b/lib/src/avatars/avatar_type.rs @@ -1,7 +1,4 @@ -use godot::{ - bind::{godot_api, GodotClass}, - prelude::*, -}; +use godot::prelude::*; use crate::comms::profile::{AvatarColor, AvatarEmote, AvatarSnapshots, AvatarWireFormat}; @@ -20,7 +17,7 @@ const DEFAULT_EMOTES: [&str; AVATAR_EMOTE_SLOTS_COUNT] = [ ]; #[derive(GodotClass)] -#[class(base=RefCounted)] +#[class(init, base=RefCounted)] pub struct DclAvatarWireFormat { pub inner: AvatarWireFormat, } diff --git a/lib/src/avatars/dcl_user_profile.rs b/lib/src/avatars/dcl_user_profile.rs index b99b26794..f122ac6dd 100644 --- a/lib/src/avatars/dcl_user_profile.rs +++ b/lib/src/avatars/dcl_user_profile.rs @@ -1,7 +1,7 @@ use godot::{ - bind::{godot_api, GodotClass}, builtin::{meta::ToGodot, Dictionary, GString}, obj::Gd, + prelude::*, }; use crate::comms::profile::UserProfile; diff --git a/lib/src/avatars/item.rs b/lib/src/avatars/item.rs index d55dc1472..36f4a70c6 100644 --- a/lib/src/avatars/item.rs +++ b/lib/src/avatars/item.rs @@ -12,12 +12,13 @@ use crate::{ godot_classes::dcl_global::DclGlobal, }; use godot::{ - bind::{godot_api, GodotClass}, builtin::{GString, PackedStringArray}, obj::Gd, + prelude::*, }; use std::sync::Arc; +#[derive(Default)] pub struct ItemEntityDefinition { pub id: String, pub entity_definition_json: EntityDefinitionJson, @@ -57,7 +58,7 @@ impl ItemEntityDefinition { } #[derive(GodotClass)] -#[class(base=RefCounted)] +#[class(init, base=RefCounted)] pub struct DclItemEntityDefinition { pub inner: Arc, } diff --git a/lib/src/comms/adapter/archipelago.rs b/lib/src/comms/adapter/archipelago.rs index 6025ab6f5..8d510e61e 100644 --- a/lib/src/comms/adapter/archipelago.rs +++ b/lib/src/comms/adapter/archipelago.rs @@ -66,7 +66,7 @@ impl ArchipelagoManager { }; Self { - ws_peer: WebSocketPeer::new(), + ws_peer: WebSocketPeer::new_gd(), ws_url: GString::from(ws_url), state: ArchipelagoState::Connecting, player_address: ephemeral_auth_chain.signer(), @@ -124,7 +124,7 @@ impl ArchipelagoManager { match self.state.clone() { ArchipelagoState::Connecting => match ws_state { - godot::engine::web_socket_peer::State::STATE_CLOSED => { + godot::engine::web_socket_peer::State::CLOSED => { if (Instant::now() - self.last_try_to_connect).as_secs() > 1 { let ws_protocols = { let mut v = PackedStringArray::new(); @@ -138,13 +138,13 @@ impl ArchipelagoManager { self.last_try_to_connect = Instant::now(); } } - godot::engine::web_socket_peer::State::STATE_OPEN => { + godot::engine::web_socket_peer::State::OPEN => { self.state = ArchipelagoState::Connected; } _ => {} }, ArchipelagoState::Connected => match ws_state { - godot::engine::web_socket_peer::State::STATE_OPEN => { + godot::engine::web_socket_peer::State::OPEN => { let client_packet = ClientPacket { message: Some(client_packet::Message::ChallengeRequest( ChallengeRequestMessage { @@ -160,7 +160,7 @@ impl ArchipelagoManager { } }, ArchipelagoState::IdentMessageSent => match ws_state { - godot::engine::web_socket_peer::State::STATE_OPEN => { + godot::engine::web_socket_peer::State::OPEN => { while let Some((packet_length, message)) = get_next_packet(peer.clone()) { match message { server_packet::Message::ChallengeResponse(challenge_msg) => { @@ -208,7 +208,7 @@ impl ArchipelagoManager { } }, ArchipelagoState::ChallengeMessageSent => match ws_state { - godot::engine::web_socket_peer::State::STATE_OPEN => { + godot::engine::web_socket_peer::State::OPEN => { while let Some((packet_length, message)) = get_next_packet(peer.clone()) { match message { server_packet::Message::Welcome(_welcome) => { @@ -228,7 +228,7 @@ impl ArchipelagoManager { } }, ArchipelagoState::WelcomeMessageReceived => match ws_state { - godot::engine::web_socket_peer::State::STATE_OPEN => { + godot::engine::web_socket_peer::State::OPEN => { self._handle_messages(); if (Instant::now() - self.last_send_heartbeat) > HEARTBEAT_INTERVAL { let client_packet = ClientPacket { @@ -265,8 +265,8 @@ impl ArchipelagoManager { let mut peer = self.ws_peer.clone(); peer.close(); match peer.get_ready_state() { - godot::engine::web_socket_peer::State::STATE_OPEN - | godot::engine::web_socket_peer::State::STATE_CONNECTING => { + godot::engine::web_socket_peer::State::OPEN + | godot::engine::web_socket_peer::State::CONNECTING => { peer.close(); } _ => {} diff --git a/lib/src/comms/adapter/ws_room.rs b/lib/src/comms/adapter/ws_room.rs index d205c0f65..4961afbc1 100644 --- a/lib/src/comms/adapter/ws_room.rs +++ b/lib/src/comms/adapter/ws_room.rs @@ -92,7 +92,7 @@ impl WebSocketRoom { let old_time = Instant::now() - Duration::from_secs(1000); Self { - ws_peer: WebSocketPeer::new(), + ws_peer: WebSocketPeer::new_gd(), ws_url: GString::from(ws_url), state: WsRoomState::Connecting, player_address: ephemeral_auth_chain.signer(), @@ -164,7 +164,7 @@ impl WebSocketRoom { match self.state.clone() { WsRoomState::Connecting => match ws_state { - godot::engine::web_socket_peer::State::STATE_CLOSED => { + godot::engine::web_socket_peer::State::CLOSED => { if (Instant::now() - self.last_try_to_connect).as_secs() > 1 { let ws_protocols = { let mut v = PackedStringArray::new(); @@ -181,13 +181,13 @@ impl WebSocketRoom { self.signature = None; } } - godot::engine::web_socket_peer::State::STATE_OPEN => { + godot::engine::web_socket_peer::State::OPEN => { self.state = WsRoomState::Connected; } _ => {} }, WsRoomState::Connected => match ws_state { - godot::engine::web_socket_peer::State::STATE_OPEN => { + godot::engine::web_socket_peer::State::OPEN => { self._send( WsPacket { message: Some(ws_packet::Message::PeerIdentification( @@ -206,7 +206,7 @@ impl WebSocketRoom { } }, WsRoomState::IdentMessageSent => match ws_state { - godot::engine::web_socket_peer::State::STATE_OPEN => { + godot::engine::web_socket_peer::State::OPEN => { while let Some((packet_length, message)) = get_next_packet(peer.clone()) { match message { ws_packet::Message::ChallengeMessage(challenge_msg) => { @@ -261,7 +261,7 @@ impl WebSocketRoom { } }, WsRoomState::ChallengeMessageSent => match ws_state { - godot::engine::web_socket_peer::State::STATE_OPEN => { + godot::engine::web_socket_peer::State::OPEN => { while let Some((packet_length, message)) = get_next_packet(peer.clone()) { match message { ws_packet::Message::WelcomeMessage(welcome_msg) => { @@ -331,7 +331,7 @@ impl WebSocketRoom { } }, WsRoomState::WelcomeMessageReceived => match ws_state { - godot::engine::web_socket_peer::State::STATE_OPEN => { + godot::engine::web_socket_peer::State::OPEN => { self._handle_messages(); } _ => { @@ -345,8 +345,8 @@ impl WebSocketRoom { let mut peer = self.ws_peer.clone(); peer.close(); match peer.get_ready_state() { - godot::engine::web_socket_peer::State::STATE_OPEN - | godot::engine::web_socket_peer::State::STATE_CONNECTING => { + godot::engine::web_socket_peer::State::OPEN + | godot::engine::web_socket_peer::State::CONNECTING => { peer.close(); } _ => {} diff --git a/lib/src/comms/communication_manager.rs b/lib/src/comms/communication_manager.rs index 088f2197c..ee3b75f94 100644 --- a/lib/src/comms/communication_manager.rs +++ b/lib/src/comms/communication_manager.rs @@ -34,7 +34,6 @@ pub struct CommunicationManager { last_position_broadcast_index: u64, voice_chat_enabled: bool, - #[base] base: Base, } @@ -51,7 +50,7 @@ impl INode for CommunicationManager { } fn ready(&mut self) { - self.base.call_deferred("init_rs".into(), &[]); + self.base_mut().call_deferred("init_rs".into(), &[]); } fn process(&mut self, _dt: f64) { @@ -61,8 +60,9 @@ impl INode for CommunicationManager { let player_identity = DclGlobal::singleton().bind().get_player_identity(); if player_identity.bind().try_get_address().is_some() { - self.base - .call_deferred("change_adapter".into(), &[adapter_url.to_variant()]); + let var = adapter_url.to_variant(); + self.base_mut() + .call_deferred("change_adapter".into(), &[var]); } } CommsConnection::SignedLogin(signed_login) => match signed_login.poll() { @@ -85,7 +85,7 @@ impl INode for CommunicationManager { if !chats.is_empty() { let chats_variant_array = get_chat_array(chats); - self.base.emit_signal( + self.base_mut().emit_signal( "chat_message".into(), &[chats_variant_array.to_variant()], ); @@ -103,7 +103,7 @@ impl INode for CommunicationManager { if !chats.is_empty() { let chats_variant_array = get_chat_array(chats); - self.base + self.base_mut() .emit_signal("chat_message".into(), &[chats_variant_array.to_variant()]); } @@ -274,24 +274,25 @@ impl CommunicationManager { fn init_rs(&mut self) { DclGlobal::singleton().bind().get_realm().connect( "realm_changed".into(), - self.base.callable("_on_realm_changed"), + self.base().callable("_on_realm_changed"), ); let mut player_identity = DclGlobal::singleton().bind().get_player_identity(); player_identity.connect( "profile_changed".into(), - self.base.callable("_on_profile_changed"), + self.base().callable("_on_profile_changed"), ); } #[func] - fn _on_profile_changed(&mut self) { - self.base.call_deferred("_on_update_profile".into(), &[]); + fn _on_profile_changed(&mut self, _: Variant) { + self.base_mut() + .call_deferred("_on_update_profile".into(), &[]); } #[func] fn _on_realm_changed(&mut self) { - self.base + self.base_mut() .call_deferred("_on_realm_changed_deferred".into(), &[]); } @@ -461,12 +462,10 @@ impl CommunicationManager { _ => false, }; - self.base.emit_signal( + let voice_chat_enabled = self.voice_chat_enabled.to_variant(); + self.base_mut().emit_signal( "on_adapter_changed".into(), - &[ - self.voice_chat_enabled.to_variant(), - comms_fixed_adapter_gstr.to_variant(), - ], + &[voice_chat_enabled, comms_fixed_adapter_gstr.to_variant()], ); } diff --git a/lib/src/comms/voice_chat.rs b/lib/src/comms/voice_chat.rs index e56e9e3e5..b6918a750 100644 --- a/lib/src/comms/voice_chat.rs +++ b/lib/src/comms/voice_chat.rs @@ -9,7 +9,6 @@ struct VoiceChatRecorder { recording_enabled: bool, effect_capture: Option>, - #[base] base: Base, } @@ -24,7 +23,7 @@ impl IAudioStreamPlayer for VoiceChatRecorder { let frames_available = effect_capture.get_frames_available(); let stereo_data = effect_capture.get_buffer(frames_available); - self.base + self.base_mut() .emit_signal("audio".into(), &[stereo_data.to_variant()]); } } @@ -57,8 +56,9 @@ impl VoiceChatRecorder { }; self.effect_capture = bus_effect; - self.base.set_stream(AudioStreamMicrophone::new().upcast()); - self.base.set_bus("Capture".into()); + self.base_mut() + .set_stream(AudioStreamMicrophone::new_gd().upcast()); + self.base_mut().set_bus("Capture".into()); } } @@ -78,10 +78,11 @@ impl VoiceChatRecorder { if !enabled { effect_capture.clear_buffer(); - self.base.stop(); + self.base_mut().stop(); } else { - self.base.play(); + // TODO: check if the order here matters effect_capture.clear_buffer(); + self.base_mut().play(); } } } diff --git a/lib/src/content/audio.rs b/lib/src/content/audio.rs index 78d876146..2c5fa66d4 100644 --- a/lib/src/content/audio.rs +++ b/lib/src/content/audio.rs @@ -1,7 +1,7 @@ use godot::{ builtin::{meta::ToGodot, PackedByteArray, Variant}, engine::{AudioStream, AudioStreamMp3, AudioStreamOggVorbis, AudioStreamWav}, - obj::Gd, + obj::{Gd, NewGd}, }; use super::{ @@ -43,13 +43,13 @@ pub async fn load_audio( let bytes = PackedByteArray::from_vec(&bytes_vec); let audio_stream: Option> = match extension.as_str() { ".wav" => { - let mut audio_stream = AudioStreamWav::new(); + let mut audio_stream = AudioStreamWav::new_gd(); audio_stream.set_data(bytes); Some(audio_stream.upcast()) } ".ogg" => AudioStreamOggVorbis::load_from_buffer(bytes).map(|value| value.upcast()), ".mp3" => { - let mut audio_stream = AudioStreamMp3::new(); + let mut audio_stream = AudioStreamMp3::new_gd(); audio_stream.set_data(bytes); Some(audio_stream.upcast()) } diff --git a/lib/src/content/content_mapping.rs b/lib/src/content/content_mapping.rs index a7ff013ba..59a0ee014 100644 --- a/lib/src/content/content_mapping.rs +++ b/lib/src/content/content_mapping.rs @@ -41,7 +41,6 @@ impl ContentMappingAndUrl { } pub type ContentMappingAndUrlRef = Arc; - #[derive(GodotClass)] #[class(base=RefCounted)] pub struct DclContentMappingAndUrl { diff --git a/lib/src/content/content_provider.rs b/lib/src/content/content_provider.rs index d639e4f3e..6176946bc 100644 --- a/lib/src/content/content_provider.rs +++ b/lib/src/content/content_provider.rs @@ -174,7 +174,7 @@ impl INode for ContentProvider { let data = entry.promise.bind().get_data(); if let Ok(mut node_3d) = Gd::::try_from_variant(&data) { if let Some(resource_locker) = - node_3d.get_node(NodePath::from("ResourceLocker")) + node_3d.get_node_or_null(NodePath::from("ResourceLocker")) { if let Ok(resource_locker) = resource_locker.try_cast::() diff --git a/lib/src/content/gltf.rs b/lib/src/content/gltf.rs index 8551ed115..146cc6121 100644 --- a/lib/src/content/gltf.rs +++ b/lib/src/content/gltf.rs @@ -1,7 +1,6 @@ use std::{collections::HashMap, sync::Arc}; use godot::{ - bind::GodotClass, builtin::{meta::ToGodot, Dictionary, GString, Variant, VariantArray}, engine::{ animation::TrackType, @@ -10,9 +9,10 @@ use godot::{ node::ProcessMode, AnimatableBody3D, Animation, AnimationLibrary, AnimationPlayer, BaseMaterial3D, CollisionShape3D, ConcavePolygonShape3D, GltfDocument, GltfState, ImageTexture, - MeshInstance3D, Node, Node3D, NodeExt, StaticBody3D, + MeshInstance3D, Node, Node3D, StaticBody3D, }, obj::{EngineEnum, Gd, InstanceId}, + prelude::*, }; use tokio::io::{AsyncReadExt, AsyncSeekExt}; @@ -111,8 +111,8 @@ pub async fn internal_load_gltf( .await .ok_or(anyhow::Error::msg("Failed trying to get thread-safe check"))?; - let mut new_gltf = GltfDocument::new(); - let mut new_gltf_state = GltfState::new(); + let mut new_gltf = GltfDocument::new_gd(); + let mut new_gltf_state = GltfState::new_gd(); let mappings = Dictionary::from_iter( dependencies_hash @@ -169,7 +169,7 @@ pub fn post_import_process(node_to_inspect: Gd, max_size: i32) { if let Some(material) = mesh.surface_get_material(surface_index) { if let Ok(mut base_material) = material.try_cast::() { // Resize images - for ord in 0..TextureParam::TEXTURE_MAX.ord() { + for ord in 0..TextureParam::MAX.ord() { let texture_param = TextureParam::from_ord(ord); if let Some(texture) = base_material.get_texture(texture_param) { if let Ok(mut texture_image) = @@ -189,8 +189,8 @@ pub fn post_import_process(node_to_inspect: Gd, max_size: i32) { } // Set Toon - base_material.set_specular_mode(SpecularMode::SPECULAR_TOON); - base_material.set_diffuse_mode(DiffuseMode::DIFFUSE_TOON); + base_material.set_specular_mode(SpecularMode::TOON); + base_material.set_diffuse_mode(DiffuseMode::TOON); } } } @@ -364,7 +364,7 @@ fn create_colliders(node_to_inspect: Gd) { if let Some(mut parent) = static_body_3d.get_parent() { let mut new_animatable = AnimatableBody3D::new_alloc(); new_animatable.set_sync_to_physics(false); - new_animatable.set_process_mode(ProcessMode::PROCESS_MODE_DISABLED); + new_animatable.set_process_mode(ProcessMode::DISABLED); new_animatable.set_meta("dcl_col".into(), 0.to_variant()); new_animatable.set_meta("invisible_mesh".into(), invisible_mesh.to_variant()); new_animatable.set_collision_layer(0); @@ -377,13 +377,14 @@ fn create_colliders(node_to_inspect: Gd) { parent.add_child(new_animatable.clone().upcast()); parent.remove_child(static_body_3d.clone().upcast()); - for body_child in static_body_3d + for mut body_child in static_body_3d .get_children_ex() .include_internal(true) .done() .iter_shared() { static_body_3d.remove_child(body_child.clone()); + body_child.call("set_owner".into(), &[Variant::nil()]); new_animatable.add_child(body_child.clone()); if let Ok(collision_shape_3d) = body_child.try_cast::() { if let Some(shape) = collision_shape_3d.get_shape() { @@ -444,9 +445,9 @@ fn update_set_mask_colliders( node.set_collision_layer(mask as u32); node.set_collision_mask(0); if mask == 0 { - node.set_process_mode(ProcessMode::PROCESS_MODE_DISABLED); + node.set_process_mode(ProcessMode::DISABLED); } else { - node.set_process_mode(ProcessMode::PROCESS_MODE_INHERIT); + node.set_process_mode(ProcessMode::INHERIT); } } @@ -493,7 +494,7 @@ fn _duplicate_animation_resources(gltf_node: Gd) { let _ = new_animations.insert(animation_name, dup_animation); } - let mut new_animation_library = AnimationLibrary::new(); + let mut new_animation_library = AnimationLibrary::new_gd(); for new_animation in new_animations { new_animation_library.add_animation(new_animation.0, new_animation.1.cast()); } @@ -612,7 +613,7 @@ fn add_animation_from_obj(file_hash: &String, gltf_node: Gd) -> Option) -> Option) -> Option>, diff --git a/lib/src/content/texture.rs b/lib/src/content/texture.rs index 38040aaa6..deb36d637 100644 --- a/lib/src/content/texture.rs +++ b/lib/src/content/texture.rs @@ -5,13 +5,13 @@ use super::{ thread_safety::GodotSingleThreadSafety, }; use godot::{ - bind::GodotClass, builtin::{meta::ToGodot, GString, PackedByteArray, Variant, Vector2i}, engine::{ global::Error, image::CompressMode, portable_compressed_texture_2d::CompressionMode, DirAccess, Image, ImageTexture, PortableCompressedTexture2D, Texture2D, }, obj::Gd, + prelude::*, }; #[derive(GodotClass)] @@ -47,7 +47,7 @@ pub async fn load_image_texture( let bytes = PackedByteArray::from_vec(&bytes_vec); - let mut image = Image::new(); + let mut image = Image::new_gd(); let err = if infer_mime::is_png(&bytes_vec) { image.load_png_from_buffer(bytes) } else if infer_mime::is_jpeg(&bytes_vec) || infer_mime::is_jpeg2000(&bytes_vec) { @@ -104,11 +104,11 @@ pub fn create_compressed_texture(image: &mut Gd, max_size: i32) -> Gd("res://src/logic/thread_safety.gd"); + let mut temp_script = godot::engine::load::