NVIDIA-Omniverse / PhysX

NVIDIA PhysX SDK
BSD 3-Clause "New" or "Revised" License
2.59k stars 374 forks source link

PxTriangleMesh collision error #182

Closed preist-nvidia closed 11 months ago

preist-nvidia commented 1 year ago

Discussed in https://github.com/NVIDIA-Omniverse/PhysX/discussions/181

Originally posted by **yananZZZZ** August 16, 2023 ### triangle mesh collide with triangle mesh Hi, As I tried to make two mesh shape collide with each others, I got error reported in the GPU dll: `PxgCudaSolverCore.cpp (1702) : internal error : GPU mComputeBodiesAverageVelocitiesFunction fail to launch kernel!!` `PxgCudaSolverCore.cpp (1681) : internal error : GPU solveStaticBlock fail to launch kernel!!` `PxgCudaUtils.h (75) : internal error : SynchronizeStreams cuEventRecord failed with error 700` `PxgCudaUtils.h (81) : internal error : SynchronizeStreams cuStreamWaitEvent failed with error 700` As one of my actor are `PxRigidDynamic` I enable the sdf when cook my mesh shape, something like: ![image](https://github.com/NVIDIA-Omniverse/PhysX/assets/122350362/0146e20d-7a00-43e9-a36c-3b995f48b2c8) since GPU dll is not open sourced, and I have no idea how to debug this kind of issue as mesh vs mesh is a common case in our application, hope someone can help to give some advice here. I also export the ovd file for this scene maybe it a bit helpful to reproduce the issue. ![image](https://github.com/NVIDIA-Omniverse/PhysX/assets/122350362/b1307d14-30f7-4ccf-9cbe-1590cae96be0) [MeshCollisionPVD.zip](https://github.com/NVIDIA-Omniverse/PhysX/files/12354444/MeshCollisionPVD.zip)
preist-nvidia commented 1 year ago

Thank you for the report @yananZZZZ we will have a look and get back to you.

nvtw commented 1 year ago

Hello, I had a look at the the ovd capture but I could not find something that is obviously incorrect. It might be worth to try a couple of things to see if it starts to work afterwards:

The file I used to experiment is attached. Maybe it helps to copy some settings.

MeshCollisionTest2.zip

yananZZZZ commented 1 year ago

Hi, I open your usd and the simulation is rather good. however i try to change sdf spacing to 0.001 to make 500 resolution for my mesh shape. it will get IE in GPU dll. I also change maxRigidContactCount to 5242880 maxRigidPatchCount = 819200; as it not the default value in your scene. it didn't work neither.

May I know the PhysX version used in Omniverse as i'm using V5.1.3. One more thing, is there still cooking process for mesh shape. If it's the case, it rather fast in Omniverse, I wonder if there is some optimization or tips to share.

thank you

nvtw commented 1 year ago

Omniverse 104.x (I guess that's equivalent 2022.3.x) should use the PhysX SDK 5.1.x. Usually the SDKs minor version increases with every new major version of kit. So 2022.4 would probably use 5.2.x but I'm not perfectly well informed on that. I can try to set up your scene in the PhysX SDK to see if I run into problems too. About cooking: There is a way to create SDFs on the gpu but it has not made it into the documentation yet. I'll update the docs asap. In the meantime you can try to set it up without documentation as it is quite easy: In the PxSDFDesc structure, make sure the member sdfBuilder points to a valid instance of the gpu sdf builder sdfDesc.sdfBuilder = PxGetPhysicsGpu()->createSDFBuilder(cudaContextManager); Make sure you release the sdfBuilder instance after the cooking to avoid memory leeks since the memory is owned by the caller. You might need to inlcude #include "PxSDFBuilder.h"

yananZZZZ commented 1 year ago

Hi I'm quite sure you that the version of PhysX is 5.2.x as there is no "PxGetPhysicsGpu" in V5.1.x. I cannot find "PxSDFBuilder.h" in V5.2.x neither. Is this file under a special directory? image I get some questions and hope to get some ideas from you:

Sorry to bother you with so many questions as mesh collision is rather complicated and I trying to rule out the any possible cause.

nvtw commented 1 year ago

You're right, the SDFBuilder seems to be in the 5.3 SDK version which is not out yet, sorry my fault. Omniverse also has caching built in, so if you compute the same sdf twice, it will take it from the cash after computing it once.

nvtw commented 1 year ago

Do you have code you could share with me such that I can reproduce the issue in the SDK? Usually I tend to modify the SDF snippet such that it uses different meshes and different parameters since it is an easy way to get some basic rendering. Having some code from you would simplify the support.

yananZZZZ commented 1 year ago

Hi,

I tried to used serialization to export my entire scene into binary and deserialized in the SDFTutorial. however, I encounter some IE when restore my data. Snipaste_2023-08-24_14-25-15

The code I used to serialize the scene is just the demo code in the doc. PxCollection* collectionScene = PxCollectionExt::createCollection(*m_pScene); PxSerialization::complete(*collectionScene, *m_pSerializationReg); everythingCollection->add(*collectionScene); collectionScene->release(); PxSerialization::complete(*everythingCollection, *m_pSerializationReg); PxDefaultFileOutputStream actorOutputStream("Scene.dat"); PxSerialization::serializeCollectionToBinary(actorOutputStream, *everythingCollection, *m_pSerializationReg); everythingCollection->release(); For the complex mesh data, the deserialization seams ok, but i get IE in the frame render, it looks like the collision between plane and mesh is not work. it works after i change plane to box geometry. I also create a simple box shape mesh and collision between mesh also not work. Untitled

Also, I manage to restore some other simple mesh data in to the tutorial but I saw error inside console, does it means it cannot proceed anymore? image Attached is my demo code and data. just put the dat file under the same dir with the snippet project the issue should be reproduced. There are three zip files:

Hope you can run the code and get the same result. If need anything, please let me know.

thank you

nvtw commented 1 year ago

Sorry for the long delay with answering. I now created a cpp file which you can use to overwrite the SnippetSDF.cpp. It expects the off-3d data file at the location C:\tmp. Feel free to adjust the folder name in the code. Collisions between the complex geometries work but I have not yet tried that base plate rectangle. Please note that SDFs work best on meshes with uniform scaling. Non uniform scaling is not recommended. If non uniform scaling is required, please scale the vertices non-uniformly before you feed them into the cooking pipeline. SnippetSDFwithCustomMesh.zip

preist-nvidia commented 11 months ago

Closing for now, please reopen if we should pick this up again.