Add CookCollision to collision data with triangles as int32
This commit is contained in:
@@ -78,6 +78,21 @@ bool CollisionData::CookCollision(CollisionDataType type, const Span<Vector3>& v
|
|||||||
return CookCollision(type, &modelData, convexFlags, convexVertexLimit);
|
return CookCollision(type, &modelData, convexFlags, convexVertexLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CollisionData::CookCollision(CollisionDataType type, const Span<Vector3>& vertices, const Span<int32>& triangles, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit)
|
||||||
|
{
|
||||||
|
CHECK_RETURN(vertices.Length() != 0, true);
|
||||||
|
CHECK_RETURN(triangles.Length() != 0 && triangles.Length() % 3 == 0, true);
|
||||||
|
ModelData modelData;
|
||||||
|
modelData.LODs.Resize(1);
|
||||||
|
auto meshData = New<MeshData>();
|
||||||
|
modelData.LODs[0].Meshes.Add(meshData);
|
||||||
|
meshData->Positions.Set(vertices.Get(), vertices.Length());
|
||||||
|
meshData->Indices.Resize(triangles.Length());
|
||||||
|
for (int32 i = 0; i < triangles.Length(); i++)
|
||||||
|
meshData->Indices.Get()[i] = triangles.Get()[i];
|
||||||
|
return CookCollision(type, &modelData, convexFlags, convexVertexLimit);
|
||||||
|
}
|
||||||
|
|
||||||
bool CollisionData::CookCollision(CollisionDataType type, ModelData* modelData, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit)
|
bool CollisionData::CookCollision(CollisionDataType type, ModelData* modelData, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit)
|
||||||
{
|
{
|
||||||
// Validate state
|
// Validate state
|
||||||
|
|||||||
@@ -223,6 +223,19 @@ public:
|
|||||||
/// <param name="convexVertexLimit">The convex mesh vertex limit. Use values in range [8;255]</param>
|
/// <param name="convexVertexLimit">The convex mesh vertex limit. Use values in range [8;255]</param>
|
||||||
API_FUNCTION() bool CookCollision(CollisionDataType type, const Span<Vector3>& vertices, const Span<uint32>& triangles, ConvexMeshGenerationFlags convexFlags = ConvexMeshGenerationFlags::None, int32 convexVertexLimit = 255);
|
API_FUNCTION() bool CookCollision(CollisionDataType type, const Span<Vector3>& vertices, const Span<uint32>& triangles, ConvexMeshGenerationFlags convexFlags = ConvexMeshGenerationFlags::None, int32 convexVertexLimit = 255);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cooks the mesh collision data and updates the virtual asset. action cannot be performed on a main thread.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Can be used only for virtual assets (see <see cref="Asset.IsVirtual"/> and <see cref="Content.CreateVirtualAsset{T}"/>).
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="type">The collision data type.</param>
|
||||||
|
/// <param name="vertices">The source geometry vertex buffer with vertices positions. Cannot be empty.</param>
|
||||||
|
/// <param name="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).</param>
|
||||||
|
/// <param name="convexFlags">The convex mesh generation flags.</param>
|
||||||
|
/// <param name="convexVertexLimit">The convex mesh vertex limit. Use values in range [8;255]</param>
|
||||||
|
API_FUNCTION() bool CookCollision(CollisionDataType type, const Span<Vector3>& vertices, const Span<int32>& triangles, ConvexMeshGenerationFlags convexFlags = ConvexMeshGenerationFlags::None, int32 convexVertexLimit = 255);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cooks the mesh collision data and updates the virtual asset. action cannot be performed on a main thread.
|
/// Cooks the mesh collision data and updates the virtual asset. action cannot be performed on a main thread.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user