mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 03:53:22 +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) {
|
if (action) {
|
||||||
action->deserialize(data);
|
action->deserialize(data);
|
||||||
if (action->lifetimeIsOver()) {
|
if (action->lifetimeIsOver()) {
|
||||||
|
qDebug() << "InterfaceActionFactory::factoryBA lifetimeIsOver during action creation";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,7 +243,7 @@ QByteArray AvatarActionHold::serialize() const {
|
||||||
dataStream << _linearTimeScale;
|
dataStream << _linearTimeScale;
|
||||||
dataStream << _hand;
|
dataStream << _hand;
|
||||||
|
|
||||||
dataStream << _expires;
|
dataStream << _expires + getEntityServerClockSkew();
|
||||||
dataStream << _tag;
|
dataStream << _tag;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -276,6 +276,7 @@ void AvatarActionHold::deserialize(QByteArray serializedArguments) {
|
||||||
dataStream >> _hand;
|
dataStream >> _hand;
|
||||||
|
|
||||||
dataStream >> _expires;
|
dataStream >> _expires;
|
||||||
|
_expires -= getEntityServerClockSkew();
|
||||||
dataStream >> _tag;
|
dataStream >> _tag;
|
||||||
|
|
||||||
#if WANT_DEBUG
|
#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";
|
"ERROR CASE...args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
setSourceUUID(args.sourceUUID);
|
||||||
|
|
||||||
args.entitiesPerPacket++;
|
args.entitiesPerPacket++;
|
||||||
|
|
||||||
|
@ -1534,6 +1535,8 @@ bool EntityItem::addActionInternal(EntitySimulation* simulation, EntityActionPoi
|
||||||
if (success) {
|
if (success) {
|
||||||
_allActionsDataCache = newDataCache;
|
_allActionsDataCache = newDataCache;
|
||||||
_dirtyFlags |= Simulation::DIRTY_PHYSICS_ACTIVATION;
|
_dirtyFlags |= Simulation::DIRTY_PHYSICS_ACTIVATION;
|
||||||
|
} else {
|
||||||
|
qDebug() << "EntityItem::addActionInternal -- serializeActions failed";
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -1628,6 +1631,7 @@ void EntityItem::deserializeActionsInternal() {
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
|
|
||||||
if (!_element) {
|
if (!_element) {
|
||||||
|
qDebug() << "EntityItem::deserializeActionsInternal -- no _element";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1670,6 +1674,8 @@ void EntityItem::deserializeActionsInternal() {
|
||||||
if (action) {
|
if (action) {
|
||||||
entity->addActionInternal(simulation, action);
|
entity->addActionInternal(simulation, action);
|
||||||
action->locallyAddedButNotYetReceived = false;
|
action->locallyAddedButNotYetReceived = false;
|
||||||
|
} else {
|
||||||
|
qDebug() << "EntityItem::deserializeActionsInternal -- action creation failed";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,9 +407,12 @@ public:
|
||||||
QVariantMap getActionArguments(const QUuid& actionID) const;
|
QVariantMap getActionArguments(const QUuid& actionID) const;
|
||||||
void deserializeActions();
|
void deserializeActions();
|
||||||
void setActionDataDirty(bool value) const { _actionDataDirty = value; }
|
void setActionDataDirty(bool value) const { _actionDataDirty = value; }
|
||||||
bool getActionDataDirty() const { return _actionDataDirty; }
|
|
||||||
bool shouldSuppressLocationEdits() const;
|
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:
|
protected:
|
||||||
|
|
||||||
const QByteArray getActionDataInternal() const;
|
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
|
// _previouslyDeletedActions is used to avoid an action being re-added due to server round-trip lag
|
||||||
static quint64 _rememberDeletedActionTime;
|
static quint64 _rememberDeletedActionTime;
|
||||||
mutable QHash<QUuid, quint64> _previouslyDeletedActions;
|
mutable QHash<QUuid, quint64> _previouslyDeletedActions;
|
||||||
|
|
||||||
|
QUuid _sourceUUID; /// the server node UUID we came from
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_EntityItem_h
|
#endif // hifi_EntityItem_h
|
||||||
|
|
|
@ -302,7 +302,7 @@ bool EntityMotionState::remoteSimulationOutOfSync(uint32_t simulationStep) {
|
||||||
_serverPosition += dt * _serverVelocity;
|
_serverPosition += dt * _serverVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_serverActionData != _entity->getActionData() || _entity->getActionDataDirty()) {
|
if (_serverActionData != _entity->getActionData()) {
|
||||||
setOutgoingPriority(SCRIPT_EDIT_SIMULATION_PRIORITY);
|
setOutgoingPriority(SCRIPT_EDIT_SIMULATION_PRIORITY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,22 @@ void ObjectAction::updateAction(btCollisionWorld* collisionWorld, btScalar delta
|
||||||
updateActionWorker(deltaTimeStep);
|
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 ObjectAction::updateArguments(QVariantMap arguments) {
|
||||||
bool somethingChanged = false;
|
bool somethingChanged = false;
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
int getEntityServerClockSkew();
|
||||||
|
|
||||||
virtual btRigidBody* getRigidBody();
|
virtual btRigidBody* getRigidBody();
|
||||||
virtual glm::vec3 getPosition();
|
virtual glm::vec3 getPosition();
|
||||||
virtual void setPosition(glm::vec3 position);
|
virtual void setPosition(glm::vec3 position);
|
||||||
|
|
|
@ -160,7 +160,7 @@ QByteArray ObjectActionOffset::serialize() const {
|
||||||
dataStream << _linearDistance;
|
dataStream << _linearDistance;
|
||||||
dataStream << _linearTimeScale;
|
dataStream << _linearTimeScale;
|
||||||
dataStream << _positionalTargetSet;
|
dataStream << _positionalTargetSet;
|
||||||
dataStream << _expires;
|
dataStream << _expires + getEntityServerClockSkew();
|
||||||
dataStream << _tag;
|
dataStream << _tag;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -190,6 +190,7 @@ void ObjectActionOffset::deserialize(QByteArray serializedArguments) {
|
||||||
dataStream >> _linearTimeScale;
|
dataStream >> _linearTimeScale;
|
||||||
dataStream >> _positionalTargetSet;
|
dataStream >> _positionalTargetSet;
|
||||||
dataStream >> _expires;
|
dataStream >> _expires;
|
||||||
|
_expires -= getEntityServerClockSkew();
|
||||||
dataStream >> _tag;
|
dataStream >> _tag;
|
||||||
_active = true;
|
_active = true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -198,7 +198,7 @@ QByteArray ObjectActionSpring::serialize() const {
|
||||||
dataStream << _rotationalTarget;
|
dataStream << _rotationalTarget;
|
||||||
dataStream << _angularTimeScale;
|
dataStream << _angularTimeScale;
|
||||||
dataStream << _rotationalTargetSet;
|
dataStream << _rotationalTargetSet;
|
||||||
dataStream << _expires;
|
dataStream << _expires + getEntityServerClockSkew();
|
||||||
dataStream << _tag;
|
dataStream << _tag;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -233,6 +233,7 @@ void ObjectActionSpring::deserialize(QByteArray serializedArguments) {
|
||||||
dataStream >> _rotationalTargetSet;
|
dataStream >> _rotationalTargetSet;
|
||||||
|
|
||||||
dataStream >> _expires;
|
dataStream >> _expires;
|
||||||
|
_expires -= getEntityServerClockSkew();
|
||||||
dataStream >> _tag;
|
dataStream >> _tag;
|
||||||
|
|
||||||
_active = true;
|
_active = true;
|
||||||
|
|
Loading…
Reference in a new issue