Class CollisionData
Represents a physics mesh that can be used with a MeshCollider. Physics mesh can be a generic triangle mesh or a convex mesh.
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public class CollisionData : BinaryAsset
Constructors
CollisionData()
Properties
Options
Gets the options.
Declaration
[Unmanaged]
public CollisionDataOptions Options { get; }
Property Value
CollisionDataOptions
|
Methods
CookCollision(CollisionDataType, Float3[], Int32[], ConvexMeshGenerationFlags, Int32)
Cooks the mesh collision data and updates the virtual asset. action cannot be performed on a main thread.
Declaration
[Unmanaged]
public bool CookCollision(CollisionDataType type, Float3[] vertices, int[] triangles, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit = 255)
Parameters
CollisionDataType
type
The collision data type. |
Float3[]
vertices
The source geometry vertex buffer with vertices positions. Cannot be empty. |
System.Int32[]
triangles
The source data index buffer (triangles list). Uses 32-bit stride buffer. Cannot be empty. Length must be multiple of 3 (as 3 vertices build a triangle). |
ConvexMeshGenerationFlags
convexFlags
The convex mesh generation flags. |
System.Int32
convexVertexLimit
The convex mesh vertex limit. Use values in range [8;255] |
Returns
System.Boolean
True if failed, otherwise false. |
Remarks
Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()).
CookCollision(CollisionDataType, Float3[], UInt32[], ConvexMeshGenerationFlags, Int32)
Cooks the mesh collision data and updates the virtual asset. action cannot be performed on a main thread.
Declaration
[Unmanaged]
public bool CookCollision(CollisionDataType type, Float3[] vertices, uint[] triangles, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit = 255)
Parameters
CollisionDataType
type
The collision data type. |
Float3[]
vertices
The source geometry vertex buffer with vertices positions. Cannot be empty. |
System.UInt32[]
triangles
The source data index buffer (triangles list). Uses 32-bit stride buffer. Cannot be empty. Length must be multiple of 3 (as 3 vertices build a triangle). |
ConvexMeshGenerationFlags
convexFlags
The convex mesh generation flags. |
System.Int32
convexVertexLimit
The convex mesh vertex limit. Use values in range [8;255] |
Returns
System.Boolean
True if failed, otherwise false. |
Remarks
Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()).
CookCollision(CollisionDataType, ModelBase, Int32, UInt32, ConvexMeshGenerationFlags, Int32)
Cooks the mesh collision data and updates the virtual asset.
Declaration
[Unmanaged]
public bool CookCollision(CollisionDataType type, ModelBase model, int modelLodIndex = 0, uint materialSlotsMask = 4294967295U, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit = 255)
Parameters
CollisionDataType
type
The collision data type. |
ModelBase
model
The source model. If model is virtual then this method cannot be called from the main thread. |
System.Int32
modelLodIndex
The source model LOD index. |
System.UInt32
materialSlotsMask
The source model material slots mask. One bit per-slot. Can be used to exclude particular material slots from collision cooking. |
ConvexMeshGenerationFlags
convexFlags
The convex mesh generation flags. |
System.Int32
convexVertexLimit
The convex mesh vertex limit. Use values in range [8;255] |
Returns
System.Boolean
True if failed, otherwise false. |
Remarks
Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()).
CookCollision(CollisionDataType, Vector3[], Int32[], ConvexMeshGenerationFlags, Int32)
Cooks the mesh collision data and updates the virtual asset. action cannot be performed on a main thread. [Deprecated on 16.06.2022, expires on 16.06.2024]
Declaration
public bool CookCollision(CollisionDataType type, Vector3[] vertices, int[] triangles, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit = 255)
Parameters
CollisionDataType
type
The collision data type. |
Vector3[]
vertices
The source geometry vertex buffer with vertices positions. Cannot be empty. |
System.Int32[]
triangles
The source data index buffer (triangles list). Uses 32-bit stride buffer. Cannot be empty. Length must be multiple of 3 (as 3 vertices build a triangle). |
ConvexMeshGenerationFlags
convexFlags
The convex mesh generation flags. |
System.Int32
convexVertexLimit
The convex mesh vertex limit. Use values in range [8;255] |
Returns
System.Boolean
True if failed, otherwise false. |
Remarks
Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()).
CookCollision(CollisionDataType, Vector3[], UInt32[], ConvexMeshGenerationFlags, Int32)
Cooks the mesh collision data and updates the virtual asset. action cannot be performed on a main thread. [Deprecated on 16.06.2022, expires on 16.06.2024]
Declaration
public bool CookCollision(CollisionDataType type, Vector3[] vertices, uint[] triangles, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit = 255)
Parameters
CollisionDataType
type
The collision data type. |
Vector3[]
vertices
The source geometry vertex buffer with vertices positions. Cannot be empty. |
System.UInt32[]
triangles
The source data index buffer (triangles list). Uses 32-bit stride buffer. Cannot be empty. Length must be multiple of 3 (as 3 vertices build a triangle). |
ConvexMeshGenerationFlags
convexFlags
The convex mesh generation flags. |
System.Int32
convexVertexLimit
The convex mesh vertex limit. Use values in range [8;255] |
Returns
System.Boolean
True if failed, otherwise false. |
Remarks
Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()).
ExtractGeometry(out Float3[], out Int32[])
Extracts the collision data geometry into list of triangles.
Declaration
[Unmanaged]
public void ExtractGeometry(out Float3[] vertexBuffer, out int[] indexBuffer)
Parameters
Float3[]
vertexBuffer
The output vertex buffer. |
System.Int32[]
indexBuffer
The output index buffer. |
ExtractGeometry(out Vector3[], out Int32[])
Extracts the collision data geometry into list of triangles. [Deprecated on 16.06.2022, expires on 16.06.2024]
Declaration
public void ExtractGeometry(out Vector3[] vertexBuffer, out int[] indexBuffer)
Parameters
Vector3[]
vertexBuffer
The output vertex buffer. |
System.Int32[]
indexBuffer
The output index buffer. |
GetModelTriangle(UInt32, out MeshBase, out UInt32)
Extracts the triangle index of the original mesh data used for cooking this collision data. Can be used to get vertex attributes of the triangle mesh hit by the raycast.
Declaration
[Unmanaged]
public bool GetModelTriangle(uint faceIndex, out MeshBase mesh, out uint meshTriangleIndex)
Parameters
System.UInt32
faceIndex
The face index of the collision mesh. |
MeshBase
mesh
The result source mesh used to build this collision data (can be null if collision data was cooked using custom geometry without source Model set). |
System.UInt32
meshTriangleIndex
The result triangle index of the source geometry used to build this collision data. |
Returns
System.Boolean
True if got a valid triangle index, otherwise false. |
Remarks
Supported only for collision data built as triangle mesh and without SuppressFaceRemapTable flag set.