Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm making pool game like game. This game requires correct (or very accurate) reflective bounces. I tried Box2D and Bullet Physics, but they have this problem.

Illustration

If there is a wall on top of this image, red line is regular course of the regular pool game. But the engines often shows green line course. Especially,

  1. This happens after a ball moving slowly hits the wall.
  2. Sometimes a ball moving fast get slower suddenly.

I'm finding a physics engine can simulate pool game as much as possible without these problems. Can you recommend some? I'm digging Newton Game Dynamics now, but I have no sure about this. I'm considering PhysX as next trial, and have to make my own if nothing be found. But it's obvious it'll take huge time, so I wish I will do not. I'll be very appreciated if you save my time. And of course, solution with Box2D / Bullet Physics are also welcomed!

Acceptable languages/platform are C/C++/Objective+C on iOS.


I attach my configuration with Box2D.

Walls

  • static box shape
  • linear/angular damping = 0.1
  • restitution = 1.0
  • friction = 100
  • density = 10
  • bullet = false
  • fixed rotation = false
  • inertial scale = 1.0

Balls

  • dynamic sphere shape
  • linear/angular damping = 0.1
  • restitution = 1.0
  • friction = 100
  • density = 20
  • bullet = true
  • fixed rotation = false
  • inertial scale = 1.0
share|improve this question
3  
chances are that the engine is not wrong, but you've not set a property or doing it wrong somehow. – The Communist Duck May 6 '11 at 16:37
possible duplicate of Is there an algorithm for a pool game? – bummzack May 7 '11 at 16:31
I tested with density 1 and friction 0.0 ~ 0.1, it keeps sticking. – Eonil May 10 '11 at 7:54

4 Answers

up vote 7 down vote accepted

Several solutions.

  1. For Box2D, set b2_velocityThreshold in b2Settings.h file. In my case, I set it to 0.0f and it worked! Mass, friction, damping were NOT problem. Check this discussion thread for more details. http://www.box2d.org/forum/viewtopic.php?f=3&t=6906&p=30782#p30782

  2. Using other physics engine. Newton Game Dynamics configured performing this correctly by default. However using Newton dynamics in iOS is possible but it's somewhat harder than others. I used several days configuring it for iOS.

I'm also asking on BulletPhysics forums. I'll update this when I got a solution.

-- (edit) --

There are some threshold attributes in Bullet, however I couldn't find exactly same thing with b2_velocityThreshold.

This looks similar, but didn't work well.

btRigidBody->setContactProcessingThreshold(0.0f)
share|improve this answer

Box2D will do what you want but you have to set the restitution (bounce) constants for the wall and ball fixtures. For a pool game you probably want to start with perfect restitution and high friction but linear and angular damping, and tweak from there.

share|improve this answer
I tried many configurations over few days, but it still happens. Can I get one good example...? – Eonil May 7 '11 at 1:33
3  
Your density and friction values seem very large, for Box2D. – Joe Wreschnig May 7 '11 at 9:56

Physics engines have a bounce threshold. I don't know how to do it in either of those engines, but the threshold being set too high will cause it to ignore impacts under a certain velocity. Lower the bounce threshold and it will bounce at lower speeds.

I know you asked for a different physics engine, but all physics engines I know of use bounce thresholds to keep objects from jittering when they're sitting on top of each other. So suggesting a good physics engine will be counterproductive as any good physics engine will have this effect.

share|improve this answer

I had this problem and for me the solution was providing perfect restitution.

So for me that is sqrt of 0.5 for all objects. Because sqrt(r1*r1 + r2*r2) == 1 in perfect situation.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.