collision problem

dehseth
Posts: 5
Joined: Mon Dec 28, 2009 9:48 am

collision problem

Post by dehseth »

Hello guys,

I have a wood box, and a ball in this box like a labyrinth game but this wood does not have any holes. You can rotate box using arrow keys, if there's a slope > 0 than the ball rotates (gravity factor). My problem is when you rotate it too fast the ball falls under wood box due to a collision error. I decrase rotation degree to avoid this error, in this computer demo runs around 500FPS and everytihng works fine, but at home it runs around 5000FPS and the ball falls, it's like ground sucks it.. I am using a discrete dynamics world (dunno if I have to use continious one). How can I avoid this collision error at any FPS?

Here's how I rotate box:

Code: Select all

static btQuaternion sq(btVector3(1,0,0), DEGTORAD/10);
				btTransform t = rbodyWoodBox.GetWorldTransform();
				t.setRotation(t.getRotation() * sq);
				rbodyWoodBox.SetWorldTransform(t);
				rbodyBall.Activate();

				btVector3 EulerRotation;
				QuaternionToEuler(t.getRotation(), EulerRotation);		
				nodeWoodBox->setRotation(core::vector3df(EulerRotation[2], EulerRotation[1], EulerRotation[0]));
mako90
Posts: 28
Joined: Tue Jan 05, 2010 12:41 pm

Re: collision problem

Post by mako90 »

static btQuaternion sq(btVector3(1,0,0), DEGTORAD/10);
btTransform t = rbodyWoodBox.GetWorldTransform();
t.setRotation(t.getRotation() * sq);
rbodyWoodBox.SetWorldTransform(t);
rbodyBall.Activate();

btVector3 EulerRotation;
QuaternionToEuler(t.getRotation(), EulerRotation);
nodeWoodBox->setRotation(core::vector3df(EulerRotation[2], EulerRotation[1], EulerRotation[0]));

Hi, why do you use the blue line? You should activate the body at the beginning. Than make all rotation actions on some time period or control (keyboard, mouse callback), than call the step simulation.

You'd better not create all the quaternions and transforms in the loop body, because you have to call all the constructors of these object on every loop iteration. Just create them outside the loop and only change the values inside of the loop. Your way makes it to be slooow.

BR.
sipickles
Posts: 44
Joined: Thu Aug 07, 2008 6:57 am

Re: collision problem

Post by sipickles »

You should use applyTorque to change the rotation of the box, not by setting its transform directly.

You are moving the box past the ball, not allowing the box to push the ball around
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: collision problem

Post by sparkprime »

If you don't have framerate independence then you're doing it wrong.

Why go to all this trouble to move things around when you can just change gravity though?