/// <summary> /// Takes the subplanes returned by one or more previous calls to FindSubPlanes() and merges /// them together into larger planes that can potentially span across multiple meshes. /// Overlapping subplanes that have similar plane equations will be merged together to form /// larger planes. /// </summary> /// <param name="subPlanes"> /// The output from one or more previous calls to FindSubPlanes(). /// </param> /// <param name="snapToGravityThreshold"> /// Planes whose normal vectors are within this threshold (in degrees) from vertical/horizontal /// will be snapped to be perfectly gravity aligned. When set to something other than zero, the /// bounding boxes for each plane will be gravity aligned as well, rather than rotated for an /// optimally tight fit. Pass 0.0 for this parameter to completely disable the gravity alignment /// logic. /// </param> /// <param name="minArea"> /// While merging subplanes together, any candidate merged plane whose constituent mesh /// triangles have a total area less than this threshold are ignored. /// </param> public static BoundedPlane[] MergeSubPlanes(BoundedPlane[] subPlanes, float snapToGravityThreshold = 0.0f, float minArea = 0.0f) { StartPlaneFinding(); try { int planeCount; IntPtr planesPtr; DuLLImports.MergeSubPlanes(subPlanes.Length, PinObject(subPlanes), minArea, snapToGravityThreshold, out planeCount, out planesPtr); return(MarshalBoundedPlanesFromIntPtr(planesPtr, planeCount)); } finally { FinishPlaneFinding(); } }
/// <summary> /// Finds small planar patches that are contained within individual meshes. The output of this /// API can then be passed to MergeSubPlanes() in order to find larger planar surfaces that /// potentially span across multiple meshes. /// </summary> /// <param name="meshes"> /// List of meshes to run the plane finding algorithm on. /// </param> /// <param name="snapToGravityThreshold"> /// Planes whose normal vectors are within this threshold (in degrees) from vertical/horizontal /// will be snapped to be perfectly gravity aligned. When set to something other than zero, the /// bounding boxes for each plane will be gravity aligned as well, rather than rotated for an /// optimally tight fit. Pass 0.0 for this parameter to completely disable the gravity alignment /// logic. /// </param> public static BoundedPlane[] FindSubPlanes(List <MeshData> meshes, float snapToGravityThreshold = 0.0f) { StartPlaneFinding(); try { int planeCount; IntPtr planesPtr; IntPtr pinnedMeshData = PinMeshDataForMarshalling(meshes); DuLLImports.FindSubPlanes(meshes.Count, pinnedMeshData, snapToGravityThreshold, out planeCount, out planesPtr); return(MarshalBoundedPlanesFromIntPtr(planesPtr, planeCount)); } finally { FinishPlaneFinding(); } }