mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 19:04:32 +02:00
print when bullet and local octree don't agree on position of an entity
This commit is contained in:
parent
1cd93b9ec8
commit
82828f0b93
3 changed files with 28 additions and 0 deletions
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue