[4.7 preview 8] Crash on physics collision with generated mesh

I create a procedural generated mesh during gameplay as described in this thread: Generate Procedural Mesh - C++ - Unreal Engine Forums

The mesh triangles are used to create the collision shapes and the mesh uses the BlockAllDynamic collision profile. Lighting, navmesh generation, particle collisions etc. work fine. I can even use a pawn to walk around on the mesh.

However, when I try to spawn some physics actors (simple cubes) above the mesh then the game crashes a moment after they collide with my generated mesh.

This is the stack trace from the crash:

MachineId:B02F4A2F4ECC0D6BF70821BFEEC1416F
Access violation - code c0000005 (first/second chance not available)

PhysX3PROFILE_x64 + 731479 bytes
PhysX3PROFILE_x64 + 729311 bytes
PhysX3PROFILE_x64 + 864095 bytes
PhysX3PROFILE_x64 + 867659 bytes
PhysX3PROFILE_x64 + 1171519 bytes
PhysX3PROFILE_x64 + 566482 bytes
UE4Editor_Engine!TGraphTask<FPhysXTask>::ExecuteTask() + 449 bytes 
UE4Editor_Core!FTaskThread::ProcessTasks() + 3109 bytes 
UE4Editor_Core!FTaskThread::ProcessTasksUntilQuit() + 77 bytes 
UE4Editor_Core!FTaskThread::Run() + 11 bytes 
UE4Editor_Core!FRunnableThreadWin::Run() + 102 bytes 
UE4Editor_Core!FRunnableThreadWin::GuardedRun() + 93 bytes 
kernel32 + 5805 bytes
ntdll + 453476 bytes

Any idea what could cause this?
I tried playing around with the collision and physics settings, physics materials or the static mesh shapes, but to no avail.

Logfile and Dumpfile

I also tried to use older versions of the PhysX3PROFILE_x64.dll (from the 4.5 branch i think), but it produced the same error.

Also, the crash does not always occur instantly when the collision happens, it takes anything between 0 and 5 seconds to actually crash the game.

Hey Cultrarius,

Would you be able to setup a simple test project that causes this crash for me to test or is this only happening in your main project?

You also mention 4.7 p8 in the title. Does this mean it wasn’t happening in any previous versions?

Hey Tim,

setting up a test project is not easy for me, because the generated mesh that causes the crash is tied to a lot of other stuff in my project. But I will try to make a minimal test project for you.

As for the title: yes, I did not think this was happening in previous versions, but now I am not so sure any more. Maybe I just never reached a critical number of physics collisions when I tested this in the past.

Ah gotcha on the project title I’ll leave it as that for the moment. 4.7 final will be releasing very soon as well with some more fixes.

I’m not a programmer myself, so if there is a sample project that causes the crash it’s much easier to see the repro and get a report in much more quickly. If I passed this off to one of our programmers on our support team it may be a bit longer as they can get backlogged with all the code questions coming in.

From meshing with the custom mesh component via BP I know there are a lot of issues with not receiving any collision at all, so I couldn’t even start to repro given that.

Thanks for putting something together when you get time.

Hey Tim,

I sent you a PM on the forums with a link to a working test project.

Thanks,
Cultrarius

awesome. Going to take a look now.

Hey Tim,

any update on this problem? I would really need working physics collision for my project and can’t for the life of me figure out why it does not work.

Thanks,
Cultrarius

I’ve been able to open and see the crash. With the final release of 4.7 this week I’ve not managed to get any further than that at the moment. I’ll continue to look into this one next week. Thank you for your patience.

Looks like I solved the problem. I had to change two things for the crashes to disappear:

  1. When constructing the UBodySetup for my mesh I have to set bMeshCollideAll = false, which is weird because it is set to true in every piece of code I find about procedurally generating meshes (for example A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums)
  2. When creating the FTriMeshCollisionData for my mesh I set the wrong material indices for the physics collision material. I still do not know how I can reference my physics materials here and what that index actually represents, because any index other than 0 leads to a crash.

Thank you Tim for the support!