When I create a collision shape for rigid body (in this case box) I use vertices positions and scale from the opengl matrix, the code looks this way:

glm::vec3 boxDim = getBoxDim(verticesPositions, scale);
collisionShape_.reset(new btBoxShape(btVector3(boxDim.x, boxDim.y, boxDim.z)));

When a simulation step is done I need to update opengl matrix for the object. I calculate a new model matrix this way:

btTransform transform = rigidBody->getWorldTransform();
float openglMatrix[16];

glm::mat4 newModelMatrix = glm::make_mat4(openglMatrix);
newModelMatrix = glm::scale(newModelMatrix, glTransform.getScale());

My code works but I wonder if there is any possibility to have already scale in the transform returned by getWorldTransform. Then I can ommit this line of the code:

newModelMatrix = glm::scale(newModelMatrix, glTransform.getScale());
  • \$\begingroup\$ What's the reason you want to skip that line? Do you expect it to impact performance? \$\endgroup\$ – Bram Jan 1 at 23:20
  • \$\begingroup\$ No, I just wonder if I use bullet api correctly. \$\endgroup\$ – Irbis Jan 2 at 19:10

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.