[solved] Bullet Hijacks my matrices?

User avatar
jubei
Posts: 11
Joined: Sun Jul 24, 2011 9:29 am

[solved] Bullet Hijacks my matrices?

Post by jubei »

Hello everybody. I am trying to add collision detection to my engine. I don't want bullet to act upon them, all I want is to intersect a spherical cursor with some object in the scene, and be notified of the intersection so that I can use it for object selection.

I make a btCollisionWorld then I make two btCollisionObjects. To each btCollisionObject I add a shape. A sphere to the cursor and a btConvexHullShape to the mesh. Then after I initialize the collisionWorld as per the examples, I do

collisionWorld->addCollisionObject(cursor) and the same for the heart. Everything ok so far.

Following that I want to let bullet know WHERE those collisionObjects are in the world, so I use a temporary btTransform object to setWorldTransform from the publicly available matrix member of my asset class:

btTransform objTrans;
objTrans.getOpenGLMatrix(glm::value_ptr(cursor.m_modelMatrix));
coCursor->setWorldTransform(objTrans);

The most amazing thing happens If I do this (both to my cursor and to my mesh). IF I execute this code, I can no longer draw my assets anywhere I want. It's like bullet hijacks their matrices and no longer lets me update them :/ It locks the objects in place and .. like.. does whatever with them. How is this possible?

The problems occur without me doing coCursor->setWorldTransform... All I need to do is:

btTransform objTrans;
objTrans.getOpenGLMatrix(glm::value_ptr(cursor.m_modelMatrix));

and my objects stay locked in place. There's no dynamics world object and no other stuff of any kind. Just a collisionWorld with two collisionobjects.

How is this possible?

many thanks in advance.
Last edited by jubei on Fri Aug 02, 2013 5:19 am, edited 1 time in total.
norbie
Posts: 21
Joined: Mon Feb 11, 2013 1:57 pm

Re: Bullet Hijacks my matrices?

Post by norbie »

Hello!

I am not really familiar with OpenGL and glm, but for me it seems you are using the wrong function of btTransform. getOpenGLMatrix gets the information from the btTransform and writes it to the given parameter, in your case cursor.m_modelMatrix.
I think you intended to do it the opposite way, which can be achieved using the setFromOpenGLMatrix function of btTransform.

Hope this helps.
User avatar
jubei
Posts: 11
Joined: Sun Jul 24, 2011 9:29 am

Re: Bullet Hijacks my matrices?

Post by jubei »

Thank you for your reply, I really appreciate the help! That was the problem!! Is there some place where this information is documented? Because I couldn't find any docs on each member function!
norbie wrote:Hello!

I am not really familiar with OpenGL and glm, but for me it seems you are using the wrong function of btTransform. getOpenGLMatrix gets the information from the btTransform and writes it to the given parameter, in your case cursor.m_modelMatrix.
I think you intended to do it the opposite way, which can be achieved using the setFromOpenGLMatrix function of btTransform.

Hope this helps.
norbie
Posts: 21
Joined: Mon Feb 11, 2013 1:57 pm

Re: [solved] Bullet Hijacks my matrices?

Post by norbie »

Sorry, I think bullet is not too well documented... :(