InteractiveComputerGraphics / PositionBasedDynamics

PositionBasedDynamics is a library for the physically-based simulation of rigid bodies, deformable solids and fluids.
MIT License
1.89k stars 358 forks source link

SDF->SDF collision detection #94

Open blooop opened 3 years ago

blooop commented 3 years ago

I have been doing research to see if methods exist for calculating the distance/collision between two signed distance fields. So far this is the only codebase I've found that looks promising.

I have spent some time trying to understand the codebase to see the performance of SDF->SDF collision and if that is really what is happening, but I am struggling.

I put a timer around line 106: https://github.com/InteractiveComputerGraphics/PositionBasedDynamics/blob/master/Simulation/DistanceFieldCollisionDetection.cpp#L106

COLLISION TIME:0.000071ms
COLLISION TIME:0.003063ms
COLLISION TIME:0.005443ms

And got some very small values. However the collision statistics in some of the examples say it spends around 16ms on collision detection per frame.

My question is: Is the collision time just low because it has been culled by some other level of the BVH or is the SDF->SDF collision time actually just very low.

The reason is I was looking to replace the Flexible Collision Library (FCL) mesh->mesh collision with the SDF->SDF collision detection from here (if it is no worse than FCL). Bearing in mind that I am not using any BVH from FCL and just do a raw mesh->mesh collision checks.

Thanks