Change position / orientation of btRigidBody on the fly in Bullet Physics

I know that this violates the laws of physics, but although there are often practical reasons for instantly changing the position and orientation of the body in the game, most physical modeling libraries will not allow this, so Bullet Physics will not.

So, I would appreciate any suggestion or comment on this.

By the way, teleportation comes to mind, which requires these instant changes. In addition, a more exotic application may be inertial - for example, when capsizing or rotating a portable device with an accelerometer, so that objects will appear static in relation to the user. Augmented reality should not sound crappy.

+4
source share
1 answer

Assuming I understand your question correctly, I would recommend checking BulletDynamics/Character/btCharacterControllerInterface.h and / or BulletDynamics/Dynamics/btActionInterface.h . Often, someone wants to "bend the rules" when implementing the movement of characters - to implement teleportation, for example, you can use the void warp(const btVector3& origin) btCharacterControllerInterface from btCharacterControllerInterface .

Personally, I managed to inherit directly from btActionInterface , while maintaining a pointer to btGhostObject , which I can update and implement my logic from there, but YMMV.

Note. If you just want to change the position and orientation, you can call the void setWorldTransform(const btTransform& worldTrans) btRigidBody on btRigidBody .

+2
source

Source: https://habr.com/ru/post/1447566/


All Articles