Our game is a racing game, little old, using in house physics system to simulate the car physics. the car physics quite complete, have some detailed simulation form engine to pacejka tire formula.
In that physics system, It used RK4 method to handle the car motion and a very simple solution to handle the collision detect and collision feedback.
Now we are planning to let the car can interaction with some dynamic objects not only the walls and roads, and also hope car crash looks better not just sliding or suddenly stop. So I guess may be the best way is to import a physics library.
But, looks like the update loop in physics engines are just like Euler's method: we only can change force every physics frame.
If I using physics engine like bullet replace the old physics, can the car motion keep the same precision ? How ?
Set the car as a kinematic object ,and update it by manual ? This way can't help me to let the car crash looks better ......
or someone have any good ideas ?
a worry about the precisions
-
Erwin Coumans
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: a worry about the precisions
You can move the car by your own physics sytem and just represent the chassis as Bullet rigid body. Then make sure your physics system sets the linear/angular velocity (and possibly position/orientation) of the chassis every frame, and let Bullet deal with the rigid body / collisions.
You might want to use the Bullet pre-tick callback to call your vehicle physics.
Thanks,
Erwin
You might want to use the Bullet pre-tick callback to call your vehicle physics.
Thanks,
Erwin
-
FXCarl
- Posts: 4
- Joined: Wed Feb 17, 2010 7:14 am
Re: a worry about the precisions
Thank you, Erwin
I'll try it asap ……
I'll try it asap ……
-
FXCarl
- Posts: 4
- Joined: Wed Feb 17, 2010 7:14 am
Re: a worry about the precisions
Erwin,
I tried the way like your said. and find some interesting things.
our goal: let cars moves reliable, and other obstacles can react with cars but no need to perfectly realistic.
solution 1:
step1 read rigidbody's position and velocity.
step2 calculate cars in own system, set velocity to rigidbody.
then goto step1
the most important thing is the integrator. if the integrator in own system isn't 100% same as physics engines, the system will lose energy or explode even never have a collision.
solution 2:
step1 read rigidbody's position
step2 calculate cars in own system based that position
step3 set velocity to rigidbody
then goto step1
just like solution1, system will lose energy or explode by integrator difference. but better.
solution 3:
step1 read velocity form rigidbody
step2 caculate cars in own system based that velocity
step3 move rigidbody manually and set velocity to rigidbody
then goto step1
no energy problems in no collisions situation. when collisions appear, cars looks a little "unstoppable" because their movements not affected by collision force. but, it's close to our goal.
maybe if you want to move things in physics space, you must move the things position by your self. physics engine will help you handle the collision, restrict your things not pass through others. but the reaction, you need to do it by yourself ……
Anyway, hit something in racing game always be a punishment of your poor driving skills. So, let the crash details go free !
I tried the way like your said. and find some interesting things.
our goal: let cars moves reliable, and other obstacles can react with cars but no need to perfectly realistic.
solution 1:
step1 read rigidbody's position and velocity.
step2 calculate cars in own system, set velocity to rigidbody.
then goto step1
the most important thing is the integrator. if the integrator in own system isn't 100% same as physics engines, the system will lose energy or explode even never have a collision.
solution 2:
step1 read rigidbody's position
step2 calculate cars in own system based that position
step3 set velocity to rigidbody
then goto step1
just like solution1, system will lose energy or explode by integrator difference. but better.
solution 3:
step1 read velocity form rigidbody
step2 caculate cars in own system based that velocity
step3 move rigidbody manually and set velocity to rigidbody
then goto step1
no energy problems in no collisions situation. when collisions appear, cars looks a little "unstoppable" because their movements not affected by collision force. but, it's close to our goal.
maybe if you want to move things in physics space, you must move the things position by your self. physics engine will help you handle the collision, restrict your things not pass through others. but the reaction, you need to do it by yourself ……
Anyway, hit something in racing game always be a punishment of your poor driving skills. So, let the crash details go free !