Update BooleanCutTool.cpp

This commit is contained in:
2025-04-18 11:07:14 +08:00
parent 0469c98285
commit c30cb1052e

View File

@@ -125,7 +125,26 @@ TArray<UProceduralMeshComponent*> UBooleanCutTool::CutProceduralMesh(UProcedural
TArray<FColor> VertexColors;
TArray<FProcMeshTangent> Tangents;
TargetMesh->GetSectionMeshData(0, Vertices, Triangles, Normals, UVs, VertexColors, Tangents);
// 在 UE5.5.4 中GetSectionMeshData 方法已不存在,改为使用 GetProcMeshSection 方法
FProcMeshSection* MeshSection = TargetMesh->GetProcMeshSection(0);
if (MeshSection)
{
// 从 MeshSection 中提取数据
for (const FProcMeshVertex& Vertex : MeshSection->ProcVertexBuffer)
{
Vertices.Add(Vertex.Position);
Normals.Add(Vertex.Normal);
UVs.Add(Vertex.UV0);
VertexColors.Add(Vertex.Color);
Tangents.Add(Vertex.Tangent);
}
// 转换索引
for (uint32 Index : MeshSection->ProcIndexBuffer)
{
Triangles.Add(static_cast<int32>(Index));
}
}
// Calculate intersection points between cut plane and mesh
TArray<FVector> IntersectionPoints = CalculateIntersectionPoints(Vertices, Triangles, CutPlane);