print when bullet and local octree don't agree on position of an entity

This commit is contained in:
Seth Alves 2015-05-05 13:52:10 -07:00
parent 1cd93b9ec8
commit 82828f0b93
3 changed files with 28 additions and 0 deletions

View file

@ -83,4 +83,13 @@ void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args)
if (PhysicsEngine::physicsInfoIsActive(entity->getPhysicsInfo())) {
renderHoverDot(entity, args);
}
glm::vec3 position;
glm::quat rotation;
if (PhysicsEngine::getBodyLocation(entity->getPhysicsInfo(), position, rotation)) {
glm::vec3 positionOffset = glm::abs(position - entity->getPosition());
if (positionOffset[0] > 0.001 || positionOffset[1] > 0.001 || positionOffset[2] > 0.001) {
qDebug() << positionOffset[0] << positionOffset[1] << positionOffset[2];
}
}
}

View file

@ -418,3 +418,21 @@ bool PhysicsEngine::physicsInfoIsActive(void* physicsInfo) {
return body->isActive();
}
bool PhysicsEngine::getBodyLocation(void* physicsInfo, glm::vec3& positionReturn, glm::quat& rotationReturn) {
if (!physicsInfo) {
return false;
}
ObjectMotionState* motionState = static_cast<ObjectMotionState*>(physicsInfo);
btRigidBody* body = motionState->getRigidBody();
if (!body) {
return false;
}
const btTransform& worldTrans = body->getCenterOfMassTransform();
positionReturn = bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset();
rotationReturn = bulletToGLM(worldTrans.getRotation());
return true;
}

View file

@ -93,6 +93,7 @@ public:
void dumpNextStats() { _dumpNextStats = true; }
static bool physicsInfoIsActive(void* physicsInfo);
static bool getBodyLocation(void* physicsInfo, glm::vec3& positionReturn, glm::quat& rotationReturn);
private:
void removeContacts(ObjectMotionState* motionState);