using System; using System.Runtime.InteropServices; using UnityEngine.XR.ARSubsystems; namespace MagicLeap.OpenXR.Features.Meshing { internal unsafe struct XrMeshId { internal fixed ulong Id[2]; internal static XrMeshId CreateFrom(T id) where T: unmanaged { var copy = id; return *(XrMeshId*)© } internal T Convert() where T : unmanaged { var copy = this; return *(T*)(©); } } public enum MeshingMode : byte { Triangles, PointCloud } internal unsafe struct FrameMeshInfo { internal TrackableId* AddedIds; internal uint AddedCount; internal TrackableId* RemovedIds; internal uint RemovedCount; internal TrackableId* UpdatedIds; internal uint UpdatedCount; } /// /// The flags to represent the generated mesh's properties /// [Flags] public enum MeshDetectorFlags : byte { /// /// Whether to compute the normals of the mesh /// ComputeNormals = 1 << 1, /// /// Whether to compute the confidence data for the mesh /// ComputeConfidence = 1 << 2, /// /// Whether to planarize the generated mesh /// Planarize = 1 << 3, /// /// When enabled, the mesh skirt (overlapping area between two mesh blocks) will be removed. This field is only valid /// when the mesh is not a point cloud. /// MeshSkirt = 1 << 4 } /// /// The mesh generation settings /// [Serializable] public struct MeshingQuerySettings { public float fillHoleLength; public float appliedDisconnectedComponentArea; public MeshDetectorFlags meshDetectorFlags; /// /// Whether to use the ion allocator on the device to store the mesh data. /// [MarshalAs(UnmanagedType.I1)] public bool useIonAllocator; public static MeshingQuerySettings DefaultSettings() { return new MeshingQuerySettings { fillHoleLength = 0.25f, appliedDisconnectedComponentArea = 0.25f, meshDetectorFlags = MeshDetectorFlags.Planarize | MeshDetectorFlags.ComputeNormals, useIonAllocator = false, }; } } }