Bug of btSliderConstraint ???

Post Reply
zjl19870808
Posts: 21
Joined: Tue Nov 03, 2009 8:33 am

Bug of btSliderConstraint ???

Post by zjl19870808 »

Hi , everyone, I am using bullet, and find a strange phenomena. I set btSliderConstraint between a btCompoundShape and a small btCylinderShapeX. The btCylinderShapeX is expected to move up and down(Y axes) or back and forth(Z axes) in the Constrain, but it only moves right and left(X axes). so how can I realize it ? Or is it a bug in btSliderConstraint?

my code:
......
btCollisionShape* smallwheel0 = new btCylinderShapeX(btVector3(2,4,4));
btTransform smalltrans;
smalltrans.setIdentity();
smalltrans.setOrigin(btVector3(0,2,0));
btRigidbody* m_smallbody = localCreateRigidBody(20,smalltrans,smallwheel0);

btTransform bodyA,small0B;
bodyA.setIdentity();
small0B.setIdentity();
bodyA.setOrigin(btVector3(0,16,0));
small0B.setOrigin(btVector3(0,2,0));
btSliderConstraint* slider = new btSliderConstraint(*m_body,*m_smallbody,bodyA,small0B,true);
/***m_body is a btCompoundShape including two btCylinderShapeXs with 12 radius****/

getDynamicsWorld()->addConstraint(slider,true);


Your suggestion will be greatly appreciated.
Thank you, Thank you very much!

Jet
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Bug of btSliderConstraint ???

Post by Erwin Coumans »

Can you reproduce this in the Bullet/Demos/ConstraintDemo and attach a working/compiling zipped reproduction case?

Thanks,
Erwin
zjl19870808
Posts: 21
Joined: Tue Nov 03, 2009 8:33 am

Re: Bug of btSliderConstraint ???

Post by zjl19870808 »

Erwin Coumans wrote:Can you reproduce this in the Bullet/Demos/ConstraintDemo and attach a working/compiling zipped reproduction case?

Thanks,
Erwin
Hi, I have reproduce btSliderConstraint in the Bullet/Demos/ConstraintDemo and the body still only slide right and left.

The following is what I did:
I added the following code at the end of the function: ConstraintDemo::initPhysics()

Code: Select all

//Jet 2010.1.21
#if 1
	{
		btTransform tr;
		tr.setIdentity();
		tr.setOrigin(btVector3(-20,5,0));
		btRigidBody* bodyA = localCreateRigidBody(0.0,tr,shape);
		bodyA->setActivationState(DISABLE_DEACTIVATION);

		tr.setIdentity();
		tr.setOrigin(btVector3(-20,0,0));
		btRigidBody* bodyB = localCreateRigidBody(1.0,tr,shape);


		btTransform InA, InB;
		InA.setIdentity(); InA.setOrigin(btVector3(0,0,0));
		InB.setIdentity(); InB.setOrigin(btVector3(0,0,0));

		btSliderConstraint* slider = new btSliderConstraint(*bodyA,*bodyB,InA,InB,true);
		slider->setLowerLinLimit(-5.0);
		slider->setUpperLinLimit(5.0);

		m_dynamicsWorld->addConstraint(slider);
	}
#endif
//end
Apparently, I added two rigid bodies at the position (-20,5,0) and (-20,0,0). The upper body was a static body, the lower one was expected to slide up and down, but it didn't. Instead it moved to the left side of the upper body, and slided right and left immediately when the programme was running. I don't know how to realize it. The working/compiling zipped has already attached.

Another question I encounted was about the coordinate. I found Left-hand coordinate was used in the ConstraintDemo, but otherDemos were using Right-hand coordinate, while I can't find any code changed the coordinate in ConstraintDemo. The Bullet_user_manual also said Right-hand coordinate was used. So which coordinate are using on earth? I learn from the code that world coordinate is using right-hand coordinate, object coordinate is using left-hand coordinate except the ConstraintDemo, and their pivots are all the body's center point. Am I right?

That is all ! thank you for your reading, and your suggestions will be greatly appreciated.
Jet
Attachments
ConstraintDemo.zip
(198.08 KiB) Downloaded 282 times
Post Reply