btGeneric6DofConstraint problem

cobolt_dink
Posts: 72
Joined: Fri Apr 04, 2008 6:07 pm

btGeneric6DofConstraint problem

Post by cobolt_dink »

I'm creating a paddle for a breakout type game so I want the paddle to only move in a straight line no matter what hits it. I've been using btGeneric6DofConstraint and it was working great. Today I upgraded to 2.73 from 2.71 and now when my paddle hits the wall it flips around, spins in a circle, and generally doesn't move along the track like it should. I link with the 2.71 stuff and all is as it should be. Guessing I haven't set something up right and the older versions were letting me get away with it.

I'm trying to create a constraint between the paddles rigid body and an invisible ground plane.

Code: Select all

void CPhysics::AddConstraint(btRigidBody *body, D3DXVECTOR3 extents)
{	
	btGeneric6DofConstraint *slider;

	btTransform identity = btTransform::getIdentity();

	btTransform transform;
	transform.setIdentity();
	body->getMotionState()->getWorldTransform(transform);
	transform.setOrigin(btVector3(transform.getOrigin().getX(),
								  transform.getOrigin().getY(),
								  transform.getOrigin().getZ()));

	btScalar mass(0.);

	btVector3 localInertia(0,0,0);
	
	//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
	btDefaultMotionState *myMotionState = new btDefaultMotionState(transform);
	btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, myMotionState, 0, localInertia);
	btRigidBody *pin = new btRigidBody(rbInfo);
	   
	slider = new btGeneric6DofConstraint(*body, *pin,
						 identity, identity, true);

	btVector3 lowerSliderLimit = btVector3(-35+extents.x,0,0);
	btVector3 hiSliderLimit = btVector3(35-extents.x,0,0);

	slider->setAngularLowerLimit(btVector3(0,0,0));
	slider->setAngularUpperLimit(btVector3(0,0,0));

	slider->setLinearLowerLimit(lowerSliderLimit);
	slider->setLinearUpperLimit(hiSliderLimit);

	m_dynamicsWorld->addConstraint(slider);
}
Any suggestions? I don't see anything different with my code then what is in the slider demo.

I should note that if I make the limits smaller then the level I don't seem to have a problem. Its when the limit is bigger then the level and the paddle is running into the trimesh that makes up the walls.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: btGeneric6DofConstraint problem

Post by Erwin Coumans »

Is that Bullet 2.73 or Bullet 2.73 SP1?

Bullet 2.73 SP1 has some fixes and changes in the constraint solver and btGeneric6DofConstraint, but we might have introduced some issue.

Is there a way to reproduce the problem in one of the Bullet demos?
Thanks,
Erwin
cobolt_dink
Posts: 72
Joined: Fri Apr 04, 2008 6:07 pm

Re: btGeneric6DofConstraint problem

Post by cobolt_dink »

Its 2.73 SP1. Don't know of a way to recreate it in the demos other then to add a trimesh to have rigid bodies collide against.

Something else that I don't know if it would be part of the problem is the paddle uses linear velocity to move. Every frame I'm calling setLinearVelocity() so the paddle has a little ramp up to full speed. If the paddle is still against the wall and the player keeps moving it, its setting get its velocity set every frame.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: btGeneric6DofConstraint problem

Post by Erwin Coumans »

add a trimesh to have rigid bodies collide against.
There are several Bullet demos with a trimesh and colliding rigid bodies, so that is not a good reproduction case.

Can you help reproducing it?

Thanks a lot,
Erwin

by the way: slider demo uses a btSliderConstraint.
User avatar
projectileman
Posts: 109
Joined: Thu Dec 14, 2006 4:27 pm
Location: Colombia

Re: btGeneric6DofConstraint problem

Post by projectileman »

Hi. sorry for the late response.

Have you ever tried to set lower angular limits to a lower value from the upper angular limits?

It could help. Actually I don't understand how it was working with the old btSequentialImpulseConstraintSolver when Lower Limits == Upper Limits. On the ODE constraint solver it usually gives errors. If you want the angular axis limited, you should set upper and lower values with a little difference, an epsilon.
cobolt_dink
Posts: 72
Joined: Fri Apr 04, 2008 6:07 pm

Re: btGeneric6DofConstraint problem

Post by cobolt_dink »

projectileman wrote:Hi. sorry for the late response.

Have you ever tried to set lower angular limits to a lower value from the upper angular limits?

It could help. Actually I don't understand how it was working with the old btSequentialImpulseConstraintSolver when Lower Limits == Upper Limits. On the ODE constraint solver it usually gives errors. If you want the angular axis limited, you should set upper and lower values with a little difference, an epsilon.
I think that might have been it. I set the lower angular limit to 1.0e-5 for all three parts and it seems to have fixed the problem.

Now just have to figure out way my game with 2.73 crashes on one computer when making rigid bodies but is fine with 2.71 (and it is only *one* computer).
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: btGeneric6DofConstraint problem

Post by Erwin Coumans »

cobolt_dink wrote: Now just have to figure out way my game with 2.73 crashes on one computer when making rigid bodies but is fine with 2.71 (and it is only *one* computer).
Is it an older computer without SIMD capabilities running Windows? If so, could try to disable USE_SIMD in the constraint solver?

Code: Select all

dynamicsWorld->getSolverInfo().m_solverMode &=~USE_SIMD;
Hope this helps,
Erwin