mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 12:50:40 +02:00
Merge pull request #7101 from ZappoMan/fixDoublePreload
fix error in preload logic
This commit is contained in:
commit
921674b952
3 changed files with 17 additions and 24 deletions
|
@ -404,18 +404,16 @@ public:
|
||||||
|
|
||||||
virtual void loader() {} // called indirectly when urls for geometry are updated
|
virtual void loader() {} // called indirectly when urls for geometry are updated
|
||||||
|
|
||||||
/// Has the entity been added to an entity tree? This is useful in some state decisions
|
|
||||||
/// for example whether or not to send out a scriptChanging signal.
|
|
||||||
void markAsAddedToTree() { _isAddedToTree = true; }
|
|
||||||
bool isAddedToTree() const { return _isAddedToTree; }
|
|
||||||
|
|
||||||
/// Should the external entity script mechanism call a preload for this entity.
|
/// Should the external entity script mechanism call a preload for this entity.
|
||||||
/// Due to the asyncronous nature of signals for add entity and script changing
|
/// Due to the asyncronous nature of signals for add entity and script changing
|
||||||
/// it's possible for two similar signals to cross paths. This method allows the
|
/// it's possible for two similar signals to cross paths. This method allows the
|
||||||
/// entity to definitively state if the preload signal should be sent.
|
/// entity to definitively state if the preload signal should be sent.
|
||||||
|
///
|
||||||
|
/// We only want to preload if:
|
||||||
|
/// there is some script, and either the script value or the scriptTimestamp
|
||||||
|
/// value have changed since our last preload
|
||||||
bool shouldPreloadScript() const { return !_script.isEmpty() &&
|
bool shouldPreloadScript() const { return !_script.isEmpty() &&
|
||||||
_loadedScript != _script && _loadedScriptTimestamp != _scriptTimestamp; }
|
((_loadedScript != _script) || (_loadedScriptTimestamp != _scriptTimestamp)); }
|
||||||
|
|
||||||
void scriptHasPreloaded() { _loadedScript = _script; _loadedScriptTimestamp = _scriptTimestamp; }
|
void scriptHasPreloaded() { _loadedScript = _script; _loadedScriptTimestamp = _scriptTimestamp; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -458,8 +456,15 @@ protected:
|
||||||
float _restitution;
|
float _restitution;
|
||||||
float _friction;
|
float _friction;
|
||||||
float _lifetime;
|
float _lifetime;
|
||||||
QString _script;
|
|
||||||
quint64 _scriptTimestamp;
|
QString _script; /// the value of the script property
|
||||||
|
QString _loadedScript; /// the value of _script when the last preload signal was sent
|
||||||
|
quint64 _scriptTimestamp{ ENTITY_ITEM_DEFAULT_SCRIPT_TIMESTAMP }; /// the script loaded property used for forced reload
|
||||||
|
|
||||||
|
/// the value of _scriptTimestamp when the last preload signal was sent
|
||||||
|
// NOTE: on construction we want this to be different from _scriptTimestamp so we intentionally bump it
|
||||||
|
quint64 _loadedScriptTimestamp{ ENTITY_ITEM_DEFAULT_SCRIPT_TIMESTAMP + 1 };
|
||||||
|
|
||||||
QString _collisionSoundURL;
|
QString _collisionSoundURL;
|
||||||
glm::vec3 _registrationPoint;
|
glm::vec3 _registrationPoint;
|
||||||
float _angularDamping;
|
float _angularDamping;
|
||||||
|
@ -520,12 +525,6 @@ protected:
|
||||||
mutable QHash<QUuid, quint64> _previouslyDeletedActions;
|
mutable QHash<QUuid, quint64> _previouslyDeletedActions;
|
||||||
|
|
||||||
QUuid _sourceUUID; /// the server node UUID we came from
|
QUuid _sourceUUID; /// the server node UUID we came from
|
||||||
|
|
||||||
bool _isAddedToTree { false }; /// this is false until the entity has been added to an entity tree
|
|
||||||
|
|
||||||
QString _loadedScript; /// the value of _script when the last preload signal was sent
|
|
||||||
quint64 _loadedScriptTimestamp { 0 }; /// the value of _scriptTimestamp when the last preload signal was sent
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_EntityItem_h
|
#endif // hifi_EntityItem_h
|
||||||
|
|
|
@ -92,9 +92,6 @@ void EntityTree::postAddEntity(EntityItemPointer entity) {
|
||||||
|
|
||||||
// find and hook up any entities with this entity as a (previously) missing parent
|
// find and hook up any entities with this entity as a (previously) missing parent
|
||||||
fixupMissingParents();
|
fixupMissingParents();
|
||||||
|
|
||||||
// indicate that the entity has been added to the tree
|
|
||||||
entity->markAsAddedToTree();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties, const SharedNodePointer& senderNode) {
|
bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties, const SharedNodePointer& senderNode) {
|
||||||
|
|
|
@ -927,11 +927,8 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
|
||||||
bool reload = entityScriptTimestampBefore != entityScriptTimestampAfter;
|
bool reload = entityScriptTimestampBefore != entityScriptTimestampAfter;
|
||||||
|
|
||||||
// If the script value has changed on us, or it's timestamp has changed to force
|
// If the script value has changed on us, or it's timestamp has changed to force
|
||||||
// a reload then we want to send out a script changing signal... UNLESS this is the
|
// a reload then we want to send out a script changing signal...
|
||||||
// first time we've read the entity information, in which case, the entity has
|
if (entityScriptBefore != entityScriptAfter || reload) {
|
||||||
// not yet been added to the tree, and we want to wait for the addEntity. In other
|
|
||||||
// words it's not a "change" in the script, if it's a first time load.
|
|
||||||
if (entityItem->isAddedToTree() && (entityScriptBefore != entityScriptAfter || reload)) {
|
|
||||||
_myTree->emitEntityScriptChanging(entityItemID, reload); // the entity script has changed
|
_myTree->emitEntityScriptChanging(entityItemID, reload); // the entity script has changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue