Struct ConvexHullBuilder
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
Fields
Triangles
Declaration
public ElementPool<ConvexHullBuilder.Triangle> Triangles
Field Value
Vertices
Declaration
public ElementPool<ConvexHullBuilder.Vertex> Vertices
Field Value
Properties
Dimension
Declaration
public int Dimension { get; }
Property Value
Type |
Description |
System.Int32 |
|
IntegerSpaceAabb
Declaration
public Aabb IntegerSpaceAabb { get; set; }
Property Value
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
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
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
ComputeCentroid()
Returns the centroid of the convex hull.
Declaration
public float3 ComputeCentroid()
Returns
ComputeMassProperties()
Declaration
public ConvexHullBuilder.MassProperties ComputeMassProperties()
Returns
ComputePlane(Int32, Boolean)
Declaration
public Plane ComputePlane(int triangleIndex, bool fromIntCoordinates = true)
Parameters
Type |
Name |
Description |
System.Int32 |
triangleIndex |
|
System.Boolean |
fromIntCoordinates |
|
Returns
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)
Declaration
public float3 ComputeVertexNormal(int vertex)
Parameters
Type |
Name |
Description |
System.Int32 |
vertex |
|
Returns
ComputeVertexNormal(ConvexHullBuilder.Edge)
Declaration
public float3 ComputeVertexNormal(ConvexHullBuilder.Edge edge)
Parameters
Returns
CopyFrom(ConvexHullBuilder)
Copy the content of another convex hull into this one.
Declaration
public void CopyFrom(ConvexHullBuilder other)
Parameters
Dispose()
Dispose internal convex hull storages if any.
Declaration
EndVertex(ConvexHullBuilder.Edge)
Declaration
public int EndVertex(ConvexHullBuilder.Edge edge)
Parameters
Returns
Type |
Description |
System.Int32 |
|
GetFirstFace()
Returns (the first edge of) the first face.
Declaration
public ConvexHullBuilder.FaceEdge GetFirstFace()
Returns
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
GetFirstPrimaryEdge()
Declaration
public ConvexHullBuilder.Edge GetFirstPrimaryEdge()
Returns
GetLinkedEdge(ConvexHullBuilder.Edge)
Returns an edge's linked edge on the neighboring triangle.
Declaration
public ConvexHullBuilder.Edge GetLinkedEdge(ConvexHullBuilder.Edge edge)
Parameters
Returns
GetNextFace(ConvexHullBuilder.FaceEdge)
Returns (the first edge of) the next face.
Declaration
public ConvexHullBuilder.FaceEdge GetNextFace(ConvexHullBuilder.FaceEdge fe)
Parameters
Returns
GetNextFaceEdge(ConvexHullBuilder.FaceEdge)
Returns the next edge within a face.
Declaration
public ConvexHullBuilder.FaceEdge GetNextFaceEdge(ConvexHullBuilder.FaceEdge fe)
Parameters
Returns
GetNextPrimaryEdge(ConvexHullBuilder.Edge)
Declaration
public ConvexHullBuilder.Edge GetNextPrimaryEdge(ConvexHullBuilder.Edge edge)
Parameters
Returns
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
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)
Declaration
public void Reset(bool keepIntegerSpaceAabb = false)
Parameters
Type |
Name |
Description |
System.Boolean |
keepIntegerSpaceAabb |
|
SimplifyFaces(Single, Int32, Int32, Single)
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)
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
StartVertex(ConvexHullBuilder.Edge)
Declaration
public int StartVertex(ConvexHullBuilder.Edge edge)
Parameters
Returns
Type |
Description |
System.Int32 |
|
Extension Methods
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.