Пример #1
0
        /// <summary>
        /// Get the mesh data associated with the face with <paramref name="faceId"/>. The <paramref name="faceMesh"/>
        /// is reused if it is the correct size, otherwise, it is disposed and reallocated using <paramref name="allocator"/>.
        /// </summary>
        /// <param name="faceId">The <see cref="TrackableId"/> for a <see cref="XRFace"/>.</param>
        /// <param name="allocator">The allocator to use for the returned data if a resize is necessary. Must be <c>Allocator.TempJob</c> or <c>Allocator.Persistent</c>.</param>
        /// <param name="faceMesh">The container for the mesh data to either re-use or re-allocate.</param>
        /// <exception cref="System.InvalidOperationException">Thrown if <paramref name="allocator"> is <c>Allocator.Temp</c></exception>
        /// <exception cref="System.InvalidOperationException">Thrown if <paramref name="allocator"> is <c>Allocator.None</c></exception>
        public virtual void GetFaceMesh(TrackableId faceId, Allocator allocator, ref XRFaceMesh faceMesh)
        {
            if (allocator == Allocator.Temp)
                throw new InvalidOperationException("Allocator.Temp is not supported. Use Allocator.TempJob if you wish to use a temporary allocator.");

            if (allocator == Allocator.None)
                throw new InvalidOperationException("Allocator.None is not a valid allocator.");

            m_Provider.GetFaceMesh(faceId, allocator, ref faceMesh);
        }
Пример #2
0
 /// <summary>
 /// Get the mesh data associated with the face with <paramref name="faceId"/>. The <paramref name="faceMesh"/>
 /// should be reused if it is the correct size, otherwise, its arrays should be reallocated with <paramref name="allocator"/>.
 /// Use <see cref="XRFaceMesh.Assign(XRFaceMesh)"/> to ensure unused <c>NativeArray</c>s are disposed properly and
 /// <see cref="CreateOrResizeNativeArrayIfNecessary"/> to resize individual arrays.
 /// </summary>
 /// <param name="faceId">The <see cref="TrackableId"/> for a <see cref="XRFace"/>.</param>
 /// <param name="allocator">The allocator to use for the returned data if a resize is necessary.</param>
 /// <param name="faceMesh">The container for the mesh data to either re-use or re-allocate.</param>
 /// <example>
 /// <code>
 /// var vertices = faceMesh.vertices;
 /// CreateOrResizeNativeArrayIfNecessary(numVertices, allocator, ref vertices);
 ///
 /// ...
 ///
 /// faceMesh.Assign(new XRFaceMesh
 /// {
 ///     vertices = vertices,
 ///     indices = ...
 /// });
 /// </code>
 /// </example>
 public virtual void GetFaceMesh(TrackableId faceId, Allocator allocator, ref XRFaceMesh faceMesh)
 {
     faceMesh.Dispose();
     faceMesh = default(XRFaceMesh);
 }