Struct ConvexHullBuilder | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Struct ConvexHullBuilder

    Convex hull builder.

    Namespace: Unity.Physics
    Syntax
    public struct ConvexHullBuilder : IDisposable

    Constructors

    ConvexHullBuilder(Int32, Int32, Allocator)

    Create using internal storage.

    Declaration
    public ConvexHullBuilder(int verticesCapacity, int trianglesCapacity, Allocator allocator = null)
    Parameters
    Type Name Description
    System.Int32 verticesCapacity
    System.Int32 trianglesCapacity
    Allocator allocator

    ConvexHullBuilder(ConvexHullBuilder.Vertex*, Int32, ConvexHullBuilder.Triangle*, Int32)

    Create using external storage.

    Declaration
    public ConvexHullBuilder(ConvexHullBuilder.Vertex*vertices, int verticesCapacity, ConvexHullBuilder.Triangle*triangles, int triangleCapacity)
    Parameters
    Type Name Description
    ConvexHullBuilder.Vertex* vertices
    System.Int32 verticesCapacity
    ConvexHullBuilder.Triangle* triangles
    System.Int32 triangleCapacity

    Fields

    Triangles

    Declaration
    public ElementPool<ConvexHullBuilder.Triangle> Triangles
    Field Value
    Type Description
    ElementPool<ConvexHullBuilder.Triangle>

    Vertices

    Declaration
    public ElementPool<ConvexHullBuilder.Vertex> Vertices
    Field Value
    Type Description
    ElementPool<ConvexHullBuilder.Vertex>

    Properties

    Dimension

    Declaration
    public int Dimension { get; }
    Property Value
    Type Description
    System.Int32

    IntegerSpaceAabb

    Declaration
    public Aabb IntegerSpaceAabb { get; set; }
    Property Value
    Type Description
    Aabb

    NumFaces

    Declaration
    public int NumFaces { get; }
    Property Value
    Type Description
    System.Int32

    NumFaceVertices

    Declaration
    public int NumFaceVertices { get; }
    Property Value
    Type Description
    System.Int32

    ProjectionPlane

    Declaration
    public Plane ProjectionPlane { get; }
    Property Value
    Type Description
    Plane

    Methods

    AddPoint(float3, UInt32)

    Add a point the the convex hull.

    Declaration
    public bool AddPoint(float3 point, uint userData = 0U)
    Parameters
    Type Name Description
    float3 point

    Point to insert.

    System.UInt32 userData

    User data attached to the new vertex if insertion succeeds.

    Returns
    Type Description
    System.Boolean

    true if the insertion succeeded, false otherwise.

    ApexVertex(ConvexHullBuilder.Edge)

    Declaration
    public int ApexVertex(ConvexHullBuilder.Edge edge)
    Parameters
    Type Name Description
    ConvexHullBuilder.Edge edge
    Returns
    Type Description
    System.Int32

    BuildFaceIndices(Single)

    Set the face index for each triangle. Triangles lying in the same plane will have the same face index.

    Declaration
    public void BuildFaceIndices(float maxAngle = 0.0174532924F)
    Parameters
    Type Name Description
    System.Single maxAngle

    ComputeAabb()

    Returns the AABB of the convex hull.

    Declaration
    public Aabb ComputeAabb()
    Returns
    Type Description
    Aabb

    ComputeCentroid()

    Returns the centroid of the convex hull.

    Declaration
    public float3 ComputeCentroid()
    Returns
    Type Description
    float3

    ComputeMassProperties()

    Compute the mass properties of the convex hull. Note: Inertia computation adapted from S. Melax, http://www.melax.com/volint.

    Declaration
    public ConvexHullBuilder.MassProperties ComputeMassProperties()
    Returns
    Type Description
    ConvexHullBuilder.MassProperties

    ComputePlane(Int32, Boolean)

    Declaration
    public Plane ComputePlane(int triangleIndex, bool fromIntCoordinates = true)
    Parameters
    Type Name Description
    System.Int32 triangleIndex
    System.Boolean fromIntCoordinates
    Returns
    Type Description
    Plane

    ComputeSupportingVertex(float3)

    Returns the supporting vertex index in a given direction.

    Declaration
    public int ComputeSupportingVertex(float3 direction)
    Parameters
    Type Name Description
    float3 direction
    Returns
    Type Description
    System.Int32

    ComputeVertexNormal(Int32)

    Compute vertex normal.

    Declaration
    public float3 ComputeVertexNormal(int vertex)
    Parameters
    Type Name Description
    System.Int32 vertex
    Returns
    Type Description
    float3

    ComputeVertexNormal(ConvexHullBuilder.Edge)

    Compute vertex normal.

    Declaration
    public float3 ComputeVertexNormal(ConvexHullBuilder.Edge edge)
    Parameters
    Type Name Description
    ConvexHullBuilder.Edge edge
    Returns
    Type Description
    float3

    CopyFrom(ConvexHullBuilder)

    Copy the content of another convex hull into this one.

    Declaration
    public void CopyFrom(ConvexHullBuilder other)
    Parameters
    Type Name Description
    ConvexHullBuilder other

    Dispose()

    Dispose internal convex hull storages if any.

    Declaration
    public void Dispose()

    EndVertex(ConvexHullBuilder.Edge)

    Declaration
    public int EndVertex(ConvexHullBuilder.Edge edge)
    Parameters
    Type Name Description
    ConvexHullBuilder.Edge edge
    Returns
    Type Description
    System.Int32

    GetFirstFace()

    Returns (the first edge of) the first face.

    Declaration
    public ConvexHullBuilder.FaceEdge GetFirstFace()
    Returns
    Type Description
    ConvexHullBuilder.FaceEdge

    GetFirstFace(Int32)

    Returns the first face edge from a given face index.

    Declaration
    public ConvexHullBuilder.FaceEdge GetFirstFace(int faceIndex)
    Parameters
    Type Name Description
    System.Int32 faceIndex
    Returns
    Type Description
    ConvexHullBuilder.FaceEdge

    GetFirstPrimaryEdge()

    Declaration
    public ConvexHullBuilder.Edge GetFirstPrimaryEdge()
    Returns
    Type Description
    ConvexHullBuilder.Edge

    GetLinkedEdge(ConvexHullBuilder.Edge)

    Returns an edge's linked edge on the neighboring triangle.

    Declaration
    public ConvexHullBuilder.Edge GetLinkedEdge(ConvexHullBuilder.Edge edge)
    Parameters
    Type Name Description
    ConvexHullBuilder.Edge edge
    Returns
    Type Description
    ConvexHullBuilder.Edge

    GetNextFace(ConvexHullBuilder.FaceEdge)

    Returns (the first edge of) the next face.

    Declaration
    public ConvexHullBuilder.FaceEdge GetNextFace(ConvexHullBuilder.FaceEdge fe)
    Parameters
    Type Name Description
    ConvexHullBuilder.FaceEdge fe
    Returns
    Type Description
    ConvexHullBuilder.FaceEdge

    GetNextFaceEdge(ConvexHullBuilder.FaceEdge)

    Returns the next edge within a face.

    Declaration
    public ConvexHullBuilder.FaceEdge GetNextFaceEdge(ConvexHullBuilder.FaceEdge fe)
    Parameters
    Type Name Description
    ConvexHullBuilder.FaceEdge fe
    Returns
    Type Description
    ConvexHullBuilder.FaceEdge

    GetNextPrimaryEdge(ConvexHullBuilder.Edge)

    Declaration
    public ConvexHullBuilder.Edge GetNextPrimaryEdge(ConvexHullBuilder.Edge edge)
    Parameters
    Type Name Description
    ConvexHullBuilder.Edge edge
    Returns
    Type Description
    ConvexHullBuilder.Edge

    GetVertexEdge(Int32)

    Returns one of the triangle edges starting from a given vertex. Note: May be one of the inner edges of a face.

    Declaration
    public ConvexHullBuilder.Edge GetVertexEdge(int vertexIndex)
    Parameters
    Type Name Description
    System.Int32 vertexIndex
    Returns
    Type Description
    ConvexHullBuilder.Edge

    OffsetVertices(Single, Single)

    Offset vertices with respect to the surface by a given amount while minimizing distortions.

    Declaration
    public void OffsetVertices(float surfaceOffset, float minRadius = 0F)
    Parameters
    Type Name Description
    System.Single surfaceOffset

    a positive value will move vertices outward while a negative value will push them toward the inside

    System.Single minRadius

    Prevent vertices to be shrunk too much

    RemoveRedundantVertices(Single)

    Remove redundant (colinear, coplanar) vertices from a 3D convex hull.

    Declaration
    public void RemoveRedundantVertices(float minCosAngle = 0.999F)
    Parameters
    Type Name Description
    System.Single minCosAngle

    Assume that edges that form a angle smaller than this value are flat

    Reset(Boolean)

    Reset the convex hull.

    Declaration
    public void Reset(bool keepIntegerSpaceAabb = false)
    Parameters
    Type Name Description
    System.Boolean keepIntegerSpaceAabb

    SimplifyFaces(Single, Int32, Int32, Single)

    Simplify faces.

    Declaration
    public void SimplifyFaces(float minError, int maxFaces = 2147483647, int maxVertices = 2147483647, float minAngle = 0F)
    Parameters
    Type Name Description
    System.Single minError

    Stop refining when the error is below this number (unit: distance)

    System.Int32 maxFaces

    Maximum number of faces allowed.

    System.Int32 maxVertices

    Maximum number of vertices allowed

    System.Single minAngle

    Do not generate face that form an angle smaller than this value with its neighbors (unit: angle in radian)

    SimplifyVertices(Single, Int32, Single)

    Simplify convex hull.

    Declaration
    public void SimplifyVertices(float maxError, int minVertices = 0, float volumeConservation = 1F)
    Parameters
    Type Name Description
    System.Single maxError
    System.Int32 minVertices
    System.Single volumeConservation

    SplitByPlane(Plane, out ConvexHullBuilder, out ConvexHullBuilder, UInt32)

    Split this convex hull by a plane.

    Declaration
    public void SplitByPlane(Plane plane, out ConvexHullBuilder negHull, out ConvexHullBuilder posHull, uint isecUserData = 0U)
    Parameters
    Type Name Description
    Plane plane
    ConvexHullBuilder negHull
    ConvexHullBuilder posHull
    System.UInt32 isecUserData

    StartVertex(ConvexHullBuilder.Edge)

    Declaration
    public int StartVertex(ConvexHullBuilder.Edge edge)
    Parameters
    Type Name Description
    ConvexHullBuilder.Edge edge
    Returns
    Type Description
    System.Int32

    Extension Methods

    ConvexHullBuilderExtensions.CompactVertices(ConvexHullBuilder)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023