// <auto-generated>
// This file is generated by Ghost.NativeWrapperGen. Do not edit manually.
// </auto-generated>

namespace Ghost.Ufbx;

public unsafe partial struct ufbx_mesh : System.IDisposable
{
    /// <summary>
    /// From: <see cref="Api.ufbx_find_face_index(ufbx_mesh*, nuint)" />
    /// </summary>
    [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
    public uint FindFaceIndex(nuint index)
    {
        return Api.ufbx_find_face_index(
            (ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this),
            index);
    }

    /// <summary>
    /// From: <see cref="Api.ufbx_compute_topology(ufbx_mesh*, ufbx_topo_edge*, nuint)" />
    /// </summary>
    [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
    public void ComputeTopology(ReadOnlySpan<ufbx_topo_edge> topo)
    {
        fixed (ufbx_topo_edge* ptopo = topo)
        {
            Api.ufbx_compute_topology(
                (ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this),
                (ufbx_topo_edge*)ptopo,
                (nuint)topo.Length);
        }
    }

    /// <summary>
    /// From: <see cref="Api.ufbx_generate_normal_mapping(ufbx_mesh*, ufbx_topo_edge*, nuint, uint*, nuint, bool)" />
    /// </summary>
    [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
    public nuint GenerateNormalMapping(ReadOnlySpan<ufbx_topo_edge> topo, ReadOnlySpan<uint> normal_indices, bool assume_smooth)
    {
        fixed (ufbx_topo_edge* ptopo = topo)
        {
            fixed (uint* pnormal_indices = normal_indices)
            {
                return Api.ufbx_generate_normal_mapping(
                    (ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this),
                    (ufbx_topo_edge*)ptopo,
                    (nuint)topo.Length,
                    (uint*)pnormal_indices,
                    (nuint)normal_indices.Length,
                    assume_smooth);
            }
        }
    }

    /// <summary>
    /// From: <see cref="Api.ufbx_compute_normals(ufbx_mesh*, ufbx_vertex_vec3*, uint*, nuint, ufbx_vec3*, nuint)" />
    /// </summary>
    [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
    public void ComputeNormals(ufbx_vertex_vec3* positions, ReadOnlySpan<uint> normal_indices, ReadOnlySpan<ufbx_vec3> normals)
    {
        fixed (uint* pnormal_indices = normal_indices)
        {
            fixed (ufbx_vec3* pnormals = normals)
            {
                Api.ufbx_compute_normals(
                    (ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this),
                    positions,
                    (uint*)pnormal_indices,
                    (nuint)normal_indices.Length,
                    (ufbx_vec3*)pnormals,
                    (nuint)normals.Length);
            }
        }
    }

    /// <summary>
    /// From: <see cref="Api.ufbx_subdivide_mesh(ufbx_mesh*, nuint, ufbx_subdivide_opts*, ufbx_error*)" />
    /// </summary>
    [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
    public ufbx_mesh* Subdivide(nuint level, ufbx_subdivide_opts* opts, ufbx_error* error)
    {
        return Api.ufbx_subdivide_mesh(
            (ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this),
            level,
            opts,
            error);
    }

    /// <summary>
    /// From: <see cref="Api.ufbx_free_mesh(ufbx_mesh*)" />
    /// </summary>
    [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
    public void Dispose()
    {
        Api.ufbx_free_mesh((ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this));
    }

    /// <summary>
    /// From: <see cref="Api.ufbx_retain_mesh(ufbx_mesh*)" />
    /// </summary>
    [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
    public void Retain()
    {
        Api.ufbx_retain_mesh((ufbx_mesh*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this));
    }
}
