mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-06 04:46:24 +02:00
take entity-server clock-skew into account when handling action expiration times
This commit is contained in:
parent
5c031a38c7
commit
46e5bf0435
9 changed files with 38 additions and 5 deletions
|
@ -66,6 +66,7 @@ EntityActionPointer InterfaceActionFactory::factoryBA(EntityItemPointer ownerEnt
|
|||
if (action) {
|
||||
action->deserialize(data);
|
||||
if (action->lifetimeIsOver()) {
|
||||
qDebug() << "InterfaceActionFactory::factoryBA lifetimeIsOver during action creation";
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ QByteArray AvatarActionHold::serialize() const {
|
|||
dataStream << _linearTimeScale;
|
||||
dataStream << _hand;
|
||||
|
||||
dataStream << _expires;
|
||||
dataStream << _expires + getEntityServerClockSkew();
|
||||
dataStream << _tag;
|
||||
});
|
||||
|
||||
|
@ -276,6 +276,7 @@ void AvatarActionHold::deserialize(QByteArray serializedArguments) {
|
|||
dataStream >> _hand;
|
||||
|
||||
dataStream >> _expires;
|
||||
_expires -= getEntityServerClockSkew();
|
||||
dataStream >> _tag;
|
||||
|
||||
#if WANT_DEBUG
|
||||
|
|
|
@ -342,6 +342,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
"ERROR CASE...args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU";
|
||||
return 0;
|
||||
}
|
||||
setSourceUUID(args.sourceUUID);
|
||||
|
||||
args.entitiesPerPacket++;
|
||||
|
||||
|
@ -1534,6 +1535,8 @@ bool EntityItem::addActionInternal(EntitySimulation* simulation, EntityActionPoi
|
|||
if (success) {
|
||||
_allActionsDataCache = newDataCache;
|
||||
_dirtyFlags |= Simulation::DIRTY_PHYSICS_ACTIVATION;
|
||||
} else {
|
||||
qDebug() << "EntityItem::addActionInternal -- serializeActions failed";
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -1628,6 +1631,7 @@ void EntityItem::deserializeActionsInternal() {
|
|||
quint64 now = usecTimestampNow();
|
||||
|
||||
if (!_element) {
|
||||
qDebug() << "EntityItem::deserializeActionsInternal -- no _element";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1670,6 +1674,8 @@ void EntityItem::deserializeActionsInternal() {
|
|||
if (action) {
|
||||
entity->addActionInternal(simulation, action);
|
||||
action->locallyAddedButNotYetReceived = false;
|
||||
} else {
|
||||
qDebug() << "EntityItem::deserializeActionsInternal -- action creation failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -407,9 +407,12 @@ public:
|
|||
QVariantMap getActionArguments(const QUuid& actionID) const;
|
||||
void deserializeActions();
|
||||
void setActionDataDirty(bool value) const { _actionDataDirty = value; }
|
||||
bool getActionDataDirty() const { return _actionDataDirty; }
|
||||
bool shouldSuppressLocationEdits() const;
|
||||
|
||||
void setSourceUUID(const QUuid& sourceUUID) { _sourceUUID = sourceUUID; }
|
||||
const QUuid& getSourceUUID() const { return _sourceUUID; }
|
||||
bool matchesSourceUUID(const QUuid& sourceUUID) const { return _sourceUUID == sourceUUID; }
|
||||
|
||||
protected:
|
||||
|
||||
const QByteArray getActionDataInternal() const;
|
||||
|
@ -510,6 +513,8 @@ protected:
|
|||
// _previouslyDeletedActions is used to avoid an action being re-added due to server round-trip lag
|
||||
static quint64 _rememberDeletedActionTime;
|
||||
mutable QHash<QUuid, quint64> _previouslyDeletedActions;
|
||||
|
||||
QUuid _sourceUUID; /// the server node UUID we came from
|
||||
};
|
||||
|
||||
#endif // hifi_EntityItem_h
|
||||
|
|
|
@ -302,7 +302,7 @@ bool EntityMotionState::remoteSimulationOutOfSync(uint32_t simulationStep) {
|
|||
_serverPosition += dt * _serverVelocity;
|
||||
}
|
||||
|
||||
if (_serverActionData != _entity->getActionData() || _entity->getActionDataDirty()) {
|
||||
if (_serverActionData != _entity->getActionData()) {
|
||||
setOutgoingPriority(SCRIPT_EDIT_SIMULATION_PRIORITY);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,22 @@ void ObjectAction::updateAction(btCollisionWorld* collisionWorld, btScalar delta
|
|||
updateActionWorker(deltaTimeStep);
|
||||
}
|
||||
|
||||
int ObjectAction::getEntityServerClockSkew() {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
||||
auto ownerEntity = _ownerEntity.lock();
|
||||
if (!ownerEntity) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const QUuid& entityServerNodeID = ownerEntity->getSourceUUID();
|
||||
auto entityServerNode = nodeList->nodeWithUUID(entityServerNodeID);
|
||||
if (entityServerNode) {
|
||||
return entityServerNode->getClockSkewUsec();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ObjectAction::updateArguments(QVariantMap arguments) {
|
||||
bool somethingChanged = false;
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
int getEntityServerClockSkew();
|
||||
|
||||
virtual btRigidBody* getRigidBody();
|
||||
virtual glm::vec3 getPosition();
|
||||
virtual void setPosition(glm::vec3 position);
|
||||
|
|
|
@ -160,7 +160,7 @@ QByteArray ObjectActionOffset::serialize() const {
|
|||
dataStream << _linearDistance;
|
||||
dataStream << _linearTimeScale;
|
||||
dataStream << _positionalTargetSet;
|
||||
dataStream << _expires;
|
||||
dataStream << _expires + getEntityServerClockSkew();
|
||||
dataStream << _tag;
|
||||
});
|
||||
|
||||
|
@ -190,6 +190,7 @@ void ObjectActionOffset::deserialize(QByteArray serializedArguments) {
|
|||
dataStream >> _linearTimeScale;
|
||||
dataStream >> _positionalTargetSet;
|
||||
dataStream >> _expires;
|
||||
_expires -= getEntityServerClockSkew();
|
||||
dataStream >> _tag;
|
||||
_active = true;
|
||||
});
|
||||
|
|
|
@ -198,7 +198,7 @@ QByteArray ObjectActionSpring::serialize() const {
|
|||
dataStream << _rotationalTarget;
|
||||
dataStream << _angularTimeScale;
|
||||
dataStream << _rotationalTargetSet;
|
||||
dataStream << _expires;
|
||||
dataStream << _expires + getEntityServerClockSkew();
|
||||
dataStream << _tag;
|
||||
});
|
||||
|
||||
|
@ -233,6 +233,7 @@ void ObjectActionSpring::deserialize(QByteArray serializedArguments) {
|
|||
dataStream >> _rotationalTargetSet;
|
||||
|
||||
dataStream >> _expires;
|
||||
_expires -= getEntityServerClockSkew();
|
||||
dataStream >> _tag;
|
||||
|
||||
_active = true;
|
||||
|
|
Loading…
Reference in a new issue