Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ private async UniTask LoadAsync()

private void OnDisable()
{
image.sprite = null!;
asset.Release();
if (image != null)
image.sprite = null!;
Comment thread
eordano marked this conversation as resolved.
asset?.Release();
}

private void OnDestroy()
{
image.sprite = null!;
asset.Dispose();
if (image != null)
image.sprite = null!;
asset?.Dispose();
}

public UniTask TriggerOrWaitReadyAsync(CancellationToken token) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void OnMuteButtonClicked()

private void OnContinuousAudioStarted(AudioClipConfig audioClipConfig)
{
if (audioClipConfig.GetInstanceID() != backgroundMusic.GetInstanceID())
if (audioClipConfig.GetEntityId() != backgroundMusic.GetEntityId())
return;

UIAudioEventsBus.Instance.PlayContinuousUIAudioEvent -= OnContinuousAudioStarted;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public void Show(string profileName)
JumpIntoWorldButton.interactable = true;
DiffAccountButton.interactable = true;

ShowAsync(CancellationToken.None).Forget();
ShowAsync(destroyCancellationToken).Forget();
}

public void Hide(int animHash)
{
hideAnimHash = animHash;
HideAsync(CancellationToken.None).Forget();
HideAsync(destroyCancellationToken).Forget();
}

public override async UniTask ShowAsync(CancellationToken ct)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ private async UniTaskVoid UpdateBodyTypeLabelAsync(bool isMale)

public void Show()
{
ShowAsync(CancellationToken.None).Forget();
ShowAsync(destroyCancellationToken).Forget();
}

public void Hide(int animHash)
{
hideAnimHash = animHash;
HideAsync(CancellationToken.None).Forget();
HideAsync(destroyCancellationToken).Forget();
}

public override async UniTask ShowAsync(CancellationToken ct)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void SetOptionsPanelVisibility(bool isExpanded)
public void Show(int animHash, bool moreOptionsExpanded)
{
showAnimHash = animHash;
ShowAsync(CancellationToken.None).Forget();
ShowAsync(destroyCancellationToken).Forget();

areOptionsExpanded = moreOptionsExpanded;
SetOptionsPanelVisibility(areOptionsExpanded);
Expand All @@ -120,7 +120,7 @@ public void Hide()
loadingSpinner.SetActive(false);
SetEmailInputFieldSpinnerActive(false);

HideAsync(CancellationToken.None).Forget();
HideAsync(destroyCancellationToken).Forget();
}

public void SetLoadingSpinnerVisibility(bool isLoading)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public class ProfileFetchingAuthView : ViewBase

public void Show()
{
ShowAsync(CancellationToken.None).Forget();
ShowAsync(destroyCancellationToken).Forget();
}

public void Hide(int hideAnimHash)
{
this.hideAnimHash = hideAnimHash;
HideAsync(CancellationToken.None).Forget();
HideAsync(destroyCancellationToken).Forget();
}

public override async UniTask ShowAsync(CancellationToken ct)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public void Show(int dataCode, DateTime expiration)
code.text = dataCode.ToString();
DoCountdownAsync(expiration).Forget();

ShowAsync(CancellationToken.None).Forget();
ShowAsync(destroyCancellationToken).Forget();
}

public void Hide(int hideAnimHash)
{
this.hideAnimHash = hideAnimHash;
HideAsync(CancellationToken.None).Forget();
HideAsync(destroyCancellationToken).Forget();
}

public override async UniTask ShowAsync(CancellationToken ct)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public class VerificationOTPAuthView : ViewBase
public void Show(string email)
{
InputField.Clear();
ShowAsync(CancellationToken.None).Forget();
ShowAsync(destroyCancellationToken).Forget();
description.text = description.text.Replace("your@email.com", email); // Update description with user email
}

public void Hide(int hideAnimHash)
{
this.hideAnimHash = hideAnimHash;
HideAsync(CancellationToken.None).Forget();
HideAsync(destroyCancellationToken).Forget();
}

public override async UniTask ShowAsync(CancellationToken ct)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public void AssignBuffer(ComputeSkinningBufferContainer container)

