// Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
using System;
using System.Collections.Generic;
using Unity.Collections;
using UnityEngine;
namespace Meta.XR.Movement.FaceTracking.Samples
{
///
/// Abstract weights provider implementation.
///
public abstract class WeightsProvider : MonoBehaviour
{
///
/// Indicates if provider is valid or not.
///
public abstract bool IsValid { get; }
///
/// Returns a readonly list of weights.
///
/// Weights.
public abstract float[] GetWeights();
///
/// Returns a readonly list of weight names.
///
/// Weight names.
public abstract string[] GetWeightNames();
///
/// Copys weights from source to destination float array.
///
/// Source weights.
/// Destination weights.
public static void CopyWeights(float[] src, ref float[] dest)
{
int srcLength = src.Length;
if (dest.Length != srcLength)
{
dest = new float[srcLength];
}
Buffer.BlockCopy(src, 0, dest, 0, srcLength * sizeof(float));
}
///
/// Copies weights from source to destination native array.
///
/// Source weights.
/// Destination weights.
public static void CopyWeights(float[] src, ref NativeArray dest)
{
Debug.Assert(dest.Length == src.Length);
for (var i = 0; i < src.Length; ++i)
{
dest[i] = src[i];
}
}
}
}