- Home /
PhysX with own Collision Detection
I have my own collision detection algorithm as using the colliders with Unity on the fly is not acceptable(generating MeshColliders on the fly with complex geometry is pretty slow). This is fine. Standard AABB sweep and all.
However, I don't want to write my own Physics engine as well. Is there a good way to integrate my own collision engine with PhysX? I noticed RigidBodies have an addForce() method but I'm not sure this is going to be sufficient. What I'd really like to hand off a bunch of collisions to the physics engine during each frame with info like interpenetration, mass, etc., and have it handle the physics from there.
Any suggestions?
/edit Anyone? Right now I'm thinking that the physics (that is, velocity and acceleration) could be passed off to PhysX easily enough by using the Unity components and the collision detection portion would handle that PLUS interpenetration resolution.
I don't think this is possible. Also, you really think you can write collision detection that out performs what's built into PhysX substantially? I actually spent a considerable amount of effort at my last job doing just that, I could beat the Bullet engine by about 15% but could only outdo PhysX by 5-7% or so. And that was disallowing PhysX to offload physics to the GPU. It just seems like you're barking up the wrong tree.
flavius, It is not the speed of the collision detection that I am concerned about. Almost all of my meshes are procedurealy generated and can be quite diverse. Using the PhysX collision detection in these cases requires using a $$anonymous$$eshCollider (as far as I can tell) which is extremely slow to generate. Enough to cause a good-sized stutter every time I instantiate a $$anonymous$$esh. I cannot use simpler collision objects as then I'd end up with millions.
With my own custom bounding volume heirarchy I can speed this up by a huge amount in this particular case.
So I figured by doing my own collision detection (easy and fast to do, even if it's not as efficient as PhysX) I can avoid using $$anonymous$$eshColliders.
See what I am getting at?
Your answer
Follow this Question
Related Questions
Physic based golf game - ball bouncing off the connection of colliders on flat surface 2 Answers
The Physics of Ball Spin in Tennis, Topspin and Backspin 3 Answers
OnCollisionEnter isnt called when player lands on object 1 Answer
Collision with rigidbody inside a gameobject 0 Answers
add torque at position 2 Answers