C# Class HoloToolkit.Unity.PlaneFinding

Mostrar archivo Open project: Microsoft/HoloToolkit-Unity Class Usage Examples

Public Methods

Method Description
FindPlanes ( List meshes, float snapToGravityThreshold = 0.0f, float minArea = 0.0f ) : HoloToolkit.Unity.BoundedPlane[]

Convenience wrapper that executes FindSubPlanes followed by MergeSubPlanes via a single call into native code (which improves performance by avoiding a bunch of unnecessary data marshalling and a managed-to-native transition).

FindSubPlanes ( List meshes, float snapToGravityThreshold = 0.0f ) : HoloToolkit.Unity.BoundedPlane[]

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.

MergeSubPlanes ( BoundedPlane subPlanes, float snapToGravityThreshold = 0.0f, float minArea = 0.0f ) : HoloToolkit.Unity.BoundedPlane[]

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.

Private Methods

Method Description
FinishPlaneFinding ( ) : void

Cleanup after finishing a PlaneFinding API call by unpinning any memory that was pinned for the call into the driver, and then reset the findPlanesRunning bool.

MarshalBoundedPlanesFromIntPtr ( IntPtr outArray, int size ) : HoloToolkit.Unity.BoundedPlane[]

Marshals BoundedPlane data returned from a DLL API call into a managed BoundedPlane array and then frees the memory that was allocated within the DLL.

Disabling warning 618 when calling Marshal.SizeOf(), because Unity does not support .Net 4.5.1+ for using the preferred Marshal.SizeOf(T) method."/>,

PinMeshDataForMarshalling ( List meshes ) : IntPtr

Copies the supplied mesh data into the reusedMeshesForMarhsalling array. All managed arrays are pinned so that the marshalling only needs to pass a pointer and the native code can reference the memory in place without needing the marshaller to create a complete copy of the data.

PinObject ( System obj ) : IntPtr

Pins the specified object so that the backing memory can not be relocated, adds the pinned memory handle to the tracking list, and then returns that address of the pinned memory so that it can be passed into the DLL to be access directly from native code.

StartPlaneFinding ( ) : void

Validate that no other PlaneFinding API call is currently in progress. As a performance optimization to avoid unnecessarily thrashing the garbage collector, each call into the PlaneFinding DLL reuses a couple of static data structures. As a result, we can't handle multiple concurrent calls into these APIs.

UnpinAllObjects ( ) : void

Unpins all of the memory previously pinned by calls to PinObject().

Method Details

FindPlanes() public static method

Convenience wrapper that executes FindSubPlanes followed by MergeSubPlanes via a single call into native code (which improves performance by avoiding a bunch of unnecessary data marshalling and a managed-to-native transition).
public static FindPlanes ( List meshes, float snapToGravityThreshold = 0.0f, float minArea = 0.0f ) : HoloToolkit.Unity.BoundedPlane[]
meshes List /// List of meshes to run the plane finding algorithm on. ///
snapToGravityThreshold float /// 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. ///
minArea float /// While merging subplanes together, any candidate merged plane whose constituent mesh /// triangles have a total area less than this threshold are ignored. ///
return HoloToolkit.Unity.BoundedPlane[]

FindSubPlanes() public static method

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.
public static FindSubPlanes ( List meshes, float snapToGravityThreshold = 0.0f ) : HoloToolkit.Unity.BoundedPlane[]
meshes List /// List of meshes to run the plane finding algorithm on. ///
snapToGravityThreshold float /// 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. ///
return HoloToolkit.Unity.BoundedPlane[]

MergeSubPlanes() public static method

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.
public static MergeSubPlanes ( BoundedPlane subPlanes, float snapToGravityThreshold = 0.0f, float minArea = 0.0f ) : HoloToolkit.Unity.BoundedPlane[]
subPlanes BoundedPlane /// The output from one or more previous calls to FindSubPlanes(). ///
snapToGravityThreshold float /// 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. ///
minArea float /// While merging subplanes together, any candidate merged plane whose constituent mesh /// triangles have a total area less than this threshold are ignored. ///
return HoloToolkit.Unity.BoundedPlane[]