Hinge constraint exploding

User avatar
SynapticBytes
Posts: 74
Joined: Thu Feb 10, 2011 8:27 pm

Hinge constraint exploding

Post by SynapticBytes »

Working on my Shiva Bullet plugin still, I'm at the stage of putting in the constraint API's. Now I'll admit I'm still trying to understand the meaning of many of the values and methods in the Bullet API, so I'm solving problems 1 at a time. I've tried to find out what I might be missing by searching the forum, but once again it seems I'm the only one who doesn't get it. So, sorry if this is a newbie question, but

I've created 2 hinge parts in Shiva, each one comprising a standard cube with a smaller resized cube as a hinge tongue attached to it. I've aligned these so they are touching, as per a standard hinge joint shown in the Bullet manual. I've put these "joined" objects in my scene, suspended in mid air, so when i start the simulation they should fall down together, but be constrained at the hinge joint.

If I add a box rigid body to each object, spanning to end of the tongues, and make both bodies dynamic, when I start the simulation, they two objects explode away from each other, and when they settle down in out-of-whack orientations, the hinge joint tries to work but naturally looks out of place compared to the objects.

If I make one of the objects static, the other one swings around it with a correct hinge connection. I don't care about angle limits or anything at the moment, I just want to see the hinge joint holding my 2 objects together.

All I have done to create the hinge joint is

Code: Select all

btHingeConstraint* newConstraint = new btHingeConstraint(*bodyA, *bodyB, btVector3(nPivotXA, nPivotYA, nPivotZA), btVector3(nPivotXB, nPivotYB, nPivotZB), btVector3(btScalar(nAxisXA), btScalar(nAxisYA), btScalar(nAxisZA)), btVector3(btScalar(nAxisXB), btScalar(nAxisYB), btScalar(nAxisZB)));
physicsWorlds[currentWorldID]->addConstraint(newConstraint);
I have yet to figure out if any other configuration is needed, but from the standard bullet constraints demo code, the only extra thing I can see is these 2 lines

Code: Select all

		pHinge2->setLowerLimit(-SIMD_HALF_PI * 0.5f);
		pHinge2->setUpperLimit( SIMD_HALF_PI * 0.5f);
Do I need to set some other options to stop collisions? If not, how do you stop bodies exploding from overlapping, or being close, when you create them?

Thanks.
User avatar
SynapticBytes
Posts: 74
Joined: Thu Feb 10, 2011 8:27 pm

Re: Hinge constraint exploding

Post by SynapticBytes »

OK well I think I've found the partial answer at least in the following :-

Code: Select all

virtual void btDynamicsWorld::addConstraint  ( btTypedConstraint *  constraint,  
  bool  disableCollisionsBetweenLinkedBodies = false   
 )  
I didn't think to look in the world class for an answer, but I guess if I set disableCollisionsBetweenLinkedBodies = true, then at least I won't have the exploding anymore. Then I just need to limit my hinge motion so the pivoting side doesn't swing through the non-pivoting side, correct?