mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 11:48:52 +02:00
debugging stutter
This commit is contained in:
parent
14c7dc8eb9
commit
838a549abe
7 changed files with 1 additions and 74 deletions
|
@ -27,13 +27,7 @@ void EntityEditPacketSender::adjustEditPacketForClockSkew(PacketType type,
|
||||||
|
|
||||||
void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemID modelID,
|
void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemID modelID,
|
||||||
const EntityItemProperties& properties) {
|
const EntityItemProperties& properties) {
|
||||||
|
|
||||||
qDebug() << "EntityEditPacketSender::queueEditEntityMessage()...";
|
|
||||||
qDebug() << " ID:" << modelID;
|
|
||||||
qDebug() << " properties:" << properties;
|
|
||||||
|
|
||||||
if (!_shouldSend) {
|
if (!_shouldSend) {
|
||||||
qDebug() << " BAIL EARLY! _shouldSend:" << _shouldSend;
|
|
||||||
return; // bail early
|
return; // bail early
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +36,6 @@ 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)) {
|
||||||
qDebug() << " queueOctreeEditMessage() sizeOut:" << sizeOut;
|
|
||||||
queueOctreeEditMessage(type, bufferOut, sizeOut);
|
queueOctreeEditMessage(type, bufferOut, sizeOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1064,9 +1064,6 @@ const float MIN_SPIN_DELTA = 0.0003f;
|
||||||
|
|
||||||
void EntityItem::updatePosition(const glm::vec3& value) {
|
void EntityItem::updatePosition(const glm::vec3& value) {
|
||||||
if (glm::distance(_position, value) * (float)TREE_SCALE > MIN_POSITION_DELTA) {
|
if (glm::distance(_position, value) * (float)TREE_SCALE > MIN_POSITION_DELTA) {
|
||||||
qDebug() << "EntityItem::updatePosition()... ";
|
|
||||||
qDebug() << " new position:" << value;
|
|
||||||
qDebug() << " in meters:" << (value * (float) TREE_SCALE);
|
|
||||||
_position = value;
|
_position = value;
|
||||||
recalculateCollisionShape();
|
recalculateCollisionShape();
|
||||||
_dirtyFlags |= EntityItem::DIRTY_POSITION;
|
_dirtyFlags |= EntityItem::DIRTY_POSITION;
|
||||||
|
@ -1076,9 +1073,6 @@ void EntityItem::updatePosition(const glm::vec3& value) {
|
||||||
void EntityItem::updatePositionInMeters(const glm::vec3& value) {
|
void EntityItem::updatePositionInMeters(const glm::vec3& value) {
|
||||||
glm::vec3 position = glm::clamp(value / (float) TREE_SCALE, 0.0f, 1.0f);
|
glm::vec3 position = glm::clamp(value / (float) TREE_SCALE, 0.0f, 1.0f);
|
||||||
if (glm::distance(_position, position) * (float)TREE_SCALE > MIN_POSITION_DELTA) {
|
if (glm::distance(_position, position) * (float)TREE_SCALE > MIN_POSITION_DELTA) {
|
||||||
qDebug() << "EntityItem::updatePositionInMeters()... ";
|
|
||||||
qDebug() << " new position:" << position;
|
|
||||||
qDebug() << " in meters:" << value;
|
|
||||||
_position = position;
|
_position = position;
|
||||||
recalculateCollisionShape();
|
recalculateCollisionShape();
|
||||||
_dirtyFlags |= EntityItem::DIRTY_POSITION;
|
_dirtyFlags |= EntityItem::DIRTY_POSITION;
|
||||||
|
|
|
@ -305,7 +305,6 @@ void EntityTree::processRemovedEntities(const DeleteEntityOperator& theOperator)
|
||||||
/// we're not changing the content of the tree, we're only changing the internal IDs that map entities from creator
|
/// we're not changing the content of the tree, we're only changing the internal IDs that map entities from creator
|
||||||
/// based to known IDs. This means we don't have to recurse the tree to mark the changed path as dirty.
|
/// based to known IDs. This means we don't have to recurse the tree to mark the changed path as dirty.
|
||||||
void EntityTree::handleAddEntityResponse(const QByteArray& packet) {
|
void EntityTree::handleAddEntityResponse(const QByteArray& packet) {
|
||||||
qDebug() << "EntityTree::handleAddEntityResponse()";
|
|
||||||
|
|
||||||
if (!getIsClient()) {
|
if (!getIsClient()) {
|
||||||
qDebug() << "UNEXPECTED!!! EntityTree::handleAddEntityResponse() with !getIsClient() ***";
|
qDebug() << "UNEXPECTED!!! EntityTree::handleAddEntityResponse() with !getIsClient() ***";
|
||||||
|
@ -330,9 +329,6 @@ void EntityTree::handleAddEntityResponse(const QByteArray& packet) {
|
||||||
searchEntityID.id = entityID;
|
searchEntityID.id = entityID;
|
||||||
searchEntityID.creatorTokenID = creatorTokenID;
|
searchEntityID.creatorTokenID = creatorTokenID;
|
||||||
|
|
||||||
qDebug() << " creatorTokenID:" << creatorTokenID;
|
|
||||||
qDebug() << " entityID:" << entityID;
|
|
||||||
|
|
||||||
lockForWrite();
|
lockForWrite();
|
||||||
|
|
||||||
// find the creator token version, it's containing element, and the entity itself
|
// find the creator token version, it's containing element, and the entity itself
|
||||||
|
|
|
@ -795,13 +795,11 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "EntityTreeElement::readElementDataFromBuffer() about to construct entity item";
|
|
||||||
entityItem = EntityTypes::constructEntityItem(dataAt, bytesLeftToRead, args);
|
entityItem = EntityTypes::constructEntityItem(dataAt, bytesLeftToRead, args);
|
||||||
if (entityItem) {
|
if (entityItem) {
|
||||||
bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args);
|
bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args);
|
||||||
addEntityItem(entityItem); // add this new entity to this elements entities
|
addEntityItem(entityItem); // add this new entity to this elements entities
|
||||||
entityItemID = entityItem->getEntityItemID();
|
entityItemID = entityItem->getEntityItemID();
|
||||||
qDebug() << " entityItemID:" << entityItemID;
|
|
||||||
_myTree->setContainingElement(entityItemID, this);
|
_myTree->setContainingElement(entityItemID, this);
|
||||||
_myTree->postAddEntity(entityItem);
|
_myTree->postAddEntity(entityItem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,23 +159,13 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
|
||||||
return; // never update entities that are unknown
|
return; // never update entities that are unknown
|
||||||
}
|
}
|
||||||
if (_outgoingPacketFlags) {
|
if (_outgoingPacketFlags) {
|
||||||
qDebug() << "EntityMotionState::sendUpdate()...";
|
|
||||||
qDebug() << " _outgoingPacketFlags:" << _outgoingPacketFlags;
|
|
||||||
|
|
||||||
EntityItemProperties properties = _entity->getProperties();
|
EntityItemProperties properties = _entity->getProperties();
|
||||||
qDebug() << " _entity->getProperties():" << properties << "line:" << __LINE__;
|
|
||||||
|
|
||||||
if (_outgoingPacketFlags & EntityItem::DIRTY_POSITION) {
|
if (_outgoingPacketFlags & EntityItem::DIRTY_POSITION) {
|
||||||
btTransform worldTrans = _body->getWorldTransform();
|
btTransform worldTrans = _body->getWorldTransform();
|
||||||
_sentPosition = bulletToGLM(worldTrans.getOrigin());
|
_sentPosition = bulletToGLM(worldTrans.getOrigin());
|
||||||
properties.setPosition(_sentPosition + ObjectMotionState::getWorldOffset());
|
properties.setPosition(_sentPosition + ObjectMotionState::getWorldOffset());
|
||||||
qDebug() << " _sentPosition:" << _sentPosition << "line:" << __LINE__;
|
|
||||||
qDebug() << " ObjectMotionState::getWorldOffset():" << ObjectMotionState::getWorldOffset() << "line:" << __LINE__;
|
|
||||||
|
|
||||||
_sentRotation = bulletToGLM(worldTrans.getRotation());
|
_sentRotation = bulletToGLM(worldTrans.getRotation());
|
||||||
properties.setRotation(_sentRotation);
|
properties.setRotation(_sentRotation);
|
||||||
|
|
||||||
qDebug() << " after position properties:" << properties << "line:" << __LINE__;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_outgoingPacketFlags & EntityItem::DIRTY_VELOCITY) {
|
if (_outgoingPacketFlags & EntityItem::DIRTY_VELOCITY) {
|
||||||
|
@ -205,8 +195,6 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
|
||||||
properties.setGravity(_sentAcceleration);
|
properties.setGravity(_sentAcceleration);
|
||||||
// DANGER! EntityItem stores angularVelocity in degrees/sec!!!
|
// DANGER! EntityItem stores angularVelocity in degrees/sec!!!
|
||||||
properties.setAngularVelocity(glm::degrees(_sentAngularVelocity));
|
properties.setAngularVelocity(glm::degrees(_sentAngularVelocity));
|
||||||
|
|
||||||
qDebug() << " after velocity properties:" << properties << "line:" << __LINE__;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RELIABLE_SEND_HACK: count number of updates for entities at rest so we can stop sending them after some limit.
|
// RELIABLE_SEND_HACK: count number of updates for entities at rest so we can stop sending them after some limit.
|
||||||
|
@ -227,9 +215,6 @@ 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);
|
||||||
qDebug() << "EntityMotionState::sendUpdate()... about to call queueEditEntityMessage()";
|
|
||||||
qDebug() << " id:" << id;
|
|
||||||
qDebug() << " properties:" << properties;
|
|
||||||
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
|
||||||
|
|
|
@ -109,7 +109,6 @@ bool ObjectMotionState::doesNotNeedToSendUpdate() const {
|
||||||
bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) {
|
bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) {
|
||||||
assert(_body);
|
assert(_body);
|
||||||
|
|
||||||
|
|
||||||
// if we've never checked before, our _sentFrame will be 0, and we need to initialize our state
|
// if we've never checked before, our _sentFrame will be 0, and we need to initialize our state
|
||||||
if (_sentFrame == 0) {
|
if (_sentFrame == 0) {
|
||||||
_sentPosition = bulletToGLM(_body->getWorldTransform().getOrigin());
|
_sentPosition = bulletToGLM(_body->getWorldTransform().getOrigin());
|
||||||
|
@ -119,7 +118,6 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t wasSentFrame = _sentFrame;
|
|
||||||
float dt = (float)(simulationFrame - _sentFrame) * PHYSICS_ENGINE_FIXED_SUBSTEP;
|
float dt = (float)(simulationFrame - _sentFrame) * PHYSICS_ENGINE_FIXED_SUBSTEP;
|
||||||
_sentFrame = simulationFrame;
|
_sentFrame = simulationFrame;
|
||||||
bool isActive = _body->isActive();
|
bool isActive = _body->isActive();
|
||||||
|
@ -143,11 +141,6 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) {
|
||||||
|
|
||||||
// NOTE: math in done the simulation-frame, which is NOT necessarily the same as the world-frame
|
// NOTE: math in done the simulation-frame, which is NOT necessarily the same as the world-frame
|
||||||
// due to _worldOffset.
|
// due to _worldOffset.
|
||||||
|
|
||||||
glm::vec3 wasPosition = _sentPosition;
|
|
||||||
glm::vec3 wasVelocity = _sentVelocity;
|
|
||||||
glm::vec3 wasAcceleration = _sentAcceleration;
|
|
||||||
|
|
||||||
// compute position error
|
// compute position error
|
||||||
if (glm::length2(_sentVelocity) > 0.0f) {
|
if (glm::length2(_sentVelocity) > 0.0f) {
|
||||||
_sentVelocity += _sentAcceleration * dt;
|
_sentVelocity += _sentAcceleration * dt;
|
||||||
|
@ -161,36 +154,7 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) {
|
||||||
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) {
|
||||||
qDebug() << "ObjectMotionState::shouldSendUpdate()... computing position error";
|
return true;
|
||||||
|
|
||||||
glm::vec3 bulletVelocity = bulletToGLM(_body->getLinearVelocity());
|
|
||||||
|
|
||||||
qDebug() << " was _sentFrame:" << wasSentFrame;
|
|
||||||
qDebug() << " now _sentFrame:" << _sentFrame;
|
|
||||||
qDebug() << " dt:" << dt;
|
|
||||||
|
|
||||||
qDebug() << " was _sentAcceleration:" << wasAcceleration;
|
|
||||||
qDebug() << " now _sentAcceleration:" << _sentAcceleration;
|
|
||||||
|
|
||||||
qDebug() << " bulletVelocity:" << bulletVelocity;
|
|
||||||
qDebug() << " was _sentVelocity:" << wasVelocity;
|
|
||||||
qDebug() << " now _sentVelocity:" << _sentVelocity;
|
|
||||||
|
|
||||||
qDebug() << " was _sentPosition:" << wasPosition;
|
|
||||||
qDebug() << " now _sentPosition:" << _sentPosition;
|
|
||||||
qDebug() << " bullet position:" << position;
|
|
||||||
|
|
||||||
qDebug() << " dx2:" << dx2;
|
|
||||||
qDebug() << " (dx2 > MAX_POSITION_ERROR_SQUARED)... considering";
|
|
||||||
if (wasSentFrame > 0) {
|
|
||||||
qDebug() << " (wasSentFrame > 0)... return TRUE";
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
qDebug() << " (wasSentFrame == 0)... ignore use bullet position for next _sentPosition";
|
|
||||||
_sentPosition = position;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//qDebug() << " (dx2 <= MAX_POSITION_ERROR_SQUARED)... FALL THROUGH... likely return false";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glm::length2(_sentAngularVelocity) > 0.0f) {
|
if (glm::length2(_sentAngularVelocity) > 0.0f) {
|
||||||
|
|
|
@ -35,9 +35,6 @@ void PhysicsEngine::updateEntitiesInternal(const quint64& now) {
|
||||||
// (3) synchronize outgoing motion states
|
// (3) synchronize outgoing motion states
|
||||||
// (4) send outgoing packets
|
// (4) send outgoing packets
|
||||||
|
|
||||||
|
|
||||||
//qDebug() << "_numSubsteps:" << _numSubsteps;
|
|
||||||
|
|
||||||
// this is step (4)
|
// this is step (4)
|
||||||
QSet<ObjectMotionState*>::iterator stateItr = _outgoingPackets.begin();
|
QSet<ObjectMotionState*>::iterator stateItr = _outgoingPackets.begin();
|
||||||
while (stateItr != _outgoingPackets.end()) {
|
while (stateItr != _outgoingPackets.end()) {
|
||||||
|
|
Loading…
Reference in a new issue