mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:18:38 +02:00
adding some debugging
This commit is contained in:
parent
18e0a91ea8
commit
f85774c687
3 changed files with 42 additions and 1 deletions
|
@ -36,6 +36,11 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemI
|
||||||
int sizeOut = 0;
|
int sizeOut = 0;
|
||||||
|
|
||||||
if (EntityItemProperties::encodeEntityEditPacket(type, modelID, properties, &bufferOut[0], _maxPacketSize, sizeOut)) {
|
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);
|
queueOctreeEditMessage(type, bufferOut, sizeOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,6 +227,9 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
|
||||||
|
|
||||||
EntityItemID id(_entity->getID());
|
EntityItemID id(_entity->getID());
|
||||||
EntityEditPacketSender* entityPacketSender = static_cast<EntityEditPacketSender*>(packetSender);
|
EntityEditPacketSender* entityPacketSender = static_cast<EntityEditPacketSender*>(packetSender);
|
||||||
|
#ifdef WANT_DEBUG
|
||||||
|
qDebug() << "EntityMotionState::sendUpdate()... calling queueEditEntityMessage()...";
|
||||||
|
#endif
|
||||||
entityPacketSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
|
entityPacketSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
|
||||||
|
|
||||||
// The outgoing flags only itemized WHAT to send, not WHETHER to send, hence we always set them
|
// The outgoing flags only itemized WHAT to send, not WHETHER to send, hence we always set them
|
||||||
|
|
|
@ -111,6 +111,12 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) {
|
||||||
_sentFrame = simulationFrame;
|
_sentFrame = simulationFrame;
|
||||||
return false;
|
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;
|
float dt = (float)(simulationFrame - _sentFrame) * PHYSICS_ENGINE_FIXED_SUBSTEP;
|
||||||
_sentFrame = simulationFrame;
|
_sentFrame = simulationFrame;
|
||||||
|
@ -147,11 +153,21 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) {
|
||||||
glm::vec3 position = bulletToGLM(worldTrans.getOrigin());
|
glm::vec3 position = bulletToGLM(worldTrans.getOrigin());
|
||||||
|
|
||||||
float dx2 = glm::distance2(position, _sentPosition);
|
float dx2 = glm::distance2(position, _sentPosition);
|
||||||
|
|
||||||
const float MAX_POSITION_ERROR_SQUARED = 0.001f; // 0.001 m^2 ~~> 0.03 m
|
const float MAX_POSITION_ERROR_SQUARED = 0.001f; // 0.001 m^2 ~~> 0.03 m
|
||||||
if (dx2 > MAX_POSITION_ERROR_SQUARED) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glm::length2(_sentAngularVelocity) > 0.0f) {
|
if (glm::length2(_sentAngularVelocity) > 0.0f) {
|
||||||
// compute rotation error
|
// compute rotation error
|
||||||
_sentAngularVelocity *= powf(1.0f - _angularDamping, dt);
|
_sentAngularVelocity *= powf(1.0f - _angularDamping, dt);
|
||||||
|
@ -165,6 +181,23 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) {
|
||||||
}
|
}
|
||||||
const float MIN_ROTATION_DOT = 0.98f;
|
const float MIN_ROTATION_DOT = 0.98f;
|
||||||
glm::quat actualRotation = bulletToGLM(worldTrans.getRotation());
|
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);
|
return (fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue