mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 07:51:01 +02:00
setup test of lockout-period oafter simulator-owner-id change
This commit is contained in:
parent
6c4d232ad9
commit
df37b853f7
3 changed files with 16 additions and 1 deletions
|
@ -75,6 +75,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) {
|
||||||
_dirtyFlags = 0;
|
_dirtyFlags = 0;
|
||||||
_changedOnServer = 0;
|
_changedOnServer = 0;
|
||||||
_element = NULL;
|
_element = NULL;
|
||||||
|
_simulatorIDChangedTime = 0;
|
||||||
initFromEntityItemID(entityItemID);
|
initFromEntityItemID(entityItemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +91,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert
|
||||||
_dirtyFlags = 0;
|
_dirtyFlags = 0;
|
||||||
_changedOnServer = 0;
|
_changedOnServer = 0;
|
||||||
_element = NULL;
|
_element = NULL;
|
||||||
|
_simulatorIDChangedTime = 0;
|
||||||
initFromEntityItemID(entityItemID);
|
initFromEntityItemID(entityItemID);
|
||||||
setProperties(properties);
|
setProperties(properties);
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,8 @@ public:
|
||||||
void setUserData(const QString& value) { _userData = value; }
|
void setUserData(const QString& value) { _userData = value; }
|
||||||
|
|
||||||
QString getSimulatorID() const { return _simulatorID; }
|
QString getSimulatorID() const { return _simulatorID; }
|
||||||
void setSimulatorID(const QString& id) { _simulatorID = id; }
|
void setSimulatorID(const QString& id) { _simulatorID = id; _simulatorIDChangedTime = usecTimestampNow(); }
|
||||||
|
quint64 getSimulatorIDChangedTime() const { return _simulatorIDChangedTime; }
|
||||||
|
|
||||||
const QString& getMarketplaceID() const { return _marketplaceID; }
|
const QString& getMarketplaceID() const { return _marketplaceID; }
|
||||||
void setMarketplaceID(const QString& value) { _marketplaceID = value; }
|
void setMarketplaceID(const QString& value) { _marketplaceID = value; }
|
||||||
|
@ -352,6 +353,7 @@ protected:
|
||||||
bool _locked;
|
bool _locked;
|
||||||
QString _userData;
|
QString _userData;
|
||||||
QString _simulatorID; // id of Node which is currently responsible for simulating this Entity
|
QString _simulatorID; // id of Node which is currently responsible for simulating this Entity
|
||||||
|
quint64 _simulatorIDChangedTime; // when was _simulatorID last updated?
|
||||||
QString _marketplaceID;
|
QString _marketplaceID;
|
||||||
|
|
||||||
// NOTE: Damping is applied like this: v *= pow(1 - damping, dt)
|
// NOTE: Damping is applied like this: v *= pow(1 - damping, dt)
|
||||||
|
|
|
@ -130,6 +130,17 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (properties.simulatorIDChanged() &&
|
||||||
|
!entity->getSimulatorID().isEmpty() &&
|
||||||
|
properties.getSimulatorID() != entity->getSimulatorID()) {
|
||||||
|
// A Node is trying to take ownership of the simulation of this entity from another Node. Only allow this
|
||||||
|
// if ownership hasn't recently changed.
|
||||||
|
quint64 now = usecTimestampNow();
|
||||||
|
if (now - entity->getSimulatorIDChangedTime() < 0.1 * USECS_PER_SECOND) { // XXX pick time and put in constant
|
||||||
|
qDebug() << "TOO SOON";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString entityScriptBefore = entity->getScript();
|
QString entityScriptBefore = entity->getScript();
|
||||||
uint32_t preFlags = entity->getDirtyFlags();
|
uint32_t preFlags = entity->getDirtyFlags();
|
||||||
UpdateEntityOperator theOperator(this, containingElement, entity, properties);
|
UpdateEntityOperator theOperator(this, containingElement, entity, properties);
|
||||||
|
|
Loading…
Reference in a new issue