// %BANNER_BEGIN% // --------------------------------------------------------------------- // %COPYRIGHT_BEGIN% // Copyright (c) (2021-2022) Magic Leap, Inc. All Rights Reserved. // Use of this file is governed by the Software License Agreement, located here: https://www.magicleap.com/software-license-agreement-ml2 // Terms and conditions applicable to third-party materials accompanying this distribution may also be found in the top-level NOTICE file appearing herein. // %COPYRIGHT_END% // --------------------------------------------------------------------- // %BANNER_END% using System; using UnityEngine.XR.ARSubsystems; namespace UnityEngine.XR.MagicLeap { public partial class PlanesSubsystem { public static partial class Extensions { [Flags] public enum MLPlanesQueryFlags : uint { /// /// Include no planes. /// None = 0, /// /// Include planes whose normal is perpendicular to gravity. /// Vertical = 1 << 0, /// /// Include planes whose normal is parallel to gravity. /// Horizontal = 1 << 1, /// /// Include planes with arbitrary normals. /// Arbitrary = 1 << 2, /// /// Include all plane orientations. /// AllOrientations = Vertical | Horizontal | Arbitrary, /// /// For non-horizontal planes, setting this flag will result in the top of /// the plane rectangle being perpendicular to gravity. /// OrientToGravity = 1 << 3, /// /// If this flag is set, inner planes will be returned; if it is not set, /// outer planes will be returned. /// Inner = 1 << 4, /// /// Include planes semantically tagged as ceiling. /// Semantic_Ceiling = 1 << 6, /// /// Include planes semantically tagged as floor. /// Semantic_Floor = 1 << 7, /// /// Include planes semantically tagged as wall. /// Semantic_Wall = 1 << 8, /// /// Include all planes that are semantically tagged. /// Semantic_All = Semantic_Ceiling | Semantic_Floor | Semantic_Wall, /// /// Include polygonal planes. (Planes that have more than 4 edges. /// /// /// /// The MLPlanesReleaseBoundariesList, MLPlanesQueryGetResultsWithBoundaries, MLPlanesQueryGetResults /// calls are handled automatically when using the Magic Leap Plane subsystem /// /// When this flag is set: /// /// /// MLPlanesQueryGetResultsWithBoundaries /// /// returns polygons along with /// other applicable rectangular planes. MLPlanesReleaseBoundariesList /// MUST be called before the next call to MLPlanesQueryGetResultsWithBoundaries /// or MLPlanesQueryGetResults, otherwise UnspecifiedFailure will be returned. /// /// /// /// MLPlanesQueryGetResults /// /// returns just the rectangular planes. /// polygons (if any) extracted during the query will be discarded. /// No need to call MLPlanesReleaseBoundariesList before the /// next MLPlanesQueryGetResultsWithBoundaries or MLPlanesQueryGetResults. /// /// /// /// When this flag is not set: /// /// /// both the APIs /// /// MLPlanesQueryGetResultsWithBoundaries and /// MLPlanesQueryGetResults returns just rectangular planes. /// No need to call MLPlanesReleaseBoundariesList. /// /// /// /// Polygons = 1 << 9, } } } public static class MLPlanesQueryFlagsAndPlaneDetectionModeExtensions { public static PlaneDetectionMode ToPlaneDetectionMode(this PlanesSubsystem.Extensions.MLPlanesQueryFlags MLPlanesQueryFlags) { var outDetectionMode = PlaneDetectionMode.None; if ((MLPlanesQueryFlags & PlanesSubsystem.Extensions.MLPlanesQueryFlags.Horizontal) != 0) outDetectionMode |= PlaneDetectionMode.Horizontal; if ((MLPlanesQueryFlags & PlanesSubsystem.Extensions.MLPlanesQueryFlags.Vertical) != 0) outDetectionMode |= PlaneDetectionMode.Vertical; return outDetectionMode; } public static PlanesSubsystem.Extensions.MLPlanesQueryFlags ToMLQueryFlags(this PlaneDetectionMode planeDetectionMode) { var outFlags = PlanesSubsystem.Extensions.MLPlanesQueryFlags.None; if ((planeDetectionMode & PlaneDetectionMode.Horizontal) != 0) outFlags |= PlanesSubsystem.Extensions.MLPlanesQueryFlags.Horizontal; if ((planeDetectionMode & PlaneDetectionMode.Vertical) != 0) outFlags |= PlanesSubsystem.Extensions.MLPlanesQueryFlags.Vertical; return outFlags; } } }