Spheres bouncing oddly

Nickeeh
Posts: 14
Joined: Wed Feb 09, 2011 8:35 pm

Spheres bouncing oddly

Post by Nickeeh »

Hey guys,

I got two movies showing my problem. The first is with cuboids, and they bounce as I would expect, you can watch them bounce in my project here: http://www.astrant.net/Bullet-Debug-Cuboids.mov

The second video shows my problem with spheres, they tend to really change direction when they bounce e.g. they come vertically down and after they bounce, they continue horizontally to the left or right, really unlike I expected.
http://www.astrant.net/Bullet-Debug-Spheres.mov

What you see is a sorta version of Pong, drawn with a Bullet Debugger (I wrote my own, really simple ES2 debug drawer). The top and bottom dots are the two paddles, I move the bottom one a bit in both videos. On the sides are 2 walls, static objects. I'm not sure if I got the paddles right, so perhaps the problem is with them?

The only change you see between the 2 videos are these lines of code:

Code: Select all

		
		static const bool useSphereCollisionShapeForBouncers = true;
		if(useSphereCollisionShapeForBouncers){
			bouncerCollisionShape = new btSphereShape(1.f);
		} else {
			bouncerCollisionShape = new btBoxShape(btVector3(btScalar(.5),btScalar(.5),btScalar(.5)));
		}
I'd like to know what I can could be doing wrong that causes the spheres to bounce weird like that.

Thanks in Advance!
Nickeeh
Posts: 14
Joined: Wed Feb 09, 2011 8:35 pm

Re: Spheres bouncing oddly

Post by Nickeeh »

I think this was due to me enforcing a minimal velocity on my objects. I removed the part of the code that does that (which by the way looks a lot like the maximum velocity enforcing on the wiki), and the problem was solved. I can only guess why the cubes to seem to bounce "normally", but on the other hand I must admit that looking at the realistic feeling results I get now, I think they also behaved odd, just less so than the spheres. ;-)

Bottom line: Don't enforce minimal speeds on all your objects: it seems to mess up the direction when they bounce (doens't matter if you enforce it post- or pretick).