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
points
Span<Vector3>Point set to compute the convex hull of.
pool
BufferPoolBuffer pool to pull memory from when creating the hull.
hullData
HullDataConvex 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
points
Span<Vector3>Point array into which the hull data indexes.
hullData
HullDataRaw input data to process.
pool
BufferPoolPool used to allocate resources for the hullShape.
center
Vector3Computed center of mass of the convex hull before its points were recentered onto the origin.
hullShape
ConvexHullConvex 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
points
Span<Vector3>Points to use to create the hull.
pool
BufferPoolBuffer pool used for temporary allocations and the output data structures.
hullData
HullDataIntermediate hull data that got processed into the convex hull.
center
Vector3Computed center of mass of the convex hull before its points were recentered onto the origin.
convexHull
ConvexHullConvex 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
points
Span<Vector3>Points to use to create the hull.
pool
BufferPoolBuffer pool used for temporary allocations and the output data structures.
center
Vector3Computed center of mass of the convex hull before its points were recentered onto the origin.
convexHull
ConvexHullConvex 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
source
ConvexHullSource convex hull to copy.
transform
Matrix3x3Transform to apply to the hull points.
pool
BufferPoolPool from which to allocate the new hull's buffers.
target
ConvexHullTarget 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
source
ConvexHullSource convex hull to copy.
transform
Matrix3x3Transform to apply to the hull points.
targetPoints
Buffer<Vector3Wide>Transformed points in the copy target hull.
targetBoundingPlanes
Buffer<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
source
ConvexHullSource convex hull to copy.
transform
Matrix3x3Transform to apply to the hull points.
pool
BufferPoolPool from which to allocate the new hull's points and bounding planes buffers.
target
ConvexHullTarget convex hull to copy into. FaceVertexIndices and FaceToVertexIndicesStart buffers are reused from the source.