To summarize the problem (s):
I have two bodies in my world, one of which is the earth, and the other is a falling box called "fallStar".
1) I donโt understand why my bullet world is not aligned with my painted world unless I set the offset btVector3(2,2,2) to MotionState (btDefault). There is no magic magic anywhere in the code to explain the bias. Or at least I could not find any reason, and not in the shaders, anywhere.
2) I expected that I could use several instances of btDefaultMotionState , to be precise, I wanted to use one instance for the falling object and place it somewhere above the ground, and then create another instance for the base, which should just align with my graphics, never without moving.
What I am experiencing with respect to 2) is that for some reason, the instance of btDefaultMotionState for the falling object always also affects one for the earth, without any reference.
Now to the code:
Creating a fallBox:
btCollisionShape *fallingBoxShape = new btBoxShape(btVector3(1,1,1)); btScalar fallingBoxMass = 1; btVector3 fallingBoxInertia(0,0,0); fallingBoxShape->calculateLocalInertia(fallingBoxMass, fallingBoxInertia); // TODO this state somehow defines where exactly _ALL_ of the physicsWorld is... btDefaultMotionState *fallMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1), btVector3(2,2,2))); //btDefaultMotionState *fallMotionState = new btDefaultMotionState(); btRigidBody::btRigidBodyConstructionInfo fallingBoxBodyCI(fallingBoxMass, fallMotionState, fallingBoxShape, fallingBoxInertia); /*btTransform initialTransform; initialTransform.setOrigin(btVector3(0,5,0));*/ this->fallingBoxBody = new btRigidBody(fallingBoxBodyCI); /*fallMotionState->setWorldTransform(initialTransform); this->fallingBoxBody->setWorldTransform(initialTransform);*/ this->physicsWorld->addBody(*fallingBoxBody);
Now, the interesting parts for me are the necessary offset btVector3(2,2,2) to align it with my drawn world, and this:
btTransform initialTransform; initialTransform.setOrigin(btVector3(0,5,0)); this->fallingStarBody = new btRigidBody(fallingStarBodyCI); fallMotionState->setWorldTransform(initialTransform);
If I repeat this part of the code, all bodies again show an offset, but NOT just 5, which I could somehow understand if for some reason worldTransform will affect every entity, but 2.2.2 from .. which I cannot understand at all.
I think this line is useless:
fallMotionState->setWorldTransform(initialTransform); because it does not change anything, whether there or not.
Now to the earth creation code:
btCompoundShape *shape = new btCompoundShape(); ... just some logic, nothing to do with bullet btTransform transform; transform.setIdentity(); transform.setOrigin(btVector3(x + (this->x * Ground::width), y + (this->y * Ground::height), z + (this->z * Ground::depth))); btBoxShape *boxShape = new btBoxShape(btVector3(1,0,1));
(this part simply creates a composite shape for each surface tile :)
btRigidBody::btRigidBodyConstructionInfo info(0, nullptr, shape); return new btRigidBody(info);
Here, I intentionally set the motion state to nullptr , but that does not change anything.
Now Iโm really curious ... I thought the implementation of btDefaultMotionState is a single, but it doesnโt look like that, so ... why the hell does setting a single body motionState affect the whole world?


