Spring Contacts
Hi all,
I'd like to implement spring contacts with PhysX, but am struggling.
I found PxContactModifyCallback, whose documentation refers to "soft" contacts which I suspect refers to this.
class MyContactModification : public PxContactModifyCallback {
void onContactModify(PxContactModifyPair* const pairs, PxU32 count) {
for (PxU32 i=0; i < count; i++) {
PxContactSet& contacts = pairs[i].contacts;
contacts.setMaxImpulse(i, 2.f);
}
}
};
https://user-images.githubusercontent.com/47274066/142777369-5e97641e-89a1-46e2-8b50-2d12b0805980.mp4
Which... sure, one could argue is "soft" but not exactly "springy". How would I go about making these springy?
I'm using PhysX 4.1.
Still banging my head against this, it doesn't seem possible with PhysX? :( I've been spoiled working with ODE, where soft contacts can easily be achieved via CFM and ERP.
My understanding of the D6 joint limits is that they are effectively solved as collisions against the limit, but with a stiffness and damping value. So part of me would still like to believe it is somehow possible.
Any pointers on this? Is it a fruitless endeavour?
This is not something that we have support for in PhysX 4. It is, however, likely to be something that we are interested in adding official support for in the future.
The D6 soft joint limits are not too dissimilar from how we would implement soft contacts.
Thanks for confirming @kstorey-nvidia. Any pointers as to where one would start poking around if one wanted to try and apply the soft joint limits to contacts?
There are quite a few places, so best suggestion would be to constrain the set of features you want to try and use.
Assuming you only want to work with rigid bodies and not articulations, and you want to use the PGS and not TGS solver, the first suggestion would be to temporarily disable the batched solver controlled with this define:
#define DY_BATCH_CONSTRAINTS 1
Then you can take a look at
setupFinalizeSolverConstraints
and look at the parameters you would need to adjust. The interesting values are velMultiplier, biasedErr and maxImpulse. You would need to add in a new "impulseMultiplier" term and use that. For hard constraints, impulseMultiplier would be 1, whereas it would be some value <= 1 for soft constraints.
Then you would also need to adjust the solveContact method.
If you take a look at these methods, you should see that there is a lot of simlarity between them and solve1D and the joint constraint prep code.
Thank you! Diving into this.