I'm making a pool-game like game. This game requires correct (or very accurate) reflective bounces. I tried Box2D and Bullet Physics, but they both have this problem.
If there is a wall on top of this image, red line is expected course of a real ball in a pool-game. But the engines often shows green line course. Especially,
- This happens after a slowly moving ball hits the wall.
- Sometimes a rapidly moving ball get slower suddenly.
I'm finding a physics engine which can simulate pool-game accurately as much as possible without these problems. Can I get some recommendations? Now I'm digging Newton Game Dynamics, but I am not sure the engine will show what I want. I'm considering the PhysX engine as a next trial, and have to make my own if nothing works. But it's obvious it'll take very long time, so I wish I won't do that. I'll be very appreciated if you save my time. And of course, solution with Box2D / Bullet Physics are also welcomed.
I am working with C/C++/Objective+C on iOS.
I attach my configuration with Box2D.
- static box shape
- linear/angular damping = 0.1
- restitution = 1.0
- friction = 100
- density = 10
- bullet = false
- fixed rotation = false
- inertial scale = 1.0
- dynamic sphere shape
- linear/angular damping = 0.1
- restitution = 1.0
- friction = 100
- density = 20
- bullet = true
- fixed rotation = false
- inertial scale = 1.0
Answer
Several solutions.
For Box2D, set
b2_velocityThreshold
inb2Settings.h
file. In my case, I set it to0.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#p30782Using 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)
No comments:
Post a Comment