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

refactor: restore godot 4.3 and gdext 0.1.3 #470

Closed
wants to merge 14 commits into from
Closed
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 .github/workflows/android_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.77.2
toolchain: 1.79
override: true
components: clippy, rustfmt
- name: Set up cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.77.2
toolchain: 1.79
override: true
components: llvm-tools-preview

Expand Down
Empty file.
2 changes: 1 addition & 1 deletion .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.77.2
toolchain: 1.79
override: true

- name: Set up cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.77.2
toolchain: 1.79
override: true

# Dependencies section
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.77.2
toolchain: 1.79
override: true
components: clippy, rustfmt
- run: rustup component add rustfmt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.77.2
toolchain: 1.79
override: true

- name: Set up cache
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ serde_json = { version = "1.0.92", features = ["raw_value"] }
glob = "*"
tokio = { version = "1.26.0", features = ["sync", "rt-multi-thread", "net"] }
directories = "5.0.1"
image = "0.24.9"
image = "0.25.4"
5 changes: 4 additions & 1 deletion godot/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ mono_crash.*.json
# System/tool-specific ignores
.directory
.DS_Store
*~
*~

# Decentraland ignores
/output/
6 changes: 6 additions & 0 deletions godot/assets/environment/cli_environment.tres
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ sky_material = SubResource("ProceduralSkyMaterial_6yihh")
sky = SubResource("Sky_0qr0h")
ambient_light_source = 2
ambient_light_color = Color(1, 1, 1, 1)
glow_enabled = true
glow_levels/1 = 1.0
glow_levels/2 = 1.0
glow_levels/5 = 0.0
glow_mix = 0.0
glow_hdr_threshold = 0.9
2 changes: 0 additions & 2 deletions godot/src/decentraland_components/avatar/avatar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ func try_to_set_body_shape(body_shape_hash):

var resource_locker = body_shape.get_node("ResourceLocker")
new_child.add_child(resource_locker.duplicate())

body_shape_skeleton_3d.add_child(new_child)

_add_attach_points()
Expand Down Expand Up @@ -532,7 +531,6 @@ func _attach_point_skeleton_updated():
if left_hand_idx != -1:
left_hand_position = body_shape_skeleton_3d.get_bone_global_pose(left_hand_idx)
left_hand_position.basis = left_hand_position.basis.scaled(100.0 * Vector3.ONE)

if right_hand_idx != -1:
right_hand_position = body_shape_skeleton_3d.get_bone_global_pose(right_hand_idx)
right_hand_position.basis = right_hand_position.basis.scaled(100.0 * Vector3.ONE)
Expand Down
4 changes: 4 additions & 0 deletions godot/src/test/avatar/avatar_tester_standalone.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ offset_left = 33.0
offset_top = 24.0
offset_right = 633.0
offset_bottom = 688.0
current_tab = 0

[node name="Avatars" type="Panel" parent="TabContainer"]
custom_minimum_size = Vector2(600, 600)
layout_mode = 2
metadata/_tab_index = 0

[node name="OptionButton_AvatarList" type="OptionButton" parent="TabContainer/Avatars"]
layout_mode = 0
Expand Down Expand Up @@ -90,6 +92,7 @@ text = "Render Avatar"
visible = false
custom_minimum_size = Vector2(600, 600)
layout_mode = 2
metadata/_tab_index = 1

[node name="EmoteWheel" parent="TabContainer/Emotes" node_paths=PackedStringArray("avatar_node") instance=ExtResource("3_ubmva")]
layout_mode = 1
Expand Down Expand Up @@ -154,6 +157,7 @@ grow_vertical = 2
[node name="Expression" type="PanelContainer" parent="TabContainer"]
visible = false
layout_mode = 2
metadata/_tab_index = 2

