Class ConvexHullHelper
- Namespace
- BepuPhysics.Collidables
- Assembly
- BepuPhysics.dll
Helper methods to create and process convex hulls from point clouds.
public static class ConvexHullHelper
- Inheritance
-
ConvexHullHelper
- Inherited Members
Methods
ComputeHull(Span<Vector3>, BufferPool, out HullData)
Computes the convex hull of a set of points.
public static void ComputeHull(Span<Vector3> points, BufferPool pool, out HullData hullData)
Parameters
pointsSpan<Vector3>Point set to compute the convex hull of.
poolBufferPoolBuffer pool to pull memory from when creating the hull.
hullDataHullDataConvex hull of the input point set.
CreateShape(Span<Vector3>, HullData, BufferPool, out Vector3, out ConvexHull)
Processes hull data into a runtime usable convex hull shape. Recenters the convex hull's points around its center of mass.
public static bool CreateShape(Span<Vector3> points, HullData hullData, BufferPool pool, out Vector3 center, out ConvexHull hullShape)
Parameters
pointsSpan<Vector3>Point array into which the hull data indexes.
hullDataHullDataRaw input data to process.
poolBufferPoolPool used to allocate resources for the hullShape.
centerVector3Computed center of mass of the convex hull before its points were recentered onto the origin.
hullShapeConvexHullConvex hull shape created from the input data.
Returns
- bool
True if the shape was created successfully, false otherwise. If false, the hull probably had no volume and would not have worked properly as a shape.
CreateShape(Span<Vector3>, BufferPool, out HullData, out Vector3, out ConvexHull)
Creates a convex hull shape out of an input point set. Recenters the convex hull's points around its center of mass.
public static bool CreateShape(Span<Vector3> points, BufferPool pool, out HullData hullData, out Vector3 center, out ConvexHull convexHull)
Parameters
pointsSpan<Vector3>Points to use to create the hull.
poolBufferPoolBuffer pool used for temporary allocations and the output data structures.
hullDataHullDataIntermediate hull data that got processed into the convex hull.
centerVector3Computed center of mass of the convex hull before its points were recentered onto the origin.
convexHullConvexHullConvex hull shape of the input point set.
Returns
- bool
True if the shape was created successfully, false otherwise. If false, the hull probably had no volume and would not have worked properly as a shape.
CreateShape(Span<Vector3>, BufferPool, out Vector3, out ConvexHull)
Creates a convex hull shape out of an input point set. Recenters the convex hull's points around its center of mass.
public static bool CreateShape(Span<Vector3> points, BufferPool pool, out Vector3 center, out ConvexHull convexHull)
Parameters
pointsSpan<Vector3>Points to use to create the hull.
poolBufferPoolBuffer pool used for temporary allocations and the output data structures.
centerVector3Computed center of mass of the convex hull before its points were recentered onto the origin.
convexHullConvexHullConvex hull shape of the input point set.
Returns
- bool
True if the shape was created successfully, false otherwise. If false, the hull probably had no volume and would not have worked properly as a shape.
CreateTransformedCopy(in ConvexHull, in Matrix3x3, BufferPool, out ConvexHull)
Creates a transformed copy of a convex hull. Unique FaceVertexIndices and FaceToVertexIndicesStart buffers are allocated for the copy target.
public static void CreateTransformedCopy(in ConvexHull source, in Matrix3x3 transform, BufferPool pool, out ConvexHull target)
Parameters
sourceConvexHullSource convex hull to copy.
transformMatrix3x3Transform to apply to the hull points.
poolBufferPoolPool from which to allocate the new hull's buffers.
targetConvexHullTarget convex hull to copy into.
CreateTransformedCopy(in ConvexHull, in Matrix3x3, Buffer<Vector3Wide>, Buffer<HullBoundingPlanes>)
Creates a transformed copy of a convex hull.
public static void CreateTransformedCopy(in ConvexHull source, in Matrix3x3 transform, Buffer<Vector3Wide> targetPoints, Buffer<HullBoundingPlanes> targetBoundingPlanes)
Parameters
sourceConvexHullSource convex hull to copy.
transformMatrix3x3Transform to apply to the hull points.
targetPointsBuffer<Vector3Wide>Transformed points in the copy target hull.
targetBoundingPlanesBuffer<HullBoundingPlanes>Transformed bounding planes in the copy target hull.
CreateTransformedShallowCopy(in ConvexHull, in Matrix3x3, BufferPool, out ConvexHull)
Creates a transformed copy of a convex hull. FaceVertexIndices and FaceToVertexIndicesStart buffers from the source are reused in the copy target. Note that disposing two convex hulls with the same buffers will cause errors; disposal must be handled carefully to avoid double freeing the shared buffers.
public static void CreateTransformedShallowCopy(in ConvexHull source, in Matrix3x3 transform, BufferPool pool, out ConvexHull target)
Parameters
sourceConvexHullSource convex hull to copy.
transformMatrix3x3Transform to apply to the hull points.
poolBufferPoolPool from which to allocate the new hull's points and bounding planes buffers.
targetConvexHullTarget convex hull to copy into. FaceVertexIndices and FaceToVertexIndicesStart buffers are reused from the source.