public void DisposeBuffers()
{
computeSkinningBufferContainer.Dispose();
bones.Dispose();
// a default(Buffers) (empty avatar) owns nothing to dispose
computeSkinningBufferContainer?.Dispose();
bones?.Dispose();
}
}

Expand Down Expand Up @@ -117,6 +118,10 @@ public readonly void SetFadingDistance(float distance)

public Result ComputeSkinning(NativeArray<float4x4> bonesResult, GlobalJobArrayIndex indexInGlobalJobArray)
{
// an empty avatar (no vertices) has nothing to skin
if (VertCount == 0)
return Result.SuccessResult();

if (indexInGlobalJobArray.TryGetValue(out int validIndex) == false)
{
return Result.ErrorResult("Attempt to process an invalid avatar");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ public override AvatarCustomSkinningComponent Initialize(IList<CachedAttachment>

(int vertCount, int totalBoneBufferCount) = SetupCounters(meshesData, boneCount);

if (vertCount == 0 || boneCount == 0)
{
ReportHub.LogWarning(ReportCategory.AVATAR,
$"[ComputeShaderSkinning] Empty avatar mesh data (vertCount={vertCount}, boneCount={boneCount}); skipping skinning.");
ListPool<MeshData>.Release(meshesData);

// VertCount == 0 with default Buffers marks the component as empty: ComputeSkinning and
// DisposeBuffers no-op on it, and the materials list is pool-rented so Dispose's
// unconditional USED_SLOTS_POOL.Release stays balanced.
return new AvatarCustomSkinningComponent(0, 0, default, AvatarCustomSkinningComponent.USED_SLOTS_POOL.Get(), skinningShader, default);
}

AvatarCustomSkinningComponent.Buffers buffers = SetupComputeShader(meshesData, skinningShader, vertCount, totalBoneBufferCount, boneCount);
List<AvatarCustomSkinningComponent.MaterialSetup> materialSetups = SetupMeshRenderer(meshesData, avatarMaterialPool, avatarShapeComponent, facialFeatureTexture);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ public void Release(Slice slice)
// Merge the region with any adjacent free regions in the freeRegions list.
// The freeRegions list should always be kept sorted. If you merge regions, make sure the result is still sorted.

// a zero-length slice was never rented (Rent rejects 0): nothing to release
if (slice.Length == 0)
return;

if (!rentedRegions.Remove(slice))
{
ReportHub.LogError(ReportCategory.AVATAR, "Trying to release a slice that was not rented");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected override void Update(float t)
{
// Just taking the one and only playable director from the scene is ok for now
if (playableDirector == null)
playableDirector = GameObject.FindObjectOfType<PlayableDirector>();
playableDirector = Object.FindAnyObjectByType<PlayableDirector>();

if (playableDirector != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ private void InstantiateExistingAvatar(ref AvatarShapeComponent avatarShapeCompo
foreach (var renderer in cachedAttachment.Renderers)
renderer.enabled = false;

skinningComponent.SetVertOutRegion(vertOutBuffer.Rent(skinningComponent.VertCount));
// an empty avatar (VertCount == 0) owns no region of the shared buffer (Rent rejects 0)
if (skinningComponent.VertCount > 0)
skinningComponent.SetVertOutRegion(vertOutBuffer.Rent(skinningComponent.VertCount));
avatarBase.gameObject.SetActive(true);
avatarBase.UpdateHeadWearableOffset(skinningComponent.LocalBounds, wearableIntention); // Update cached head wearable offset for nametag positioning

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ protected override void Update(float t)
[Query]
private void UpdateIndices([Data] IReadOnlyDictionary<int, FixedComputeBufferHandler.Slice> remapping, ref AvatarCustomSkinningComponent avatarCustomSkinningComponent)
{
// a zero-length region owns no slice of the buffer; its default StartIndex (0) must not
// match a real region that starts at 0
if (avatarCustomSkinningComponent.VertsOutRegion.Length == 0)
return;

if (remapping.TryGetValue(avatarCustomSkinningComponent.VertsOutRegion.StartIndex, out FixedComputeBufferHandler.Slice newRegion))
avatarCustomSkinningComponent.SetVertOutRegion(newRegion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,6 @@ public void ResetDitherStateWhenAvatarShapeIsDirty()
ref var shapeRef = ref world.Get<AvatarShapeComponent>(playerEntity);
shapeRef.IsDirty = true;

// Add skinning component for dither test
var skinningMaterials = new List<AvatarCustomSkinningComponent.MaterialSetup>();
var skinningComponent = new AvatarCustomSkinningComponent();

// Act - This update should trigger ResetDitherState due to IsDirty
system.Update(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ private MaskedLegacyEmoteBlender AddOrGetMaskedLegacyBlender()

public void StartMaskedLegacyEmote(AnimationClip clip, AvatarMask avatarMask, bool loop)
{
if (AvatarAnimator == null) return;
Comment thread
eordano marked this conversation as resolved.

// Keep the Animator enabled so locomotion stays driving the bones we restore each frame.
AvatarAnimator.enabled = true;
AddOrGetMaskedLegacyBlender().Play(clip, avatarMask, loop);
Expand All @@ -200,15 +202,22 @@ public void StartMaskedLegacyEmote(AnimationClip clip, AvatarMask avatarMask, bo
public void StopMaskedLegacyEmote() =>
maskedLegacyBlender?.Stop();

public void SetPointAtLayerWeight(float weight) =>
public void SetPointAtLayerWeight(float weight)
{
if (AvatarAnimator == null) return;
AvatarAnimator.SetLayerWeight(rightPointAtLayerIndex, weight);
}

public void SetRotationLayerWeight(float weight) =>
public void SetRotationLayerWeight(float weight)
{
if (AvatarAnimator == null) return;
AvatarAnimator.SetLayerWeight(rotationLayerIndex, weight);
}

public void SetAnimatorFloat(int hash, float value)
{
if (IsLegacyAnimationPlaying) return;
if (AvatarAnimator == null) return;
if (AvatarAnimator.GetFloat(hash).Equals(value)) return;

AvatarAnimator.enabled = true;
Expand All @@ -218,6 +227,7 @@ public void SetAnimatorFloat(int hash, float value)
public void SetAnimatorInt(int hash, int value)
{
if (IsLegacyAnimationPlaying) return;
if (AvatarAnimator == null) return;
if (AvatarAnimator.GetInteger(hash).Equals(value)) return;

AvatarAnimator.enabled = true;
Expand All @@ -227,22 +237,28 @@ public void SetAnimatorInt(int hash, int value)
public void SetAnimatorTrigger(int hash)
{
if (IsLegacyAnimationPlaying) return;
if (AvatarAnimator == null) return;

AvatarAnimator.enabled = true;
AvatarAnimator.SetTrigger(hash);
}

public bool IsAnimatorInTag(int hashTag) =>
AvatarAnimator.GetCurrentAnimatorStateInfo(0).tagHash == hashTag;
AvatarAnimator != null && AvatarAnimator.GetCurrentAnimatorStateInfo(0).tagHash == hashTag;

public int GetAnimatorCurrentStateTag(string layerName)
{
if (AvatarAnimator == null) return 0;

int layerIndex = AvatarAnimator.GetLayerIndex(layerName);
return AvatarAnimator.GetCurrentAnimatorStateInfo(layerIndex).tagHash;
}

public void ResetAnimatorTrigger(int hash) =>
public void ResetAnimatorTrigger(int hash)
{
if (AvatarAnimator == null) return;
AvatarAnimator.ResetTrigger(hash);
}

public void ResetArmatureInclination()
{
Expand All @@ -260,36 +276,40 @@ public void ResetState()
transform.localPosition = Vector3.zero;
LegacyAnimation?.Stop();
maskedLegacyBlender?.Stop();
AvatarAnimator.Rebind();
if (AvatarAnimator != null) AvatarAnimator.Rebind();
HipsConstraint.data.offset = Vector3.zero;
HipsConstraint.weight = 0;
FeetIKRig.enabled = false;
}

public void SetLayerWeight(string layerName, float weight)
{
if (AvatarAnimator == null) return;

int index = AvatarAnimator.GetLayerIndex(layerName);
AvatarAnimator.SetLayerWeight(index, weight);
}

public bool GetAnimatorBool(int hash) =>
AvatarAnimator.GetBool(hash);
AvatarAnimator != null && AvatarAnimator.GetBool(hash);

public void SetAnimatorBool(int hash, bool value)
{
if (IsLegacyAnimationPlaying) return;
if (AvatarAnimator == null) return;
if (AvatarAnimator.GetBool(hash) == value) return;

AvatarAnimator.enabled = true;
AvatarAnimator.SetBool(hash, value);
}

public float GetAnimatorFloat(int hash) =>
AvatarAnimator.GetFloat(hash);
AvatarAnimator != null ? AvatarAnimator.GetFloat(hash) : 0f;

public void ReplaceEmoteAnimation(AnimationClip animationClip)
{
if (lastEmote == animationClip) return;
if (AvatarAnimator == null) return;

overrideController["Emote"] = animationClip;
AvatarAnimator.runtimeAnimatorController = overrideController;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DCL.Audio;
using DCL.Chat;
using DCL.Clipboard;
using DCL.Emoji;
using DCL.Profiles;
using DCL.UI.CustomInputField;
Expand Down Expand Up @@ -40,6 +41,7 @@ public class AnnouncementCreationCardView : MonoBehaviour

private string currentProfileThumbnailUrl = null!;
private AnnouncementEmojiController? announcementEmojiController;
private ClipboardManager? subscribedClipboardManager;

private void Awake()
{
Expand All @@ -50,17 +52,23 @@ private void Awake()
announcementInput.onValueChanged.AddListener(OnAnnouncementInputValueChanged);
announcementInput.PasteShortcutPerformed += OnAnnouncementInputPasteShortcut;
createAnnouncementButton.onClick.AddListener(OnCreateAnnouncementButton);
ViewDependencies.ClipboardManager.OnPaste += OnPasteClipboardText;
subscribedClipboardManager = ViewDependencies.ClipboardManager;
subscribedClipboardManager.OnPaste += OnPasteClipboardText;
}

private void OnDestroy()
{
announcementInput.onSelect.RemoveListener(OnAnnouncementInputSelected);
announcementInput.onDeselect.RemoveListener(OnAnnouncementInputDeselected);
announcementInput.onValueChanged.RemoveListener(OnAnnouncementInputValueChanged);
announcementInput.PasteShortcutPerformed -= OnAnnouncementInputPasteShortcut;
createAnnouncementButton.onClick.RemoveListener(OnCreateAnnouncementButton);
ViewDependencies.ClipboardManager.OnPaste -= OnPasteClipboardText;
if (announcementInput != null)
{
announcementInput.onSelect.RemoveListener(OnAnnouncementInputSelected);
announcementInput.onDeselect.RemoveListener(OnAnnouncementInputDeselected);
announcementInput.onValueChanged.RemoveListener(OnAnnouncementInputValueChanged);
announcementInput.PasteShortcutPerformed -= OnAnnouncementInputPasteShortcut;
}
if (createAnnouncementButton != null)
createAnnouncementButton.onClick.RemoveListener(OnCreateAnnouncementButton);
if (subscribedClipboardManager != null)
subscribedClipboardManager.OnPaste -= OnPasteClipboardText;

announcementEmojiController?.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ public void UpdateInterestedCounter()
{
//Disabled because of https://github.com/decentraland/unity-explorer/issues/5154
interestedContainer.SetActive(false);
return;

eventInterestedUsersText.text = eventData!.Value.Event.total_attendees.ToString();
interestedContainer.SetActive(eventData!.Value.Event is { live: false, total_attendees: > 0 });
}

public void SubscribeToInteractions(Action<PlaceAndEventDTO> mainAction,
Expand Down
Loading
Loading