[node name="VBoxContainer" type="VBoxContainer" parent="TabContainer/Expression"]
layout_mode = 2
Expand Down
4 changes: 2 additions & 2 deletions godot/src/test/testing_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ func start():
snapshot_folder = args[snapshot_folder_index + 1]
else:
if OS.has_feature("editor"):
snapshot_folder = ProjectSettings.globalize_path("res://../tests/snapshots")
snapshot_folder = ProjectSettings.globalize_path("res://../tests/snapshots/scenes")
else:
snapshot_folder = OS.get_user_data_dir() + "/snapshot"
snapshot_folder = OS.get_user_data_dir() + "/snapshot/scenes"

if not snapshot_folder.ends_with("/"):
snapshot_folder += "/"
Expand Down
5 changes: 4 additions & 1 deletion lib/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ rustflags = ["-C", "link-args=-ObjC"]
rustflags = ["-C", "link-args=-mios-version-min=12.0 -ObjC"]

[target.aarch64-apple-ios-sim]
rustflags = ["-C", "link-args=-mios-version-min=12.0 -ObjC"]
rustflags = ["-C", "link-args=-mios-version-min=12.0 -ObjC"]

[env]
CARGO_FEATURE_CRT_STATIC = "ohyes"
18 changes: 7 additions & 11 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ publish = false
crate-type = ["cdylib"]

[dependencies]
godot = { git = "https://github.com/godot-rust/gdext", rev ="cb41673a0ab802145543a8f371abfcb1f0be10f9", features=["experimental-threads", "serde"] }
godot = { version = "0.1.3", features=["experimental-threads", "serde"] }
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0.92", features = ["raw_value"] }
tokio = { version = "1.37.0", features = ["full"] }
tokio = { version = "1.40.0", features = ["full"] }
protobuf = "3.2.0"
prost = "0.11.8"
once_cell = "1.16.0"
Expand Down Expand Up @@ -41,8 +41,8 @@ tracing-subscriber = "0.3"
poll-promise = "0.2.0"
log-panics = { version = "2", features = ["with-backtrace"]}

v8 = { version = "0.74.3", optional = true }
deno_core = { version = "0.197", optional = true }
v8 = { version = "0.105.1", default-features = false, optional = true }
deno_core = { git = "https://github.com/robtfm/deno_core", branch = "0_307_hotfix", optional = true }
uuid = { version = "1.3.0", features = ["v4"] }
fastwebsockets = { version = "0.3.1", features = ["upgrade"], optional = true }
hyper1 = { package = "hyper", version = "0.14.26", features = ["server","runtime", "http1"], optional = true }
Expand All @@ -55,7 +55,7 @@ bytes = "1.4.0"
tokio-tungstenite = "0.20.1"
futures-util = "0.3.30"

livekit = { git = "https://github.com/livekit/rust-sdks", features=["rustls-tls-webpki-roots"], optional = true, rev="8b276f9d4b98437a139e1cbe41cfda1332ce1120" }
livekit = { git = "https://github.com/robtfm/client-sdk-rust", branch="0.6-h264-false-2", features=["rustls-tls-webpki-roots"], optional = true }

taffy = "0.5.2"
tracing-test = "0.2.4"
Expand Down Expand Up @@ -83,10 +83,6 @@ use_resource_tracking = []
enable_inspector = ["use_deno", "dep:fastwebsockets", "dep:hyper1"]

[build-dependencies]
webrtc-sys-build = { git = "https://github.com/livekit/rust-sdks", optional = true, rev="8b276f9d4b98437a139e1cbe41cfda1332ce1120" }
webrtc-sys-build = { version = "0.3.5", optional = true }
prost-build = "0.11.8"
chrono = "0.4.31"

[patch."https://github.com/godot-rust/godot4-prebuilt".godot4-prebuilt]
git = "https://github.com//godot-rust/godot4-prebuilt"
rev = "bc1e77856d181c14c59d2a5cb6a7e138ea5a2b39"
chrono = "0.4.31"
16 changes: 12 additions & 4 deletions lib/android-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,28 @@ if [[ "$1" == "x86_64" ]]; then
cp target/x86_64-linux-android/release/libdclgodot.so ../godot/android/build/libs/release/x86_64/libdclgodot.so

