Skip to content

Commit

Permalink
Merge pull request #5961 from decentraland/release/release-20231120
Browse files Browse the repository at this point in the history
Release: 20231120
  • Loading branch information
anicalbano committed Nov 20, 2023
2 parents 0f386c0 + 8dc35a9 commit 019fc66
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
using DCL.CameraTool;
using DCL.SettingsCommon;
using System;
using System.Collections.Generic;
using DCL.CameraTool;
using UnityEngine;
using QualitySettings = DCL.SettingsCommon.QualitySettings;

namespace DCL
{
public class AvatarsLODController : IAvatarsLODController
{
internal const float RENDERED_DOT_PRODUCT_ANGLE = 0.25f;
internal const float AVATARS_INVISIBILITY_DISTANCE = 1.75f;
private const float RENDERED_DOT_PRODUCT_ANGLE = 0.25f;
private const float AVATARS_INVISIBILITY_DISTANCE = 1.75f;
private const float MIN_DISTANCE_BETWEEN_NAMES_PIXELS = 70f;
private const float MIN_ANIMATION_FRAME_SKIP_DISTANCE_MULTIPLIER = 0.3f;
private const float MAX_ANIMATION_FRAME_SKIP_DISTANCE_MULTIPLIER = 2f;

private BaseDictionary<string, Player> otherPlayers => DataStore.i.player.otherPlayers;
private BaseVariable<float> simpleAvatarDistance => DataStore.i.avatarsLOD.simpleAvatarDistance;
private BaseVariable<int> maxAvatars => DataStore.i.avatarsLOD.maxAvatars;
private BaseVariable<int> maxImpostors => DataStore.i.avatarsLOD.maxImpostors;
private QualitySettings qualitySettings => Settings.i.qualitySettings.Data;

private readonly GPUSkinningThrottlingCurveSO gpuSkinningThrottlingCurve;
private readonly SimpleOverlappingTracker overlappingTracker = new (MIN_DISTANCE_BETWEEN_NAMES_PIXELS);
Expand Down Expand Up @@ -114,7 +119,7 @@ internal void UpdateAllLODs(int maxAvatars = DataStore_AvatarsLOD.DEFAULT_MAX_AV

if (avatarsCount < maxAvatars)
{
lodController.SetAnimationThrottling((int)gpuSkinningThrottlingCurve.curve.Evaluate(distance));
lodController.SetAnimationThrottling(CalculateAnimationTrhottle(distance));

if (distance < simpleAvatarDistance)
lodController.SetLOD0();
Expand Down Expand Up @@ -142,6 +147,22 @@ internal void UpdateAllLODs(int maxAvatars = DataStore_AvatarsLOD.DEFAULT_MAX_AV
}
}

private int CalculateAnimationTrhottle(float distance)
{
if (!qualitySettings.enableDetailObjectCulling) return 1;

float culling = qualitySettings.detailObjectCullingLimit;

// The higher the culling, the higher distance multiplier we give to the calculation
float distanceNerf = Mathf.Lerp(
MIN_ANIMATION_FRAME_SKIP_DISTANCE_MULTIPLIER,
MAX_ANIMATION_FRAME_SKIP_DISTANCE_MULTIPLIER,
culling / 100f);

// The curve starts adding frame skips at 15 distance (one parcel)
return (int)gpuSkinningThrottlingCurve.curve.Evaluate(distance * distanceNerf);
}

private void GetMainCamera()
{
if (camera == null)
Expand Down Expand Up @@ -195,7 +216,7 @@ public void Dispose()

otherPlayers.OnAdded -= RegisterAvatar;
otherPlayers.OnRemoved -= UnregisterAvatar;
DCL.Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.Update, Update);
Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.Update, Update);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"GUID:da3e51d19d51a544fa14d43fee843098",
"GUID:0c0c18c12967b3944b844b79c47c2320",
"GUID:4d3366a36e77f41cfb7436340334e236",
"GUID:2d39cc535b437e749965d4a8258f0c13"
"GUID:2d39cc535b437e749965d4a8258f0c13",
"GUID:301149363e31a4bdaa1943465a825c8e"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,65 @@ MonoBehaviour:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 29.97296
value: 5.9995947
time: 22.886015
value: 2.0299528
inSlope: Infinity
outSlope: Infinity
tangentMode: 7
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 30
value: 4
inSlope: Infinity
outSlope: Infinity
tangentMode: 97
weightedMode: 0
inWeight: 0
outWeight: 0.33333334
- serializedVersion: 3
time: 45
value: 6
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
mildCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0.03470943
value: 1.0015817
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 60
value: 2
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 120
value: 3
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void SetEmotes(WearableItem[] ownedEmotes)

UpdateEmoteSlots();

view.Refresh();
view.RefreshEmotesGrid();
}

public void SetEquippedBodyShape(string bodyShapeId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public void Refresh()
RefreshControl();
}

public void RefreshEmotesGrid() =>
emotesGrid.RefreshControl();

internal void ClickOnEmote(string emoteId, string emoteName, int slotNumber, bool isAssignedInSelectedSlot)
{
if (!isAssignedInSelectedSlot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,7 @@ public interface IEmotesCustomizationComponentView
EmoteSlotCardComponentView GetSlot(int slotNumber);

void Refresh();

void RefreshEmotesGrid();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,10 @@ RectTransform:
m_Children: []
m_Father: {fileID: 1238863926746129352}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 693.49, y: 0}
m_SizeDelta: {x: 2069.3, y: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 300, y: 0}
m_SizeDelta: {x: -600, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7517409048018998757
CanvasRenderer:
Expand Down Expand Up @@ -8820,6 +8820,11 @@ PrefabInstance:
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8910445738144305339, guid: 7987c409c7fea4189954a35a350cfd2a,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 18.999878
objectReference: {fileID: 0}
- target: {fileID: 9066200567839680107, guid: 7987c409c7fea4189954a35a350cfd2a,
type: 3}
propertyPath: m_SizeDelta.y
Expand Down
Loading

0 comments on commit 019fc66

Please sign in to comment.