Splitting Bullet in Various Components

Leonardo
Posts: 4
Joined: Wed Jul 13, 2011 9:24 am

Splitting Bullet in Various Components

Post by Leonardo »

Hello. I have a engine that works in a component-entity way, i.e, you would add a collider component to an object so you can detect collisions with it and a rigidbody component so it can react to collisions.

Previous to this week I had custom components for doing kinematics (a component that has acceleration and speed an apply them to the position of the object), a collider that was doing brute force to detect collisions and a rigidbody that, once these collisions were detected, applied some basic inertia stuff, but collision detection is slow and my rigidbody is very buggy.

Now, I am trying to port this code to use bullet, while keeping the same scheme - a component that do movement, one that do collision detection and one that reacts to collisions, and I am wondering the way to go with Bullet.

Since btRigitBody inherits from btCollisionObject, I figured that collider component would create and manage the world and set up everything as rigidbodies, but figure a way to use them like triggers. Then, when a rigidbody component gets attached, the collider would make the rigidbody work again - is that ok or do you have a better idea that feels less of a hack?

But now I have this kinematic component and I do not know how to integrate it with bullet - I would much like to left it untouched, that is, using the basic integrators (speed += a*dt; pos += speed *dt); My idea was that the collider would update the rigidbody position every frame that position gets changed elsewhere (i.e, not changed by the rigidbody/collider components, but from some user custom component), and update the object position based on rigidbody after world calculation. But then I haven't found any place to set acceleration/speed directly on Bullet, only forces and impulses. I can go with F=m*a and apply that force - is it right? how do you people do this when you want to set up acceleration or speed directly?

Has anybody any experience in breaking down a physics engine like this? What is the best/right approach? How can I keep my kinematics component independent of Bullet code? (that is, I just want to move it around, I shouldn't need Bullet for it...)

Thanks.