Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kuruk-mm committed Oct 28, 2024
1 parent 64cba25 commit 05c5bdd
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 35 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/docker_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*
${{ github.workspace }}/avatar-output/**/*
${{ github.workspace }}/scenes-output/**/*
5 changes: 3 additions & 2 deletions godot/src/tool/avatar_renderer/avatar_renderer_standalone.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
24 changes: 20 additions & 4 deletions godot/src/tool/scene_renderer/scene-test-input.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
26 changes: 12 additions & 14 deletions godot/src/tool/scene_renderer/scene_orchestor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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()
)

Expand Down
2 changes: 2 additions & 0 deletions godot/src/ui/explorer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
Expand Down
27 changes: 21 additions & 6 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand All @@ -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",
]
Expand All @@ -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(())
}

0 comments on commit 05c5bdd

Please sign in to comment.