Dear all,
incorporating Bullet Physics API into a Game Project requires a lot of data copying/conversion from existing structures into Bullet Physics to perform all the math and physics calculations (copying of matrices, vectors, etc..).
In a game project, where the usual approach is saving processing time where possible, I go an idea to use Bullet Physics structures/functions as the main math/vector/3d structures everywhere in the project (not just in the game physics). If the data is formatted into Bullet Physics structures from the beginning of the project, then no conversion is later needed to perform physics calculations.
I would need your opinion: is this good idea? Does Bullet Physics contain all the math structures and functions usually needed for a game project? Alernatively, are there are any reasons, why it is not good idea to format all the game data into Bullet Physics structures?
In what ways does Bullet Physics API need to be updated to use its structures and functions everywhere in the game project?
Thanks. Regards.
Using BP Structures as the Main Game Data Structures.
-
- Posts: 7
- Joined: Sat Sep 18, 2010 12:33 pm
-
- Posts: 43
- Joined: Mon Jan 03, 2011 4:26 pm
Re: Using BP Structures as the Main Game Data Structures.
You mean like btTransform instead of your own matrix class?
I have tried it. I don't think btTransform supports scaling, so it's not perfect as an all-around matrix class, but it does produce OpenGL matrices, so it most of the work of transferring data from Bullet into the graphics engine is done for you.
You should avoid duplicating data as much as possible. If there's a situation where you can't avoid it, don't worry, it happens.
I have tried it. I don't think btTransform supports scaling, so it's not perfect as an all-around matrix class, but it does produce OpenGL matrices, so it most of the work of transferring data from Bullet into the graphics engine is done for you.
You should avoid duplicating data as much as possible. If there's a situation where you can't avoid it, don't worry, it happens.
-
- Posts: 7
- Joined: Sat Sep 18, 2010 12:33 pm
Re: Using BP Structures as the Main Game Data Structures.
lulzfish wrote:You mean like btTransform instead of your own matrix class?
I have tried it. I don't think btTransform supports scaling, so it's not perfect as an all-around matrix class, but it does produce OpenGL matrices, so it most of the work of transferring data from Bullet into the graphics engine is done for you.
You should avoid duplicating data as much as possible. If there's a situation where you can't avoid it, don't worry, it happens.
Hi Lulzfish,
that is exactly what I meant. I do not know what are all the missing things in BT API, but as you correctly pointed out, scaling would be one of them.
BT API is open source, therefore it should not be difficult to add missing functionality into btTransform. Is that correct, please?
Any ideas (for anyone), what might be other things difficult for BT to accomplish, if BT were used as the only data holder in the game (assuming BT classes would be used to perform all the game data math )?
Any ideas are welcome. If I start relying on BT from the beginning, it will be very difficult to exclude BT from some areas in my project later.
Thanks.
-
- Posts: 43
- Joined: Mon Jan 03, 2011 4:26 pm
Re: Using BP Structures as the Main Game Data Structures.
On second thought, that might be a bad idea. (maybe)
Ideally, I think your program should be able to swap out physics engines, so you probably don't want any core functionality to be based on Bullet's vector or matrix classes.
But if you're absolutely sure you'll always use Bullet, then there won't be any problems, it just might be bad practice.
Ideally, I think your program should be able to swap out physics engines, so you probably don't want any core functionality to be based on Bullet's vector or matrix classes.
But if you're absolutely sure you'll always use Bullet, then there won't be any problems, it just might be bad practice.
-
- Posts: 7
- Joined: Sat Sep 18, 2010 12:33 pm
Re: Using BP Structures as the Main Game Data Structures.
Thank you very much, Lulzfish.
Your second argumet is valid as well. The game core is built for more than one game. It is not yet known, whether BulletPhysics library will be used in all the subsequent titles.
To summarize, you believe, it is not worth of implementing BP as the main data holder and the main math library for the whole game, for the benefit gained from not dupicating and copying data into physics engine.
Any more ideas for anyone else?
Your second argumet is valid as well. The game core is built for more than one game. It is not yet known, whether BulletPhysics library will be used in all the subsequent titles.
To summarize, you believe, it is not worth of implementing BP as the main data holder and the main math library for the whole game, for the benefit gained from not dupicating and copying data into physics engine.
Any more ideas for anyone else?
-
- Posts: 77
- Joined: Thu Nov 26, 2009 6:32 pm
Re: Using BP Structures as the Main Game Data Structures.
One more thing to remember would to maintain the proper data type during conversion from Bullet to your own custom library to avoid any precision problems.
Keep floats as floats and doubles as doubles.
BTW: You would have to recompile Bullet for enabling double precision.
Keep floats as floats and doubles as doubles.
BTW: You would have to recompile Bullet for enabling double precision.
-
- Posts: 7
- Joined: Sat Sep 18, 2010 12:33 pm
Re: Using BP Structures as the Main Game Data Structures.
Hi Winspear,
that is valuable comment. Thank you for that.
I would like to know, if anybody thinks, it might be a good idea to use BP structures and libraries in the overall project, not only for the physics part. In other words, if using BP is worth of the savings gainded from not duplicating and converting data into the physics engine.
Best regards.
that is valuable comment. Thank you for that.
I would like to know, if anybody thinks, it might be a good idea to use BP structures and libraries in the overall project, not only for the physics part. In other words, if using BP is worth of the savings gainded from not duplicating and converting data into the physics engine.
Best regards.
-
- Posts: 508
- Joined: Fri May 30, 2008 2:51 am
- Location: Ossining, New York
Re: Using BP Structures as the Main Game Data Structures.
There should not be any performance problem translating from btVector3 to MyVector3 -- as long as the code is properly written to be inlineable by the compiler.
FWIW i just spent a long time removing all Ogre::Vector3 and friends from my game logic since I want to be able to make a dedicated server with no graphics.
FWIW i just spent a long time removing all Ogre::Vector3 and friends from my game logic since I want to be able to make a dedicated server with no graphics.