From f85774c687cf870675996bb764d9471c892d9b0d Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 26 Jan 2015 09:45:33 -0800 Subject: [PATCH] adding some debugging --- .../entities/src/EntityEditPacketSender.cpp | 5 +++ libraries/physics/src/EntityMotionState.cpp | 3 ++ libraries/physics/src/ObjectMotionState.cpp | 35 ++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/libraries/entities/src/EntityEditPacketSender.cpp b/libraries/entities/src/EntityEditPacketSender.cpp index f2588d0493..a04e07ebb3 100644 --- a/libraries/entities/src/EntityEditPacketSender.cpp +++ b/libraries/entities/src/EntityEditPacketSender.cpp @@ -36,6 +36,11 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemI int sizeOut = 0; if (EntityItemProperties::encodeEntityEditPacket(type, modelID, properties, &bufferOut[0], _maxPacketSize, sizeOut)) { + #ifdef WANT_DEBUG + qDebug() << "calling queueOctreeEditMessage()..."; + qDebug() << " id:" << modelID; + qDebug() << " properties:" << properties; + #endif queueOctreeEditMessage(type, bufferOut, sizeOut); } } diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 96897ff527..a6a358faa0 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -227,6 +227,9 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ EntityItemID id(_entity->getID()); EntityEditPacketSender* entityPacketSender = static_cast(packetSender); + #ifdef WANT_DEBUG + qDebug() << "EntityMotionState::sendUpdate()... calling queueEditEntityMessage()..."; + #endif entityPacketSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, id, properties); // The outgoing flags only itemized WHAT to send, not WHETHER to send, hence we always set them diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index dfa059d47f..7e9c6b76b6 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -111,6 +111,12 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { _sentFrame = simulationFrame; return false; } + + #ifdef WANT_DEBUG + glm::vec3 wasPosition = _sentPosition; + glm::quat wasRotation = _sentRotation; + glm::vec3 wasAngularVelocity = _sentAngularVelocity; + #endif float dt = (float)(simulationFrame - _sentFrame) * PHYSICS_ENGINE_FIXED_SUBSTEP; _sentFrame = simulationFrame; @@ -147,11 +153,21 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { glm::vec3 position = bulletToGLM(worldTrans.getOrigin()); float dx2 = glm::distance2(position, _sentPosition); + const float MAX_POSITION_ERROR_SQUARED = 0.001f; // 0.001 m^2 ~~> 0.03 m if (dx2 > MAX_POSITION_ERROR_SQUARED) { + + #ifdef WANT_DEBUG + qDebug() << ".... (dx2 > MAX_POSITION_ERROR_SQUARED) ...."; + qDebug() << "wasPosition:" << wasPosition; + qDebug() << "bullet position:" << position; + qDebug() << "_sentPosition:" << _sentPosition; + qDebug() << "dx2:" << dx2; + #endif + return true; } - + if (glm::length2(_sentAngularVelocity) > 0.0f) { // compute rotation error _sentAngularVelocity *= powf(1.0f - _angularDamping, dt); @@ -165,6 +181,23 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { } const float MIN_ROTATION_DOT = 0.98f; glm::quat actualRotation = bulletToGLM(worldTrans.getRotation()); + + #ifdef WANT_DEBUG + if ((fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT)) { + qDebug() << ".... ((fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT)) ...."; + + qDebug() << "wasAngularVelocity:" << wasAngularVelocity; + qDebug() << "_sentAngularVelocity:" << _sentAngularVelocity; + + qDebug() << "length wasAngularVelocity:" << glm::length(wasAngularVelocity); + qDebug() << "length _sentAngularVelocity:" << glm::length(_sentAngularVelocity); + + qDebug() << "wasRotation:" << wasRotation; + qDebug() << "bullet actualRotation:" << actualRotation; + qDebug() << "_sentRotation:" << _sentRotation; + } + #endif + return (fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT); }