// SPDX-FileCopyrightText: 2023 Unity Technologies and the Draco for Unity authors
// SPDX-License-Identifier: Apache-2.0
using System;
using Unity.Collections;
using UnityEngine;
namespace Draco
{
///
/// Draco encoded meshes might contain bone weights and indices that cannot be applied to the resulting Unity
/// mesh right away. This class provides them and offers methods to apply them to Unity meshes.
///
public sealed class BoneWeightData : IDisposable
{
NativeArray m_BonesPerVertex;
NativeArray m_BoneWeights;
///
/// Constructs an object with parameters identical to .
///
/// Bones per vertex
/// Bone weights
///
public BoneWeightData(NativeArray bonesPerVertex, NativeArray boneWeights)
{
m_BonesPerVertex = bonesPerVertex;
m_BoneWeights = boneWeights;
}
///
/// Applies the bone weights and indices on a Unity mesh.
///
/// The mesh to apply the data onto.
public void ApplyOnMesh(Mesh mesh)
{
mesh.SetBoneWeights(m_BonesPerVertex, m_BoneWeights);
}
///
/// Releases allocated resources.
///
public void Dispose()
{
m_BonesPerVertex.Dispose();
m_BoneWeights.Dispose();
}
}
}