generateStaticMesh(positions:faceIndices:)
Creates a static collision mesh from an array of vertex positions and face indices.
Declaration
nonisolated static func generateStaticMesh(positions: [SIMD3<Float>], faceIndices: [UInt16]) async throws -> ShapeResourceParameters
- positions:
An array of vertex positions containing discrete points on the mesh.
- faceIndices:
An array of integers used to index into the position array. Each three indices define a polygon in the mesh.
Discussion
The triangle mesh is pre-processed into an optimized format before being used by the physics engine. The pre-processing step can take significant time if the position counts are large. To minimize this cost, the position count should be as small as possible. The returned ShapeResource can only be used under the following circumstances:
This shape can only be used with
PhysicsBodyMode.staticand not.dynamicor.kinematic.This shape cannot be used with
CollisionComponent.Mode.trigger.