FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Collison detection callbacks with SIO2 & Bullet Kinematics

2 posters

Go down

Collison detection callbacks with SIO2 & Bullet Kinematics Empty Collison detection callbacks with SIO2 & Bullet Kinematics

Post  cgen2 Fri Sep 18, 2009 5:58 am

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?] scratch confused

cgen2

Posts : 38
Join date : 2008-12-14

Back to top Go down

Collison detection callbacks with SIO2 & Bullet Kinematics Empty Re: Collison detection callbacks with SIO2 & Bullet Kinematics

Post  sio2interactive Fri Sep 18, 2009 3:40 pm

linear velocity function jitters in my scenario

>> That should not happen... there must be a problem with your implementation...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Collison detection callbacks with SIO2 & Bullet Kinematics Empty Re: Collison detection callbacks with SIO2 & Bullet Kinematics

Post  cgen2 Fri Sep 18, 2009 6:39 pm

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.

cgen2

Posts : 38
Join date : 2008-12-14

Back to top Go down

Collison detection callbacks with SIO2 & Bullet Kinematics Empty Re: Collison detection callbacks with SIO2 & Bullet Kinematics

Post  sio2interactive Fri Sep 18, 2009 9:21 pm

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...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Collison detection callbacks with SIO2 & Bullet Kinematics Empty Re: Collison detection callbacks with SIO2 & Bullet Kinematics

Post  cgen2 Fri Sep 18, 2009 11:00 pm

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 ....

cgen2

Posts : 38
Join date : 2008-12-14

Back to top Go down

Collison detection callbacks with SIO2 & Bullet Kinematics Empty Re: Collison detection callbacks with SIO2 & Bullet Kinematics

Post  sio2interactive Sat Sep 19, 2009 2:13 am

hardcoding a value that increment every frame is not ideal at all... cuz basically the FPS will change every second...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Collison detection callbacks with SIO2 & Bullet Kinematics Empty Re: Collison detection callbacks with SIO2 & Bullet Kinematics

Post  cgen2 Sat Sep 19, 2009 4:12 pm

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

cgen2

Posts : 38
Join date : 2008-12-14

Back to top Go down

Collison detection callbacks with SIO2 & Bullet Kinematics Empty Re: Collison detection callbacks with SIO2 & Bullet Kinematics

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum