Collison detection callbacks with SIO2 & Bullet Kinematics
2 posters
Collison detection callbacks with SIO2 & Bullet Kinematics
How to get working collision detection callbacks with Bullet's kinematic (DIY movement) mode?
I find collision detection callbacks function as expected using SIO2/Bullet with a dynamic actor. Unfortunately Bullet's linear velocity function jitters in my scenario so I am forced to the kinematic mode. (I integrate linear accelerations to get velocities using a simple algorithm (Adams-Bashford) and that's smooth as). But collision detection callbacks using the SIO2 sensors are not working but otherwise unchanged from dynamic mode.
In my loader I have this code fragment
[ // Enable Bullet kinematics. Set small mass with 0 rot inertia. Note: mass > 0.0 else static object
_object->_SIO2objectphysic->mass = 0.1;
_object->_SIO2objectphysic->_btRigidBody->setMassProps( 0.1, btVector3 ( 0.0, 0.0, 0.0 ) );
_object->_SIO2objectphysic->_btRigidBody->
setCollisionFlags( _object->_SIO2objectphysic->_btRigidBody->getCollisionFlags()
| btCollisionObject::CF_KINEMATIC_OBJECT );
:
:
:
:
_object->_SIO2objectphysic->_btRigidBody->setActivationState( DISABLE_DEACTIVATION );
In the render call I have:
// Attach new transform to Bullet rigid body matrix.
btTransform _btTransform;
_btTransform.setFromOpenGLMatrix( (btScalar *)_object->_SIO2transform->mat );
_object->_SIO2objectphysic->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( _object->_SIO2transform->mat );
Do any of you know this trick?]
I find collision detection callbacks function as expected using SIO2/Bullet with a dynamic actor. Unfortunately Bullet's linear velocity function jitters in my scenario so I am forced to the kinematic mode. (I integrate linear accelerations to get velocities using a simple algorithm (Adams-Bashford) and that's smooth as). But collision detection callbacks using the SIO2 sensors are not working but otherwise unchanged from dynamic mode.
In my loader I have this code fragment
[ // Enable Bullet kinematics. Set small mass with 0 rot inertia. Note: mass > 0.0 else static object
_object->_SIO2objectphysic->mass = 0.1;
_object->_SIO2objectphysic->_btRigidBody->setMassProps( 0.1, btVector3 ( 0.0, 0.0, 0.0 ) );
_object->_SIO2objectphysic->_btRigidBody->
setCollisionFlags( _object->_SIO2objectphysic->_btRigidBody->getCollisionFlags()
| btCollisionObject::CF_KINEMATIC_OBJECT );
:
:
:
:
_object->_SIO2objectphysic->_btRigidBody->setActivationState( DISABLE_DEACTIVATION );
In the render call I have:
// Attach new transform to Bullet rigid body matrix.
btTransform _btTransform;
_btTransform.setFromOpenGLMatrix( (btScalar *)_object->_SIO2transform->mat );
_object->_SIO2objectphysic->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( _object->_SIO2transform->mat );
Do any of you know this trick?]
cgen2- Posts : 38
Join date : 2008-12-14
Re: Collison detection callbacks with SIO2 & Bullet Kinematics
linear velocity function jitters in my scenario
>> That should not happen... there must be a problem with your implementation...
>> That should not happen... there must be a problem with your implementation...
Re: Collison detection callbacks with SIO2 & Bullet Kinematics
Of course that's possible. Maybe timing?
But I would prefer to use Bullet kinematic mode. In my case I expect it is less computationally expensive than dynamic mode. (According to the Bullet user guide, dynamics is clipped onto basic collision detection and I'm down to 30 fps).
The Bullet user manual discusses several requirements for kinematic mode. The kinematic object should have zero mass. SIO2 seems to interpret an object with 0 mass as static. Not sure if this has consequences ... Also there has to be an object translation push back mechanism to Bullet (so Bullet knows where the object is) which I think I implemented in my code sample. But I have yet to prove it is working.
But I would prefer to use Bullet kinematic mode. In my case I expect it is less computationally expensive than dynamic mode. (According to the Bullet user guide, dynamics is clipped onto basic collision detection and I'm down to 30 fps).
The Bullet user manual discusses several requirements for kinematic mode. The kinematic object should have zero mass. SIO2 seems to interpret an object with 0 mass as static. Not sure if this has consequences ... Also there has to be an object translation push back mechanism to Bullet (so Bullet knows where the object is) which I think I implemented in my code sample. But I have yet to prove it is working.
cgen2- Posts : 38
Join date : 2008-12-14
Re: Collison detection callbacks with SIO2 & Bullet Kinematics
I really suggest you to stick with the approach implemented in SIO2... it work for every case... maybe have a look at tutorial 061, 062 and 09 to check how to manipulate the linear velocity in conjunction with the application delta time... Honestly I personally always use this in many projects and never had to go for kinematic and also never experience the jittering that you are mentioning... I really suggest you to check your implementation...
Re: Collison detection callbacks with SIO2 & Bullet Kinematics
I have given it a real crack ... studied the tutorials and everything but my flightsim scenario doesn't work at all well with Bullet's dynamic mode. I've tried implementing it using the tut09 framework but the plane jitters. Even my kinematic code jitters if I use sio2->_SIO2window->d_time as the time increment. My code is tuned to a specific magic time increment. I suspect you'd have to be a mathematician to understand why.
Anyhoooo ....
Anyhoooo ....
cgen2- Posts : 38
Join date : 2008-12-14
Re: Collison detection callbacks with SIO2 & Bullet Kinematics
hardcoding a value that increment every frame is not ideal at all... cuz basically the FPS will change every second...
Re: Collison detection callbacks with SIO2 & Bullet Kinematics
You'd think but hard coding a time step works great. Using the same (special magic value) time step in my flightsim and the SIO2 physicrender functions eliminates the jitter. And the collision callbacks work too so it's all sweeeeeeeeet.
You're a genius. Thanks
You're a genius. Thanks
cgen2- Posts : 38
Join date : 2008-12-14
Similar topics
» SIO2 Architecture and Bullet Physics integration
» Culling and Bullet
» Collision Detection
» Bullet for 2D
» Upgrading Bullet
» Culling and Bullet
» Collision Detection
» Bullet for 2D
» Upgrading Bullet
Permissions in this forum:
You cannot reply to topics in this forum