From 05c5bdd6cc376f90c4156aeec0616873fe0af709 Mon Sep 17 00:00:00 2001 From: "Mateo \"Kuruk\" Miccino" Date: Mon, 28 Oct 2024 20:18:14 -0300 Subject: [PATCH] fixes --- .github/workflows/docker_build_test.yml | 18 ++++++------- .../avatar_renderer_standalone.gd | 5 ++-- .../tool/scene_renderer/scene-test-input.json | 24 ++++++++++++++--- .../tool/scene_renderer/scene_orchestor.gd | 26 +++++++++--------- godot/src/ui/explorer.gd | 2 ++ src/tests.rs | 27 ++++++++++++++----- 6 files changed, 67 insertions(+), 35 deletions(-) diff --git a/.github/workflows/docker_build_test.yml b/.github/workflows/docker_build_test.yml index 120f7345..4fa549bd 100644 --- a/.github/workflows/docker_build_test.yml +++ b/.github/workflows/docker_build_test.yml @@ -47,36 +47,36 @@ jobs: - name: Run avatar test run: | - mkdir -p output + mkdir -p avatars-output podman run --rm -v \ $(pwd)/tests/avatars-test-input.json:/app/avatars.json \ - -v $(pwd)/output:/app/output localhost/godot-explorer:latest + -v $(pwd)/avatars-output:/app/output localhost/godot-explorer:latest - name: Compare images with snapshots run: | cargo run -- compare-image-folders \ --snapshots tests/snapshots/avatar-image-generation/ \ - --result ${{ github.workspace }}/output/ + --result ${{ github.workspace }}/avatars-output/ - name: Run scene-rendering test run: | - rm -rf output || true - mkdir -p output + mkdir -p scenes-output podman run --rm -v \ $(pwd)/tests/scene-renderer-test-input.json:/app/scenes.json \ --env 'PRESET_ARGS="--scene-renderer --scene-input-file scenes.json"' \ - -v $(pwd)/output:/app/output localhost/godot-explorer:latest + -v $(pwd)/scenes-output:/app/output localhost/godot-explorer:latest - name: Compare images with snapshots run: | cargo run -- compare-image-folders \ --snapshots tests/snapshots/scene-image-generation/ \ - --result ${{ github.workspace }}/output/ + --result ${{ github.workspace }}/scenes-output/ - name: Upload artifacts if: success() || failure() uses: actions/upload-artifact@v4 with: - name: avatar-snapshots + name: snapshots path: | - ${{ github.workspace }}/output/**/* \ No newline at end of file + ${{ github.workspace }}/avatar-output/**/* + ${{ github.workspace }}/scenes-output/**/* \ No newline at end of file diff --git a/godot/src/tool/avatar_renderer/avatar_renderer_standalone.gd b/godot/src/tool/avatar_renderer/avatar_renderer_standalone.gd index 55235f7f..64bce3b1 100644 --- a/godot/src/tool/avatar_renderer/avatar_renderer_standalone.gd +++ b/godot/src/tool/avatar_renderer/avatar_renderer_standalone.gd @@ -13,14 +13,15 @@ var current_avatar: DclAvatarWireFormat # TODO: this can be a command line parser and get some helpers like get_string("--realm"), etc func get_params_from_cmd(): - if USE_TEST_INPUT: + var args := OS.get_cmdline_args() + + if USE_TEST_INPUT or args.has("--use-test-input"): return [ AvatarRendererHelper.AvatarFile.from_file_path( "res://src/tool/avatar_renderer/avatar-test-input.json" ) ] - var args := OS.get_cmdline_args() var avatar_data = null var avatar_in_place := args.find("--avatars") diff --git a/godot/src/tool/scene_renderer/scene-test-input.json b/godot/src/tool/scene_renderer/scene-test-input.json index 60506603..18f71279 100644 --- a/godot/src/tool/scene_renderer/scene-test-input.json +++ b/godot/src/tool/scene_renderer/scene-test-input.json @@ -1,13 +1,29 @@ { - "realmUrl": "https://peer.decentraland.org", + "realmUrl": "https://sdk-team-cdn.decentraland.org/ipfs/goerli-plaza-main-latest", "defaultPayload": { "coords": "9,-9", - "destPath": "output/test-scene-rendering-$index-$coords.glb", - "sceneDistance": 0 + "width": 512, + "height": 512, + "destPath": "output/test-scene-rendering-$index-$coords.png", + "sceneDistance": 0, + "camera": { + "position": { + "x": 8, + "y": 20, + "z": -8 + }, + "target": { + "x": 8, + "y": 0, + "z": -8 + }, + "orthoSize": 20, + "projection": "ortho" + } }, "payload": [ { - "coords": "0,0" + "coords": "72,-10" } ] } \ No newline at end of file diff --git a/godot/src/tool/scene_renderer/scene_orchestor.gd b/godot/src/tool/scene_renderer/scene_orchestor.gd index daee769a..d36a1f20 100644 --- a/godot/src/tool/scene_renderer/scene_orchestor.gd +++ b/godot/src/tool/scene_renderer/scene_orchestor.gd @@ -24,26 +24,24 @@ var test_camera_tune_base_position: Vector3 var are_all_scene_loaded: bool = false -@onready var scene_preview = %AvatarPreview - - # TODO: this can be a command line parser and get some helpers like get_string("--realm"), etc func get_params_from_cmd(): + var args := OS.get_cmdline_args() var scene_data = null - if USE_TEST_INPUT: + var camera_tune := args.find("--test-camera-tune") != -1 + + if USE_TEST_INPUT or args.has("--use-test-input"): print("scene-renderer: using test input") scene_data = SceneRendererInputHelper.SceneInputFile.from_file_path( "res://src/tool/scene_renderer/scene-test-input.json" ) + else: + var scene_in_place := args.find("--scene-input-file") - var args := OS.get_cmdline_args() - var scene_in_place := args.find("--scene-input-file") - var camera_tune := args.find("--test-camera-tune") != -1 - - if scene_in_place != -1 and args.size() > scene_in_place + 1 and scene_data == null: - var file_path: String = args[scene_in_place + 1] - print("scene-renderer: using input file from command line", file_path) - scene_data = SceneRendererInputHelper.SceneInputFile.from_file_path(file_path) + if scene_in_place != -1 and args.size() > scene_in_place + 1 and scene_data == null: + var file_path: String = args[scene_in_place + 1] + print("scene-renderer: using input file from command line", file_path) + scene_data = SceneRendererInputHelper.SceneInputFile.from_file_path(file_path) return [scene_data, camera_tune] @@ -68,10 +66,10 @@ func _ready(): Global.realm.realm_changed.connect(self.on_realm_changed) Global.realm.async_set_realm(scenes_to_process.realm_url) - print( + prints( "scene-renderer: realm", scenes_to_process.realm_url, - " - scenes number: ", + "- scenes number:", scenes_to_process.scenes.size() ) diff --git a/godot/src/ui/explorer.gd b/godot/src/ui/explorer.gd index c0d27a2b..2669eb8c 100644 --- a/godot/src/ui/explorer.gd +++ b/godot/src/ui/explorer.gd @@ -187,6 +187,8 @@ func _ready(): ui_root.grab_focus.call_deferred() if OS.get_cmdline_args().has("--scene-renderer"): + prints("load scene_orchestor") + ui_root.hide() var scene_renderer_orchestor = ( load("res://src/tool/scene_renderer/scene_orchestor.tscn").instantiate() ) diff --git a/src/tests.rs b/src/tests.rs index 28d64daf..06b8ca46 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -13,9 +13,16 @@ pub fn test_godot_tools( println!("=== running godot avatar generation ==="); + let avatar_output = Path::new("./godot/output/"); + if !avatar_output.exists() { + std::fs::create_dir_all(&avatar_output)?; + } + let extra_args = [ "--rendering-driver", "opengl3", + "--rendering-method", + "gl_compatibility", "--avatar-renderer", "--use-test-input", ] @@ -36,18 +43,23 @@ pub fn test_godot_tools( )?; // Move files - let avatar_output = Path::new("./godot/output/").canonicalize()?; - move_dir_recursive(&avatar_output, &comparison_folder)?; + move_dir_recursive(&avatar_output.canonicalize()?, &comparison_folder)?; // Images comparison - compare_images_folders(&avatar_snapshot_folder, &comparison_folder, 0.995) + compare_images_folders(&avatar_snapshot_folder, &comparison_folder, 0.90) .map_err(|e| anyhow::anyhow!(e))?; - println!("=== running scene generation ==="); + println!("=== running scene generation ==="); + let scene_output = Path::new("./godot/output/"); + if !scene_output.exists() { + std::fs::create_dir_all(&scene_output)?; + } let extra_args = [ "--rendering-driver", "opengl3", + "--rendering-method", + "gl_compatibility", "--scene-renderer", "--use-test-input", ] @@ -72,8 +84,11 @@ pub fn test_godot_tools( let comparison_folder = scene_renderer_snapshot_folder.join("comparison"); // Move files - let avatar_output = Path::new("./godot/output/").canonicalize()?; - move_dir_recursive(&avatar_output, &comparison_folder)?; + move_dir_recursive(&scene_output.canonicalize()?, &comparison_folder)?; + + // Images comparison + compare_images_folders(&scene_renderer_snapshot_folder, &comparison_folder, 0.90) + .map_err(|e| anyhow::anyhow!(e))?; Ok(()) }