From 15b944cd8a467db0772d575d4ac6742061348270 Mon Sep 17 00:00:00 2001 From: Lean Mendoza Date: Fri, 1 Nov 2024 21:12:10 +0100 Subject: [PATCH] fix: avatar rendering and scene crashes doesn't kill the scene anymore (#479) * fix: avatar rendering and scene crashes doesn't kill the scene anymore cherry-pick fixes from bump * add profile fetcher from avatar test standalone * fix format&lint --- .../avatar/wearables/wearables.gd | 39 +- godot/src/test/avatar/avatar_list.json | 608 +++++++++++++++++- .../test/avatar/avatar_tester_standalone.gd | 83 ++- .../test/avatar/avatar_tester_standalone.tscn | 35 +- .../avatar_renderer_standalone.gd | 9 + lib/src/dcl/js/mod.rs | 35 +- 6 files changed, 757 insertions(+), 52 deletions(-) diff --git a/godot/src/decentraland_components/avatar/wearables/wearables.gd b/godot/src/decentraland_components/avatar/wearables/wearables.gd index 4b984645f..66b6f9cf5 100644 --- a/godot/src/decentraland_components/avatar/wearables/wearables.gd +++ b/godot/src/decentraland_components/avatar/wearables/wearables.gd @@ -392,7 +392,7 @@ class Categories: ] const UPPER_BODY_DEFAULT_HIDES: PackedStringArray = [HANDS] - const REQUIRED_CATEGORIES: PackedStringArray = [EYES, MOUTH] + const REQUIRED_CATEGORIES: PackedStringArray = [EYES, MOUTH, EYEBROWS] const MAIN_CATEGORIES: Dictionary = { BODY_SHAPE: [BODY_SHAPE], @@ -454,13 +454,17 @@ static func can_equip(wearable: DclItemEntityDefinition, body_shape_id: String) static func compose_hidden_categories( - body_shape_id: String, force_render: PackedStringArray, wearables_by_category: Dictionary + body_shape_id: String, + force_render: PackedStringArray, + wearables_by_category: Dictionary, + skip_compute_hidden: bool = false ) -> Array: - var result: Array = [] - var previously_hidden: Dictionary = {} + var hidden: Array = [] for priority_category in Categories.HIDING_PRIORITY: - previously_hidden[priority_category] = [] + if not skip_compute_hidden: + if hidden.has(priority_category): + continue var wearable: DclItemEntityDefinition = wearables_by_category.get(priority_category) if wearable == null: @@ -471,19 +475,13 @@ static func compose_hidden_categories( continue for category_to_hide in current_hides_list: - var hidden_categories = previously_hidden.get(category_to_hide) - if hidden_categories != null and hidden_categories.has(priority_category): - continue - - previously_hidden[priority_category].push_back(category_to_hide) - - if force_render.has(category_to_hide): - continue + if not hidden.has(category_to_hide): + hidden.push_back(category_to_hide) - if not result.has(category_to_hide): - result.push_back(category_to_hide) + for category in force_render: + hidden.erase(category) - return result + return hidden static func get_wearable_facial_hashes( @@ -562,12 +560,17 @@ static func get_curated_wearable_list( else: printerr("invalid wearable ", wearable_id) - ret.hidden_categories = compose_hidden_categories( + var unused_wearables = compose_hidden_categories( body_shape_id, force_render, ret.wearables_by_category ) - for hide_category in ret.hidden_categories: + for hide_category in unused_wearables: if ret.wearables_by_category.has(hide_category): ret.wearables_by_category.erase(hide_category) + + ret.hidden_categories = compose_hidden_categories( + body_shape_id, force_render, ret.wearables_by_category, true + ) + ret.need_to_fetch = set_fallback_for_missing_needed_categories( body_shape_id, ret.wearables_by_category, ret.hidden_categories ) diff --git a/godot/src/test/avatar/avatar_list.json b/godot/src/test/avatar/avatar_list.json index 55f561c6e..b87b3e7b0 100644 --- a/godot/src/test/avatar/avatar_list.json +++ b/godot/src/test/avatar/avatar_list.json @@ -10,7 +10,31 @@ "urn:decentraland:off-chain:base-avatars:keanu_hair", "urn:decentraland:off-chain:base-avatars:granpa_beard" ], - "forceRender": [] + "forceRender": [], + "eyes": { + "color": { + "r": 0.22265625, + "g": 0.484375, + "b": 0.69140625, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.12156863510608673, + "g": 0.08627451211214066, + "b": 0.07058823853731155, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.32156863808631897, + "g": 0.17254900932312012, + "b": 0.10980391502380371, + "a": 1 + } + } }, { "ref": "ForceRender and Skin", @@ -55,7 +79,31 @@ "urn:decentraland:matic:collections-v2:0x0dc28547b88100eb6b3f3890f0501607aa5dd6be:0:3202", "urn:decentraland:matic:collections-v2:0xbf83965191065487db0644812649d5238435c723:1:105312291668557186697918027683670432318895095400549111254310978934" ], - "forceRender": [] + "forceRender": [], + "eyes": { + "color": { + "r": 0.22265625, + "g": 0.484375, + "b": 0.69140625, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.12156863510608673, + "g": 0.08627451211214066, + "b": 0.07058823853731155, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.32156863808631897, + "g": 0.17254900932312012, + "b": 0.10980391502380371, + "a": 1 + } + } }, { "ref": "Test A", @@ -71,7 +119,31 @@ "urn:decentraland:ethereum:collections-v1:cybermike_cybersoldier_set:cybersoldier_leggings_lower_body:34", "urn:decentraland:ethereum:collections-v1:cybermike_cybersoldier_set:cybersoldier_torso_upper_body:35" ], - "forceRender": [] + "forceRender": [], + "eyes": { + "color": { + "r": 0.22265625, + "g": 0.484375, + "b": 0.69140625, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.12156863510608673, + "g": 0.08627451211214066, + "b": 0.07058823853731155, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.32156863808631897, + "g": 0.17254900932312012, + "b": 0.10980391502380371, + "a": 1 + } + } }, { "ref": "Test B", @@ -90,7 +162,31 @@ "urn:decentraland:ethereum:collections-v1:halloween_2020:hwn_2020_ghostblaster_tiara:3855", "urn:decentraland:matic:collections-v2:0xded1e53d7a43ac1844b66c0ca0f02627eb42e16d:3:315936875005671560093754083051011296956685286201647333762932932647" ], - "forceRender": [] + "forceRender": [], + "eyes": { + "color": { + "r": 0.22265625, + "g": 0.484375, + "b": 0.69140625, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.12156863510608673, + "g": 0.08627451211214066, + "b": 0.07058823853731155, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.32156863808631897, + "g": 0.17254900932312012, + "b": 0.10980391502380371, + "a": 1 + } + } }, { "ref": "Female", @@ -103,7 +199,31 @@ "urn:decentraland:off-chain:base-avatars:black_sun_glasses", "urn:decentraland:off-chain:base-avatars:f_mouth_05" ], - "forceRender": [] + "forceRender": [], + "eyes": { + "color": { + "r": 0.22265625, + "g": 0.484375, + "b": 0.69140625, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.12156863510608673, + "g": 0.08627451211214066, + "b": 0.07058823853731155, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.32156863808631897, + "g": 0.17254900932312012, + "b": 0.10980391502380371, + "a": 1 + } + } }, { "ref": "MarianoPlayground - pants not present", @@ -149,7 +269,31 @@ "urn:decentraland:matic:collections-v2:0x2113853d20f7b6d08fa756c294fb6f36e9108b22:0:26", "urn:decentraland:matic:collections-v2:0x2929bbb4f18b40ac52a7f0b91629c695e3f96504:2:210624583337114373395836055367340864637790190801098222508621955096" ], - "forceRender": [] + "forceRender": [], + "eyes": { + "color": { + "r": 0.22265625, + "g": 0.484375, + "b": 0.69140625, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.12156863510608673, + "g": 0.08627451211214066, + "b": 0.07058823853731155, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.32156863808631897, + "g": 0.17254900932312012, + "b": 0.10980391502380371, + "a": 1 + } + } }, { "ref": "MarianoPlayground - pants not present v3", @@ -164,7 +308,31 @@ "urn:decentraland:matic:collections-v2:0xbf83965191065487db0644812649d5238435c723:4:421249166674228746791672110734681729275580381602196445017243911444", "urn:decentraland:matic:collections-v2:0xbf83965191065487db0644812649d5238435c723:7:737186041679900306885426193785693026232265667803843778780176844143" ], - "forceRender": [] + "forceRender": [], + "eyes": { + "color": { + "r": 0.22265625, + "g": 0.484375, + "b": 0.69140625, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.12156863510608673, + "g": 0.08627451211214066, + "b": 0.07058823853731155, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.32156863808631897, + "g": 0.17254900932312012, + "b": 0.10980391502380371, + "a": 1 + } + } }, { "ref": "MarianoPlayground - feet not present", @@ -177,7 +345,31 @@ "urn:decentraland:off-chain:base-avatars:f_eyes_08", "urn:decentraland:off-chain:base-avatars:blue_star_earring" ], - "forceRender": [] + "forceRender": [], + "eyes": { + "color": { + "r": 0.22265625, + "g": 0.484375, + "b": 0.69140625, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.12156863510608673, + "g": 0.08627451211214066, + "b": 0.07058823853731155, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.32156863808631897, + "g": 0.17254900932312012, + "b": 0.10980391502380371, + "a": 1 + } + } }, { "ref": "MarianoPlayground - green shadow not present", @@ -200,7 +392,31 @@ "urn:decentraland:matic:collections-v2:0x07d03ca2c27f29ec3c4cf3afad857c5af13f61cd:7:737186041679900306885426193785693026232265667803843778780176842874", "urn:decentraland:matic:collections-v2:0xc65c3e0dd85d993678e02a1407be7d804fae4667:2:210624583337114373395836055367340864637790190801098222508621955084" ], - "forceRender": [] + "forceRender": [], + "eyes": { + "color": { + "r": 0.22265625, + "g": 0.484375, + "b": 0.69140625, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.12156863510608673, + "g": 0.08627451211214066, + "b": 0.07058823853731155, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.32156863808631897, + "g": 0.17254900932312012, + "b": 0.10980391502380371, + "a": 1 + } + } }, { "ref": "With lower body not hidden", @@ -217,7 +433,379 @@ "urn:decentraland:matic:collections-v2:0x3ec01a62bbbad1b49a8a51b86d4d7eeffa0775c0:1:105312291668557186697918027683670432318895095400549111254310977684", "urn:decentraland:matic:collections-v2:0x3338d5294e0312dd39f77a725a65e1ab8f009fd0:0:328" ], - "forceRender": [] + "forceRender": [], + "eyes": { + "color": { + "r": 0.22265625, + "g": 0.484375, + "b": 0.69140625, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.12156863510608673, + "g": 0.08627451211214066, + "b": 0.07058823853731155, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.32156863808631897, + "g": 0.17254900932312012, + "b": 0.10980391502380371, + "a": 1 + } + } + }, + { + "ref": "mati test A 2024-09-26", + "bodyShape": "urn:decentraland:off-chain:base-avatars:BaseMale", + "wearables": [ + "urn:decentraland:off-chain:base-avatars:mouth_03", + "urn:decentraland:off-chain:base-avatars:f_eyebrows_01", + "urn:decentraland:off-chain:base-avatars:eyes_00", + "urn:decentraland:matic:collections-v2:0xb854bf4d15be8e1f9b38e8b6af7d3283b81edfd8:1:105312291668557186697918027683670432318895095400549111254310977575", + "urn:decentraland:matic:collections-v2:0x021159005cda2bbaf591c061a69d890725804855:0:81", + "urn:decentraland:matic:collections-v2:0xd99c0320d8d4d36a77740b13439059dbc7446835:4:421249166674228746791672110734681729275580381602196445017243910162", + "urn:decentraland:matic:collections-v2:0x26ea2f6a7273a2f28b410406d1c13ff7d4c9a162:5:526561458342785933489590138418352161594475477002745556271554889477", + "urn:decentraland:matic:collections-v2:0x378cd34662fcd2311743fad74b5a196ad0cb2544:0:226", + "urn:decentraland:matic:collections-v2:0xded1e53d7a43ac1844b66c0ca0f02627eb42e16d:6:631873750011343120187508166102022593913370572403294667525865865533", + "urn:decentraland:matic:collections-v2:0xded1e53d7a43ac1844b66c0ca0f02627eb42e16d:0:439", + "urn:decentraland:matic:collections-v2:0xf16ff41128b298304b761b49c1c56580972ada32:0:10", + "urn:decentraland:off-chain:base-avatars:black_glove", + "urn:decentraland:matic:collections-v2:0x26ea2f6a7273a2f28b410406d1c13ff7d4c9a162:0:1603", + "urn:decentraland:off-chain:base-avatars:full_beard" + ], + "forceRender": [ + "facial_hair" + ], + "eyes": { + "color": { + "r": 0.22265625, + "g": 0.484375, + "b": 0.69140625, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.12156863510608673, + "g": 0.08627451211214066, + "b": 0.07058823853731155, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.32156863808631897, + "g": 0.17254900932312012, + "b": 0.10980391502380371, + "a": 1 + } + } + }, + { + "ref": "mati test B 2024-09-26", + "bodyShape": "urn:decentraland:off-chain:base-avatars:BaseMale", + "wearables": [ + "urn:decentraland:off-chain:base-avatars:sport_jacket", + "urn:decentraland:off-chain:base-avatars:corduroygreenpants", + "urn:decentraland:off-chain:base-avatars:citycomfortableshoes", + "urn:decentraland:off-chain:base-avatars:modern_hair", + "urn:decentraland:off-chain:base-avatars:mouth_04", + "urn:decentraland:off-chain:base-avatars:eyebrows_01", + "urn:decentraland:off-chain:base-avatars:eyes_01", + "urn:decentraland:off-chain:base-avatars:piratepatch", + "urn:decentraland:off-chain:base-avatars:red_bandana" + ], + "forceRender": [], + "eyes": { + "color": { + "r": 0.37254902720451355, + "g": 0.2235294133424759, + "b": 0.19607843458652496, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.3977261781692505, + "g": 0.30723604559898376, + "b": 0.09609238803386688, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.9490196108818054, + "g": 0.7607843279838562, + "b": 0.6470588445663452, + "a": 1 + } + } + }, + { + "ref": "0x51a514d3f28ea19775e811fc09396e808394bd12", + "bodyShape": "urn:decentraland:off-chain:base-avatars:BaseMale", + "wearables": [ + "urn:decentraland:matic:collections-v2:0xee77b0a104cd6db1bbbcfa2f13076f234647c017:0:15", + "urn:decentraland:matic:collections-v2:0xee77b0a104cd6db1bbbcfa2f13076f234647c017:2:210624583337114373395836055367340864637790190801098222508621955075", + "urn:decentraland:matic:collections-v2:0xee77b0a104cd6db1bbbcfa2f13076f234647c017:1:105312291668557186697918027683670432318895095400549111254310977553", + "urn:decentraland:off-chain:base-avatars:eyebrows_03", + "urn:decentraland:off-chain:base-avatars:eyes_02", + "urn:decentraland:off-chain:base-avatars:f_mouth_03" + ], + "forceRender": [ + "mask", + "tiara", + "earring", + "feet", + "hat", + "hair" + ], + "eyes": { + "color": { + "r": 0.125490203499794, + "g": 0.7019608020782471, + "b": 0.9647058844566345 + } + }, + "hair": { + "color": { + "r": 1, + "g": 0.7450980544090271, + "b": 0.1568627506494522 + } + }, + "skin": { + "color": { + "r": 1, + "g": 0.8497498035430908, + "b": 0 + } + } + }, + { + "ref": "0xa9272ec23574eb5846a1bc752bc19770beadfae5", + "bodyShape": "urn:decentraland:off-chain:base-avatars:BaseMale", + "wearables": [ + "urn:decentraland:off-chain:base-avatars:black_jacket", + "urn:decentraland:off-chain:base-avatars:f_african_leggins", + "urn:decentraland:off-chain:base-avatars:curly_hair", + "urn:decentraland:off-chain:base-avatars:eyebrows_00", + "urn:decentraland:off-chain:base-avatars:eyes_00", + "urn:decentraland:off-chain:base-avatars:f_mouth_00" + ], + "forceRender": [], + "eyes": { + "color": { + "r": 0, + "g": 0, + "b": 0 + } + }, + "hair": { + "color": { + "r": 0.6000000238418579, + "g": 0.23999999463558197, + "b": 0.23999999463558197 + } + }, + "skin": { + "color": { + "r": 0, + "g": 1, + "b": 0.26315808296203613 + } + } + }, + { + "ref": "with emissive", + "bodyShape": "urn:decentraland:off-chain:base-avatars:BaseMale", + "wearables": [ + "urn:decentraland:matic:collections-v2:0xe91f0faf04bcb2c1c25ac9459fb90228be8735e7:0:17", + "urn:decentraland:matic:collections-v2:0xa780096910ce7fc4663ad3a954b34e2d842f0374:0:7", + "urn:decentraland:matic:collections-v2:0x08dc1667db12675e8cfb6e58ba30fe865d8c4bb6:0:8", + "urn:decentraland:matic:collections-v2:0x300c8583c5f18fd3f2bcc251ce913394a8c5d8f9:0:80", + "urn:decentraland:matic:collections-v2:0x768c1027b1f1a452ecb8dab017a1e630a75f0d30:9:947810625017014680281262249153033890870055858604942001288798799313", + "urn:decentraland:off-chain:base-avatars:eyebrows_00", + "urn:decentraland:off-chain:base-avatars:eyes_00", + "urn:decentraland:off-chain:base-avatars:f_mouth_04" + ], + "forceRender": [ + "helmet" + ], + "eyes": { + "color": { + "r": 0.052996814250946045, + "g": 0.5021452307701111, + "b": 0.025209957733750343, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.009899990633130074, + "g": 0.9900000095367432, + "b": 0.23136761784553528, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.8666666746139526, + "g": 0.6941176652908325, + "b": 0.5607843399047852, + "a": 1 + } + } + }, + { + "ref": "without emissive", + "bodyShape": "urn:decentraland:off-chain:base-avatars:BaseFemale", + "wearables": [ + "urn:decentraland:off-chain:base-avatars:f_simple_yellow_tshirt", + "urn:decentraland:off-chain:base-avatars:f_short_blue_jeans", + "urn:decentraland:off-chain:base-avatars:pink_sleepers", + "urn:decentraland:off-chain:base-avatars:cornrows", + "urn:decentraland:off-chain:base-avatars:green_stone_tiara", + "urn:decentraland:off-chain:base-avatars:f_mouth_04" + ], + "forceRender": [], + "eyes": { + "color": { + "r": 0.052996814250946045, + "g": 0.5021452307701111, + "b": 0.025209957733750343, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.009899990633130074, + "g": 0.9900000095367432, + "b": 0.23136761784553528, + "a": 1 + } + }, + "skin": { + "color": { + "r": 0.8666666746139526, + "g": 0.6941176652908325, + "b": 0.5607843399047852, + "a": 1 + } + } + }, + { + "ref": "without emissive v2", + "bodyShape": "urn:decentraland:off-chain:base-avatars:BaseFemale", + "skin": { + "color": { + "r": 0.800000011920929, + "g": 0.6078431606292725, + "b": 0.46666666865348816, + "a": 1 + } + }, + "hair": { + "color": { + "r": 0.48235294222831726, + "g": 0.2823529541492462, + "b": 0.0941176488995552, + "a": 1 + } + }, + "eyes": { + "color": { + "r": 0.125490203499794, + "g": 0.7019608020782471, + "b": 0.9647058844566345, + "a": 1 + } + }, + "wearables": [ + "urn:decentraland:off-chain:base-avatars:f_blue_jacket", + "urn:decentraland:off-chain:base-avatars:f_capris", + "urn:decentraland:off-chain:base-avatars:ruby_blue_loafer", + "urn:decentraland:off-chain:base-avatars:pony_tail", + "urn:decentraland:off-chain:base-avatars:pearls_earring", + "urn:decentraland:off-chain:base-avatars:f_mouth_05" + ] + }, + { + "ref": "bafkreidyaysvsyof3f2s2k7ufmhkksm6lsawebg7bcdqlnzimwumu5qz7e", + "bodyShape": "urn:decentraland:off-chain:base-avatars:BaseMale", + "wearables": [ + "urn:decentraland:matic:collections-v2:0x4ea1cfe9e8ca641fbe362469f79029a0eaa6a996:0:1", + "urn:decentraland:matic:collections-v2:0xded1e53d7a43ac1844b66c0ca0f02627eb42e16d:7:737186041679900306885426193785693026232265667803843778780176842775", + "urn:decentraland:matic:collections-v2:0x80ec22f149a3f4727ba1ab91ddcefe9860ed4808:0:409", + "urn:decentraland:matic:collections-v2:0x3f0ba00d6a98db91f92e5e04accc9735a6fc562d:3:315936875005671560093754083051011296956685286201647333762932932618", + "urn:decentraland:matic:collections-v2:0x8cc5f22eec7b03c6a183499d7bb50679097ddfb6:0:10", + "urn:decentraland:matic:collections-v2:0x083230402677cad61d7a0cc040dc8a08cfeb809e:6:631873750011343120187508166102022593913370572403294667525865865251", + "urn:decentraland:matic:collections-v2:0xd1b84ae24b95f290211a6da61cde8d1b2647c711:0:5", + "urn:decentraland:matic:collections-v2:0xbad1c910568230c92c223b55564cf689928ec1b6:0:4", + "urn:decentraland:matic:collections-v2:0x5b7bd3e12f7d1461fc0ad370cd12402049b4b0d9:0:25", + "urn:decentraland:matic:collections-v2:0x324cb2c654be51c6ad6c76a3e022cabe49cc4e46:4:421249166674228746791672110734681729275580381602196445017243910158", + "urn:decentraland:off-chain:base-avatars:eyebrows_06", + "urn:decentraland:ethereum:collections-v1:halloween_2020:hwn_2020_cat_eyes:409", + "urn:decentraland:ethereum:collections-v1:halloween_2020:hwn_2020_pumpkin_mouth:394", + "urn:decentraland:matic:collections-v2:0xcbd17d94f5be12fff27566c23888d6936b8e70b8:6:631873750011343120187508166102022593913370572403294667525865865262" + ], + "forceRender": [ + "eyewear", + "hands_wear", + "facial_hair" + ] + }, + { + "description": "", + "avatar": { + "bodyShape": "urn:decentraland:off-chain:base-avatars:BaseMale", + "snapshots": { + "body": "https://peer-ec2.decentraland.org/content/contents/bafkreiegje2flk3yiyu5qelqiyx3uchkvvlegurmec36nbp5gz2pzwklny", + "face256": "https://peer-ec2.decentraland.org/content/contents/bafkreicbzfziozcirg5b4cxvhul67kzgl6grmhsa4zdrrpa2ttrierimgy" + }, + "eyes": { + "color": { + "r": 0.37109375, + "g": 0.22265625, + "b": 0.1953125 + } + }, + "hair": { + "color": { + "r": 0.234375, + "g": 0.12890625, + "b": 0.04296875 + } + }, + "skin": { + "color": { + "r": 0.94921875, + "g": 0.76171875, + "b": 0.6484375 + } + }, + "emotes": [], + "wearables": [ + "urn:decentraland:off-chain:base-avatars:eyes_00", + "urn:decentraland:off-chain:base-avatars:eyebrows_00", + "urn:decentraland:off-chain:base-avatars:mouth_00", + "urn:decentraland:off-chain:base-avatars:casual_hair_01", + "urn:decentraland:off-chain:base-avatars:beard", + "urn:decentraland:off-chain:base-avatars:sneakers", + "urn:decentraland:matic:collections-v2:0xd98aeb263b7709a8954ac8cc3c488494016cf785:0:12329" + ] + }, + "hasClaimedName": false, + "name": "Guest#ce46", + "tutorialStep": 0, + "version": 974, + "userId": "0xdb85ed07980d17a0e890af48f15e92199879ce46", + "ethAddress": "0xdb85ed07980d17a0e890af48f15e92199879ce46" } ], "emotes": [ diff --git a/godot/src/test/avatar/avatar_tester_standalone.gd b/godot/src/test/avatar/avatar_tester_standalone.gd index 0fc63e699..c6ac3bf43 100644 --- a/godot/src/test/avatar/avatar_tester_standalone.gd +++ b/godot/src/test/avatar/avatar_tester_standalone.gd @@ -11,13 +11,26 @@ var avatar_list: Array = [] @onready var line_edit_custom = $TabContainer/Emotes/LineEdit_Custom @onready var option_button_avatar_list = $TabContainer/Avatars/OptionButton_AvatarList +@onready var spinner = $Spinner +@onready var line_edit_profile_entity = $TabContainer/Avatars/LineEdit_ProfileEntity + func _ready(): + spinner.hide() load_avatar_list() avatar.avatar_loaded.connect(self._on_avatar_loaded) option_button_avatar_list.selected = -1 option_button_avatar_list.text = "Select an avatar" + # Visual enhance + var viewport: Viewport = sub_viewport_container.subviewport.get_viewport() + viewport.use_debanding = true + viewport.scaling_3d_scale = 2.0 + RenderingServer.viewport_set_msaa_3d( + viewport.get_viewport_rid(), RenderingServer.VIEWPORT_MSAA_8X + ) + RenderingServer.screen_space_roughness_limiter_set_active(true, 4.0, 1.0) + func load_avatar_list(): var file = FileAccess.open("res://src/test/avatar/avatar_list.json", FileAccess.READ) @@ -32,7 +45,7 @@ func load_avatar_list(): avatar_list = json_value.get("avatars", []) for avatar_i in avatar_list.size(): - option_button_avatar_list.add_item(avatar_list[avatar_i].ref, avatar_i) + option_button_avatar_list.add_item(avatar_list[avatar_i].get("ref", "no_ref"), avatar_i) func download_wearable(id: String): @@ -105,14 +118,32 @@ func _on_button_clear_pressed(): func _on_option_button_avatar_list_item_selected(index): var avatar_i = option_button_avatar_list.get_item_id(index) + _async_render_avatar(avatar_list[avatar_i]) + + +func _async_render_avatar(avatar_dict: Dictionary) -> void: var profile: DclUserProfile = DclUserProfile.new() var avatar_wf: DclAvatarWireFormat = profile.get_avatar() - avatar_wf.set_wearables(PackedStringArray(avatar_list[avatar_i].wearables)) - avatar_wf.set_force_render(avatar_list[avatar_i].forceRender) - avatar_wf.set_body_shape(avatar_list[avatar_i].bodyShape) + avatar_wf.set_wearables(PackedStringArray(avatar_dict.wearables)) + avatar_wf.set_force_render(avatar_dict.get("forceRender", [])) + avatar_wf.set_body_shape(avatar_dict.bodyShape) + + var skin_color = avatar_dict.get("skin", {}).get("color", {}) + var eyes_color = avatar_dict.get("eye", {}).get("color", {}) + var hair_color = avatar_dict.get("hair", {}).get("color", {}) + + skin_color = Color(skin_color.get("r", 0.8), skin_color.get("g", 0.8), skin_color.get("b", 0.8)) + eyes_color = Color(eyes_color.get("r", 0.8), eyes_color.get("g", 0.8), eyes_color.get("b", 0.8)) + hair_color = Color(hair_color.get("r", 0.8), hair_color.get("g", 0.8), hair_color.get("b", 0.8)) + avatar_wf.set_eyes_color(eyes_color) + avatar_wf.set_hair_color(hair_color) + avatar_wf.set_skin_color(skin_color) + + spinner.show() await avatar.async_update_avatar(avatar_wf, "") + spinner.hide() func _on_button_download_wearables_pressed(): @@ -125,3 +156,47 @@ func _on_button_copy_wearable_data_pressed(): func _on_button_refresh_pressed(): _on_option_button_avatar_list_item_selected(option_button_avatar_list.selected) + + +# gdlint:ignore = async-function-name +func _on_button_fetch_pressed(): + var avatars_fetched = null + spinner.show() + + if line_edit_profile_entity.text.begins_with("0x"): + var address = line_edit_profile_entity.text + var url = "https://peer.decentraland.org/lambdas/profiles/" + address + var promise: Promise = Global.http_requester.request_json( + url, HTTPClient.METHOD_GET, "", {} + ) + var response = await PromiseUtils.async_awaiter(promise) + + if response is PromiseError: + printerr("Error while fetching profile " + url, " reason: ", response.get_error()) + spinner.hide() + return + + var json: Dictionary = response.get_string_response_as_json() + avatars_fetched = json.get("avatars", []) + elif line_edit_profile_entity.text.begins_with("bafk"): + var url = "https://peer.decentraland.org/content/contents/" + line_edit_profile_entity.text + var promise: Promise = Global.http_requester.request_json( + url, HTTPClient.METHOD_GET, "", {} + ) + var response = await PromiseUtils.async_awaiter(promise) + + if response is PromiseError: + printerr("Error while fetching entity " + url, " reason: ", response.get_error()) + spinner.hide() + return + + var json: Dictionary = response.get_string_response_as_json() + avatars_fetched = json.get("metadata", {}).get("avatars", []) + + if avatars_fetched.is_empty(): + printerr("no avatars found") + spinner.hide() + return + + spinner.hide() + _async_render_avatar(avatars_fetched[0].get("avatar", {})) diff --git a/godot/src/test/avatar/avatar_tester_standalone.tscn b/godot/src/test/avatar/avatar_tester_standalone.tscn index be46db919..9ae82396b 100644 --- a/godot/src/test/avatar/avatar_tester_standalone.tscn +++ b/godot/src/test/avatar/avatar_tester_standalone.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=7 format=3 uid="uid://4227l72a8kdu"] +[gd_scene load_steps=8 format=3 uid="uid://4227l72a8kdu"] [ext_resource type="PackedScene" uid="uid://cy43hvd5bivso" path="res://src/ui/components/backpack/avatar_preview.tscn" id="1_1eenv"] [ext_resource type="Script" path="res://src/test/avatar/avatar_tester_standalone.gd" id="1_l1th6"] [ext_resource type="Environment" uid="uid://c6yftsnvufsg8" path="res://assets/environment/cli_environment.tres" id="3_2n2br"] [ext_resource type="PackedScene" uid="uid://ec0egfeyv5fm" path="res://src/ui/components/emotes/emote_wheel.tscn" id="3_ubmva"] [ext_resource type="Texture2D" uid="uid://ckn18yn0v8tsa" path="res://src/ui/components/debug_panel/icons/Clear.svg" id="4_wetld"] +[ext_resource type="PackedScene" uid="uid://buu3ox7iefpgx" path="res://src/ui/components/loading_spinner/loading_spinner.tscn" id="6_wsp5b"] [sub_resource type="CodeHighlighter" id="CodeHighlighter_684t6"] number_color = Color(0, 0.670588, 0, 1) @@ -48,17 +49,17 @@ offset_bottom = 47.0 [node name="Button_DownloadWearables" type="Button" parent="TabContainer/Avatars"] layout_mode = 0 offset_left = 16.0 -offset_top = 64.0 +offset_top = 512.0 offset_right = 581.0 -offset_bottom = 111.0 +offset_bottom = 559.0 text = "Download wearables" [node name="Button_CopyWearableData" type="Button" parent="TabContainer/Avatars"] layout_mode = 0 offset_left = 16.0 -offset_top = 120.0 +offset_top = 568.0 offset_right = 581.0 -offset_bottom = 167.0 +offset_bottom = 615.0 text = "Copy wearables data" [node name="Button_Refresh" type="Button" parent="TabContainer/Avatars"] @@ -69,6 +70,22 @@ offset_right = 575.0 offset_bottom = 48.0 icon = ExtResource("4_wetld") +[node name="LineEdit_ProfileEntity" type="LineEdit" parent="TabContainer/Avatars"] +layout_mode = 0 +offset_left = 24.0 +offset_top = 88.0 +offset_right = 575.0 +offset_bottom = 127.0 +placeholder_text = "Profile Adress(0xff...) or Entity ID (bafk...)" + +[node name="Button_Fetch" type="Button" parent="TabContainer/Avatars"] +layout_mode = 0 +offset_left = 16.0 +offset_top = 136.0 +offset_right = 583.0 +offset_bottom = 174.0 +text = "Render Avatar" + [node name="Emotes" type="Panel" parent="TabContainer"] visible = false custom_minimum_size = Vector2(600, 600) @@ -189,10 +206,18 @@ text = "asdasd" editable = false wrap_mode = 1 +[node name="Spinner" parent="." instance=ExtResource("6_wsp5b")] +layout_mode = 0 +offset_left = 875.0 +offset_top = 257.0 +offset_right = 1003.0 +offset_bottom = 385.0 + [connection signal="item_selected" from="TabContainer/Avatars/OptionButton_AvatarList" to="." method="_on_option_button_avatar_list_item_selected"] [connection signal="pressed" from="TabContainer/Avatars/Button_DownloadWearables" to="." method="_on_button_download_wearables_pressed"] [connection signal="pressed" from="TabContainer/Avatars/Button_CopyWearableData" to="." method="_on_button_copy_wearable_data_pressed"] [connection signal="pressed" from="TabContainer/Avatars/Button_Refresh" to="." method="_on_button_refresh_pressed"] +[connection signal="pressed" from="TabContainer/Avatars/Button_Fetch" to="." method="_on_button_fetch_pressed"] [connection signal="pressed" from="TabContainer/Emotes/Button_OpenWheel" to="." method="_on_button_open_wheel_pressed"] [connection signal="pressed" from="TabContainer/Emotes/Button_PlayCustom" to="." method="_on_button_play_custom_pressed"] [connection signal="pressed" from="TabContainer/Emotes/Button_Clear" to="." method="_on_button_clear_pressed"] diff --git a/godot/src/tool/avatar_renderer/avatar_renderer_standalone.gd b/godot/src/tool/avatar_renderer/avatar_renderer_standalone.gd index 19fb3de56..1ae1fa77f 100644 --- a/godot/src/tool/avatar_renderer/avatar_renderer_standalone.gd +++ b/godot/src/tool/avatar_renderer/avatar_renderer_standalone.gd @@ -56,6 +56,15 @@ func _ready(): func start(): async_update_avatar(0) + # Visual enhance + var viewport: Viewport = avatar_preview.subviewport.get_viewport() + viewport.use_debanding = true + viewport.scaling_3d_scale = 2.0 + RenderingServer.viewport_set_msaa_3d( + viewport.get_viewport_rid(), RenderingServer.VIEWPORT_MSAA_8X + ) + RenderingServer.screen_space_roughness_limiter_set_active(true, 4.0, 1.0) + func flush_logs(): for log_item in logs: diff --git a/lib/src/dcl/js/mod.rs b/lib/src/dcl/js/mod.rs index 688454b23..c8c0c8427 100644 --- a/lib/src/dcl/js/mod.rs +++ b/lib/src/dcl/js/mod.rs @@ -291,6 +291,7 @@ pub(crate) fn scene_thread( let start_time = std::time::SystemTime::now(); let mut elapsed = Duration::default(); + let mut reported_error_filter = 0; loop { let dt = std::time::SystemTime::now() @@ -312,22 +313,26 @@ pub(crate) fn scene_thread( }); if let Err(e) = result { - let err_str = format!("{:?}", e); - if let Ok(err) = e.downcast::() { - tracing::error!( - "[scene thread {scene_id:?}] script error onUpdate: {} msg {:?} @ {:?}", - err_str, - err.message, - err - ); - } else { - tracing::error!( - "[scene thread {scene_id:?}] script error onUpdate: {}", - err_str - ); + reported_error_filter += 1; + + if reported_error_filter <= 10 { + let err_str = format!("{:?}", e); + if let Ok(err) = e.downcast::() { + tracing::error!( + "[scene thread {scene_id:?}] script error onUpdate: {} msg {:?} @ {:?}", + err_str, + err.message, + err + ); + } else { + tracing::error!( + "[scene thread {scene_id:?}] script error onUpdate: {}", + err_str + ); + } } - - break; + } else { + reported_error_filter -= 1; } let value = state.borrow().borrow::().0;