else
# Run the specified commands
# Run the specified commands
export TARGET_CC=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android35-clang
export TARGET_CXX=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android35-clang++
export TARGET_AR=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
export RUSTY_V8_MIRROR=https://github.com/leanmendoza/rusty_v8/releases/download
export CARGO_FFMPEG_SYS_DISABLE_SIZE_T_IS_USIZE=1
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android35-clang"
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true

export CXXFLAGS="-v --target=aarch64-linux-android"
export RUSTFLAGS="-L${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/lib/aarch64-unknown-linux-musl"

# CI
export RUSTY_V8_MIRROR=https://github.com/leanmendoza/rusty_v8/releases/download
V8_BINDING_FILE_NAME=src_binding_debug_aarch64-linux-android.rs
V8_BINDING=$RUSTY_V8_MIRROR/v0.105.1/$V8_BINDING_FILE_NAME
export RUSTY_V8_SRC_BINDING_PATH=$(pwd)/target/$V8_BINDING_FILE_NAME
# download if not exists
if [ ! -f "target/$V8_BINDING_FILE_NAME" ]; then
curl -L -o target/$V8_BINDING_FILE_NAME $V8_BINDING
fi
GODOT_DIR=../godot

# Local development
# - V8 local build
# export RUSTY_V8_SRC_BINDING_PATH=/home/user/github/rusty_v8_updated/target/aarch64-linux-android/release/gn_out/src_binding.rs
Expand Down
8 changes: 4 additions & 4 deletions lib/src/avatars/avatar_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ impl DclAvatarWireFormat {

for (i, emote) in DEFAULT_EMOTES.iter().enumerate() {
if let Some(emote) = used_emotes.iter().find(|e| e.slot == i as u32) {
emotes.set(i, GString::from(emote.urn.as_str()));
emotes[i] = GString::from(emote.urn.as_str());
} else {
emotes.set(i, GString::from(*emote));
emotes[i] = GString::from(*emote);
}
}
emotes
Expand Down Expand Up @@ -156,7 +156,7 @@ impl DclAvatarWireFormat {
fn set_wearables(&mut self, wearables: PackedStringArray) {
let mut wearables_vec = Vec::new();
for i in 0..wearables.len() {
wearables_vec.push(wearables.get(i).to_string());
wearables_vec.push(wearables.get(i).as_ref().unwrap().to_string());
}
self.inner.wearables = wearables_vec;
}
Expand All @@ -172,7 +172,7 @@ impl DclAvatarWireFormat {
for i in 0..10 {
emotes_vec.push(AvatarEmote {
slot: i as u32,
urn: emotes.get(i).to_string(),
urn: emotes.get(i).as_ref().unwrap().to_string(),
});
}
self.inner.emotes = Some(emotes_vec);
Expand Down
14 changes: 5 additions & 9 deletions lib/src/comms/adapter/livekit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use livekit::{
audio_source::native::NativeAudioSource,
prelude::{AudioSourceOptions, RtcAudioSource},
},
DataPacket, DataPacketKind, RoomOptions,
DataPacket, RoomOptions,
};
use prost::Message;

Expand Down Expand Up @@ -411,7 +411,7 @@ fn spawn_livekit_task(
echo_cancellation: true,
noise_suppression: true,
auto_gain_control: true,
}, 48000, 1);
}, 48000, 1, None);
let mic_track = LocalTrack::Audio(LocalAudioTrack::create_audio_track("mic", RtcAudioSource::Native(native_source.clone())));
room.local_participant().publish_track(mic_track, TrackPublishOptions{ source: TrackSource::Microphone, ..Default::default() }).await.unwrap();

