From 0f488bca023f5771c91414c94dcc0efeb0a94229 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 15 Dec 2014 14:28:53 -0800 Subject: [PATCH] differentiation btw _lastEdited and _lastSimulated --- libraries/entities/src/EntityItem.cpp | 10 +++++++--- libraries/entities/src/EntityItem.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 0faea7cc1c..d2e3acb86d 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -458,7 +458,8 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef ByteCountCoded updateDeltaCoder = encodedUpdateDelta; quint64 updateDelta = updateDeltaCoder; if (overwriteLocalData) { - _lastSimulated = _lastUpdated = lastEditedFromBufferAdjusted + updateDelta; // don't adjust for clock skew since we already did that for _lastEdited + _lastUpdated = lastEditedFromBufferAdjusted + updateDelta; // don't adjust for clock skew since we already did that for _lastEdited + _lastSimulated = now; if (wantDebug) { qDebug() << "_lastUpdated =" << _lastUpdated; qDebug() << "_lastEdited=" << _lastEdited; @@ -619,8 +620,6 @@ void EntityItem::simulate(const quint64& now) { } } - _lastSimulated = now; - if (wantDebug) { qDebug() << " ********** EntityItem::update() .... SETTING _lastSimulated=" << _lastSimulated; } @@ -730,6 +729,8 @@ void EntityItem::simulate(const quint64& now) { } } } + + _lastSimulated = now; } bool EntityItem::isMoving() const { @@ -819,6 +820,9 @@ bool EntityItem::setProperties(const EntityItemProperties& properties, bool forc "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties._lastEdited); + if (getDirtyFlags() & EntityItem::DIRTY_POSITION) { + _lastSimulated = usecTimestampNow(); + } } return somethingChanged; diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index c01e9b9ceb..ef88cb772f 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -86,7 +86,7 @@ public: /// Last edited time of this entity universal usecs quint64 getLastEdited() const { return _lastEdited; } void setLastEdited(quint64 lastEdited) - { _lastEdited = _lastSimulated = _lastUpdated = lastEdited; _changedOnServer = glm::max(lastEdited, _changedOnServer); } + { _lastEdited = _lastUpdated = lastEdited; _changedOnServer = glm::max(lastEdited, _changedOnServer); } float getEditedAgo() const /// Elapsed seconds since this entity was last edited { return (float)(usecTimestampNow() - getLastEdited()) / (float)USECS_PER_SECOND; }