NvCloth for mobile

We are porting a game to Android and iOS using a modified UE 4.27. The base game relies heavily on NvCloth.

Before replacing our cloth system, we want to compile NvCloth for mobile to profile the actual performance cost. However, setting Target.bCompileNvCloth = true causes linker errors.

Looking at the engine source, mobile support is completely missing:

  • No precompiled libraries in Engine/Source/ThirdParty/PhysX3/Lib/Android/ARM64.
  • No mobile targets in Engine/Source/ThirdParty/PhysX3/NvCloth/compiler/cmake.

How can we get the missing CMake files or libraries to compile NvCloth for mobile ourselves, if realistic?

[Attachment Removed]

Hello Jerôme,

At first glance, based on the release notes and the contents of NvCloth.Build.cs, it seems nvcloth isn’t supported on mobile. However, in my local tests, bCompileNvCloth=True alone doesn’t seem to trigger errors in linkage. Are you able to provide more details as to their errors and a potential repro? Note that I am testing on the LTS 4.27 plus branch and not the 4.27 Chaos branch.

Best regards.

[Attachment Removed]

Hello Stéphane,

Thank you for your answer. Here are the details of our errors:

ld.lld: error: undefined symbol: NvClothCookFabricFromMesh(nv::cloth::Factory*, nv::cloth::ClothMeshDesc const&, physx::PxVec3 const&, physx::shdfnd::Array<int, nv::cloth::NonTrackingAllocator>*, bool)

17:37:57 >>> referenced by ClothingSimulationNv.cpp:185 (Runtime/ClothingSystemRuntimeNv/Private/ClothingSimulationNv.cpp:185)

17:37:57 >>> ClothingSystemRuntimeNv/Module.ClothingSystemRuntimeNv.cppa8.o:(FClothingSimulationNv::CreateActor(USkeletalMeshComponent*, UClothingAssetBase*, int))

17:37:57

17:37:57 ld.lld: error: undefined symbol: GetNvClothAllocator()

17:37:57 >>> referenced by Allocator.h:64 (ThirdParty/PhysX3/NvCloth/include/NvCloth/Allocator.h:64)

17:37:57 >>> ClothingSystemRuntimeNv/Module.ClothingSystemRuntimeNv.cppa8.o:(FClothingSimulationNv::CreateActor(USkeletalMeshComponent*, UClothingAssetBase*, int))

17:37:57

17:37:57 ld.lld: error: undefined symbol: nv::cloth::InitializeNvCloth(physx::PxAllocatorCallback*, physx::PxErrorCallback*, physx::PxAssertHandler*, physx::PxProfilerCallback*, int)

17:37:57 >>> referenced by NvClothSupport.cpp:128 (Runtime/ClothingSystemRuntimeNv/Private/NvClothSupport.cpp:128)

17:37:57 >>> ClothingSystemRuntimeNv/Module.ClothingSystemRuntimeNv.cppa8.o:(FClothingSystemRuntimeModuleNv::StartupModule())

17:37:57 >>> referenced by NvClothSupport.cpp:128 (Runtime/ClothingSystemRuntimeNv/Private/NvClothSupport.cpp:128)

17:37:57 >>> ClothingSystemRuntimeNv/Module.ClothingSystemRuntimeNv.cppa8.o:(NvClothSupport::InitializeNvClothingSystem())

17:37:57

17:37:57 ld.lld: error: undefined symbol: NvClothCreateFactoryCPU()

17:37:57 >>> referenced by ClothingSystemRuntimeModuleNv.cpp:35 (Runtime/ClothingSystemRuntimeNv/Private/ClothingSystemRuntimeModuleNv.cpp:35)

17:37:57 >>> ClothingSystemRuntimeNv/Module.ClothingSystemRuntimeNv.cppa8.o:(FClothingSystemRuntimeModuleNv::StartupModule())

17:37:57

17:37:57 ld.lld: error: undefined symbol: NvClothCreateMeshQuadifier()

17:37:57 >>> referenced by ClothingSystemRuntimeModuleNv.cpp:36 (Runtime/ClothingSystemRuntimeNv/Private/ClothingSystemRuntimeModuleNv.cpp:36)

17:37:57 >>> ClothingSystemRuntimeNv/Module.ClothingSystemRuntimeNv.cppa8.o:(FClothingSystemRuntimeModuleNv::StartupModule())

17:37:57

17:37:57 ld.lld: error: undefined symbol: NvClothDestroyFactory(nv::cloth::Factory*)

17:37:57 >>> referenced by ClothingSystemRuntimeModuleNv.cpp:50 (Runtime/ClothingSystemRuntimeNv/Private/ClothingSystemRuntimeModuleNv.cpp:50)

17:37:57 >>> ClothingSystemRuntimeNv/Module.ClothingSystemRuntimeNv.cppa8.o:(FClothingSystemRuntimeModuleNv::ShutdownModule())

17:37:57 clang++: error: linker command failed with exit code 1 (use -v to see invocation)

And here are our libs in directory Engine\Source\ThirdParty\PhysX3\Lib\Android\ARM64

libPhysX3.a

libPhysX3CharacterKinematic.a

libPhysX3CharacterKinematicCHECKED.a

libPhysX3CharacterKinematicPROFILE.a

libPhysX3CHECKED.a

libPhysX3Common.a

libPhysX3CommonCHECKED.a

libPhysX3CommonPROFILE.a

libPhysX3Cooking.a

libPhysX3CookingCHECKED.a

libPhysX3CookingPROFILE.a

libPhysX3Extensions.a

libPhysX3ExtensionsCHECKED.a

libPhysX3ExtensionsPROFILE.a

libPhysX3PROFILE.a

libPhysX3Vehicle.a

libPhysX3VehicleCHECKED.a

libPhysX3VehiclePROFILE.a

libPsFastXml.a

libPsFastXmlCHECKED.a

libPsFastXmlPROFILE.a

libPxFoundation.a

libPxFoundationCHECKED.a

libPxFoundationPROFILE.a

libPxPvdSDK.a

libPxPvdSDKCHECKED.a

libPxPvdSDKPROFILE.a

We are going to try “AnimDynamics” to solve our issues.

Regards

Jérôme

[Attachment Removed]

Thanks Jérôme,

From what I can tell, its exclusion from Mobile appears to have beeb explicite. In Vanilla 4.27+, both UEBuildIOS and UIBuildAndroid explicitly disable bCompileNvCloth meaning that setting bCompileNvCloth to true in the game target had no effect. This explains why I wasn’t seeing the linker errors you were encountering. I was able to reproduce these with local modifications to UBT. Assuming NvCloth is buildable for Android and IOS, integrating these should be relatively straightforward with a few additions to NvCloth.Build to append the prebuilt libraries to the linker appropriately per platform and some potential additional modifications to the runtime. Please advise if this support is essential to your project or if AnimDynamics doesn’t cover the gap, however, note that support to UE4 at this level may not be immediate as it would be beyond the scope functional LTS.

Best regards.

[Attachment Removed]