Expand Down Expand Up @@ -473,7 +473,7 @@ fn spawn_livekit_task(
livekit::track::RemoteTrack::Audio(audio) => {
let sender = sender.clone();
rt2.spawn(async move {
let mut x = livekit::webrtc::audio_stream::native::NativeAudioStream::new(audio.rtc_track());
let mut x = livekit::webrtc::audio_stream::native::NativeAudioStream::new(audio.rtc_track(), 48000, 1);

tracing::debug!("remove track from {:?}", participant.identity().0.as_str());

Expand Down Expand Up @@ -519,12 +519,8 @@ fn spawn_livekit_task(
break 'stream;
};

let kind = if outgoing.unreliable {
DataPacketKind::Lossy
} else {
DataPacketKind::Reliable
};
if let Err(e) = room.local_participant().publish_data(DataPacket { payload: outgoing.data, kind, ..Default::default() }).await {
let reliable = !outgoing.unreliable;
if let Err(e) = room.local_participant().publish_data(DataPacket { payload: outgoing.data, reliable, ..Default::default() }).await {
tracing::debug!("outgoing failed: {e}; not exiting loop though since it often fails at least once or twice at the start...");
// break 'stream;
};
Expand Down
2 changes: 1 addition & 1 deletion lib/src/dcl/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct SceneEntityId {
pub version: u16,
}

impl godot::builtin::meta::GodotConvert for SceneEntityId {
impl GodotConvert for SceneEntityId {
type Via = i32;
}

Expand Down
9 changes: 5 additions & 4 deletions lib/src/dcl/js/adaptation_layer_helper.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::dcl::scene_apis::RpcCall;
use deno_core::{anyhow::anyhow, op, Op, OpDecl, OpState};
use deno_core::{anyhow::anyhow, op2, OpDecl, OpState};
use serde::Serialize;
use std::{cell::RefCell, rc::Rc};

// list of op declarations
pub fn ops() -> Vec<OpDecl> {
vec![op_get_texture_size::DECL]
vec![op_get_texture_size()]
}

#[derive(Serialize)]
Expand All @@ -14,8 +14,9 @@ struct TextureSize {
height: f32,
}

#[op(v8)]
async fn op_get_texture_size(state: Rc<RefCell<OpState>>, src: String) -> TextureSize {
#[op2(async)]
#[serde]
async fn op_get_texture_size(state: Rc<RefCell<OpState>>, #[string] src: String) -> TextureSize {
let (sx, rx) = tokio::sync::oneshot::channel::<Result<godot::builtin::Vector2, String>>();

state
Expand Down
13 changes: 7 additions & 6 deletions lib/src/dcl/js/comms.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{cell::RefCell, rc::Rc};

use deno_core::{op, JsBuffer, Op, OpDecl, OpState};
use deno_core::{op2, JsBuffer, OpDecl, OpState};
use ethers_core::types::H160;

use crate::dcl::scene_apis::RpcCall;
Expand All @@ -12,27 +12,28 @@ pub(crate) struct InternalPendingBinaryMessages {

// list of op declarations
pub fn ops() -> Vec<OpDecl> {
vec![op_comms_send_string::DECL, op_comms_send_binary::DECL]
vec![op_comms_send_string(), op_comms_send_binary()]
}

pub(crate) const COMMS_MSG_TYPE_STRING: u8 = 1;
pub(crate) const COMMS_MSG_TYPE_BINARY: u8 = 2;

#[op]
#[op2(async)]
async fn op_comms_send_string(
state: Rc<RefCell<OpState>>,
message: String,
#[string] message: String,
) -> Result<(), anyhow::Error> {
let mut message = message.into_bytes();
message.insert(0, COMMS_MSG_TYPE_STRING);
comms_send(state, vec![message]).await?;
Ok(())
}

#[op]
#[op2(async)]
#[serde]
async fn op_comms_send_binary(
state: Rc<RefCell<OpState>>,
messages: Vec<JsBuffer>,
#[serde] messages: Vec<JsBuffer>,
) -> Result<Vec<Vec<u8>>, anyhow::Error> {
let messages = messages
.iter()
Expand Down
Loading
Loading