collisions for procedural mesh

Read this if you want to use runtime meshes on mobile devices.

Creating meshes that may change during runtime is what I wanted to try. (personally, I believe this sort of functionality is extremely useful).

I was playing with ProceduralMesh and RuntimeMesh plugins, and in my experience ProceduralMesh is a way slower than RuntimeMesh, it is clearly seen on slow devices.
The unfortunate thing is that collisions and physics do not work on mobile for both of them. Someone decided for me that runtime cooking kills performance, and cut it out for Android. That was really ******* me off. I wanted to see collision with my meshes and I can’t. Motherf*s!

I did some digging it looked like all I need is to uncomment one line (“PhysX3Cooking{0}”) in PhysX.Build.cs and set bRuntimePhysicsCooking to true in UEBuildAndroid.cs. Well, it did absolutely nothing, except making linker to complain about some missing dependencies.

So, after a series of experiments I actually found a way.

Download engine source. (do as manual says: download; make sure that environment variables ANDROID_HOME, ANT_HOME, JAVA_HOME and NDKROOT are set properly; run Setup script; run GenerateProjectFiles script). One more thing of advice here, set the engine on a drive that has at least 100 GB of free space on it.

Engine/Source/Programs/UnrealBuildTool/Android/UEBuildAndroid.cs: set bRuntimePhysicsCooking to true
Engine/Source/Programs/AutomationTool/Scripts/BuildPhysX.Automation.cs: comment the line with [RequireP4]
Engine/Source/ThirdParty/PhysX/PhysX.Build.cs: uncomment the line containing “PhysX3Cooking{0}” for Android

Engine/Source/ThirdParty/PhysX/PhysX_3.4/Source/compiler/cmake/Andorid/CMakeLists.txt: uncomment INCLUDE(PhysXCooking.cmake)
Run Engine/Source/ThirdParty/PhysX/GenerateProjects_UAT script with TargetPlatforms set to Android, SkipBuild disabled

Build the Engine

After that games created with your own build of the Engine will support collisions and physics with runtime meshes on mobile devices.
In my test app mesh rebuild happens relatively rare: twice every second. With collision overlap events enabled I do not see any drop in performance.

Finally, at peace.

Thanks for this! I ended up going through all these steps, it builds fine but stalls on the splash screen, seemingly with nothing useful in the logcat. I generate terrain on startup so it’s probably hitting that immediately. Do you know if there any any specific DLLs responsible for this? It’s a bit “nuke the site from orbit” :slight_smile:

It seems ridiculous they’ve disabled this functionality for “performance” reasons. I swapped from ProceduralMeshComponent to RuntimeMeshComponent and my scene rebuild times went from 16 seconds to 0.02 seconds. The main reason people use Unreal is the freedom and performance, this current solution is giving neither.

can’t advise on what is causing your stalls, but stalls on load are not, generally, uncommon.

you could try unreal profiler to log and trace activity of your app. (Window -> Developer Tools -> Session Frontend)
although in my opinion it is difficult to read/understand and use, especially because you need to markup every piece of code you want to monitor. but it is free, so probably nothing to complain.