From 00713ab2250ab18c167485fbd437e582e37a95a3 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 6 Apr 2018 14:00:50 -0700 Subject: [PATCH 1/4] fix selection api --- interface/src/scripting/SelectionScriptingInterface.cpp | 4 +++- interface/src/scripting/SelectionScriptingInterface.h | 8 ++++++-- scripts/developer/utilities/render/debugHighlight.js | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index f8a62e848c..5f762ab511 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -110,6 +110,7 @@ bool SelectionScriptingInterface::enableListHighlight(const QString& listName, c } if (!(*highlightStyle).isBoundToList()) { + enableListToScene(listName); (*highlightStyle).setBoundToList(true); } @@ -133,6 +134,7 @@ bool SelectionScriptingInterface::disableListHighlight(const QString& listName) auto highlightStyle = _highlightStyleMap.find(listName); if (highlightStyle != _highlightStyleMap.end()) { if ((*highlightStyle).isBoundToList()) { + disableListToScene(listName); } _highlightStyleMap.erase(highlightStyle); @@ -476,4 +478,4 @@ QVariantMap SelectionHighlightStyle::toVariantMap() const { properties["isOutlineSmooth"] = _style._isOutlineSmooth; return properties; -} \ No newline at end of file +} diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 3046ac371e..ed6efb39c6 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -165,6 +165,8 @@ public: * @param listName {string} name of the selection * @param highlightStyle {jsObject} highlight style fields (see Selection.getListHighlightStyle for a detailed description of the highlightStyle). * @returns {bool} true if the selection was successfully enabled for highlight. + * + * Note: This function will implicitly call Selection.enableListToScene */ Q_INVOKABLE bool enableListHighlight(const QString& listName, const QVariantMap& highlightStyle); @@ -175,8 +177,10 @@ public: * @function Selection.disableListHighlight * @param listName {string} name of the selection * @returns {bool} true if the selection was successfully disabled for highlight, false otherwise. + * + * Note: This function will implicitly call Selection.disableListToScene */ - Q_INVOKABLE bool disableListHighlight(const QString& listName); + Q_INVOKABLE bool disableListHighlight(const QString& listName); /**jsdoc * Enable scene selection for the named selection. * If the Selection doesn't exist, it will be created. @@ -246,7 +250,7 @@ private: void setupHandler(const QString& selectionName); void removeHandler(const QString& selectionName); - + }; #endif // hifi_SelectionScriptingInterface_h diff --git a/scripts/developer/utilities/render/debugHighlight.js b/scripts/developer/utilities/render/debugHighlight.js index c2173f6e2a..664af836a9 100644 --- a/scripts/developer/utilities/render/debugHighlight.js +++ b/scripts/developer/utilities/render/debugHighlight.js @@ -157,7 +157,7 @@ }) function cleanup() { - Pointers.removePointer(ray); + Pointers.removePointer(laser); Selection.disableListHighlight(HoveringList) Selection.removeListFromMap(HoveringList) From b515fd50fcbb09ec13ed070847eff0fff7168a24 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 6 Apr 2018 16:52:49 -0700 Subject: [PATCH 2/4] remove unused data member --- libraries/entities-renderer/src/RenderableZoneEntityItem.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index c5824abef0..2f8fd47b79 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -69,7 +69,6 @@ private: graphics::SkyboxPointer editSkybox() { return editBackground()->getSkybox(); } graphics::HazePointer editHaze() { _needHazeUpdate = true; return _haze; } - bool _needsInitialSimulation{ true }; glm::vec3 _lastPosition; glm::vec3 _lastDimensions; glm::quat _lastRotation; From 353afb47b3a3f547234b6cd36d5ffe854b3d10bf Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 6 Apr 2018 16:53:08 -0700 Subject: [PATCH 3/4] more correct needsToCallUpdate() implementations --- libraries/entities/src/MaterialEntityItem.h | 2 +- libraries/entities/src/ModelEntityItem.cpp | 69 +++++++++------------ libraries/entities/src/PolyLineEntityItem.h | 2 - 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/libraries/entities/src/MaterialEntityItem.h b/libraries/entities/src/MaterialEntityItem.h index f77077a782..88ff7766c4 100644 --- a/libraries/entities/src/MaterialEntityItem.h +++ b/libraries/entities/src/MaterialEntityItem.h @@ -25,7 +25,7 @@ public: ALLOW_INSTANTIATION // This class can be instantiated void update(const quint64& now) override; - bool needsToCallUpdate() const override { return true; } + bool needsToCallUpdate() const override { return _retryApply; } // methods for getting/setting all properties of an entity virtual EntityItemProperties getProperties(EntityPropertyFlags desiredProperties = EntityPropertyFlags()) const override; diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index bec7bc1906..92d99ac3fb 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -195,53 +195,43 @@ void ModelEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit // added update function back for property fix void ModelEntityItem::update(const quint64& now) { + auto currentAnimationProperties = this->getAnimationProperties(); + if (_previousAnimationProperties != currentAnimationProperties) { + withWriteLock([&] { + // if we hit start animation or change the first or last frame then restart the animation + if ((currentAnimationProperties.getFirstFrame() != _previousAnimationProperties.getFirstFrame()) || + (currentAnimationProperties.getLastFrame() != _previousAnimationProperties.getLastFrame()) || + (currentAnimationProperties.getRunning() && !_previousAnimationProperties.getRunning())) { - { - auto currentAnimationProperties = this->getAnimationProperties(); - - if (_previousAnimationProperties != currentAnimationProperties) { - withWriteLock([&] { - // if we hit start animation or change the first or last frame then restart the animation - if ((currentAnimationProperties.getFirstFrame() != _previousAnimationProperties.getFirstFrame()) || - (currentAnimationProperties.getLastFrame() != _previousAnimationProperties.getLastFrame()) || - (currentAnimationProperties.getRunning() && !_previousAnimationProperties.getRunning())) { - - // when we start interface and the property is are set then the current frame is initialized to -1 - if (_currentFrame < 0) { - // don't reset _lastAnimated here because we need the timestamp from the ModelEntityItem constructor for when the properties were set - _currentFrame = currentAnimationProperties.getCurrentFrame(); - setAnimationCurrentFrame(_currentFrame); - } else { - _lastAnimated = usecTimestampNow(); - _currentFrame = currentAnimationProperties.getFirstFrame(); - setAnimationCurrentFrame(currentAnimationProperties.getFirstFrame()); - } - } else if (!currentAnimationProperties.getRunning() && _previousAnimationProperties.getRunning()) { - _currentFrame = currentAnimationProperties.getFirstFrame(); - setAnimationCurrentFrame(_currentFrame); - } else if (currentAnimationProperties.getCurrentFrame() != _previousAnimationProperties.getCurrentFrame()) { - // don't reset _lastAnimated here because the currentFrame was set with the previous setting of _lastAnimated + // when we start interface and the property is are set then the current frame is initialized to -1 + if (_currentFrame < 0) { + // don't reset _lastAnimated here because we need the timestamp from the ModelEntityItem constructor for when the properties were set _currentFrame = currentAnimationProperties.getCurrentFrame(); + setAnimationCurrentFrame(_currentFrame); + } else { + _lastAnimated = usecTimestampNow(); + _currentFrame = currentAnimationProperties.getFirstFrame(); + setAnimationCurrentFrame(currentAnimationProperties.getFirstFrame()); } - - }); - _previousAnimationProperties = this->getAnimationProperties(); - - } - - if (isAnimatingSomething()) { - if (!(getAnimationFirstFrame() < 0) && !(getAnimationFirstFrame() > getAnimationLastFrame())) { - updateFrameCount(); + } else if (!currentAnimationProperties.getRunning() && _previousAnimationProperties.getRunning()) { + _currentFrame = currentAnimationProperties.getFirstFrame(); + setAnimationCurrentFrame(_currentFrame); + } else if (currentAnimationProperties.getCurrentFrame() != _previousAnimationProperties.getCurrentFrame()) { + // don't reset _lastAnimated here because the currentFrame was set with the previous setting of _lastAnimated + _currentFrame = currentAnimationProperties.getCurrentFrame(); } - } - } + }); + _previousAnimationProperties = this->getAnimationProperties(); + } + if (!(getAnimationFirstFrame() < 0) && !(getAnimationFirstFrame() > getAnimationLastFrame())) { + updateFrameCount(); + } EntityItem::update(now); } bool ModelEntityItem::needsToCallUpdate() const { - - return true; + return isAnimatingSomething(); } void ModelEntityItem::updateFrameCount() { @@ -714,11 +704,10 @@ float ModelEntityItem::getAnimationFPS() const { }); } - bool ModelEntityItem::isAnimatingSomething() const { return resultWithReadLock([&] { return !_animationProperties.getURL().isEmpty() && _animationProperties.getRunning() && (_animationProperties.getFPS() != 0.0f); }); -} \ No newline at end of file +} diff --git a/libraries/entities/src/PolyLineEntityItem.h b/libraries/entities/src/PolyLineEntityItem.h index 2dc8befe97..20d7598b9f 100644 --- a/libraries/entities/src/PolyLineEntityItem.h +++ b/libraries/entities/src/PolyLineEntityItem.h @@ -78,8 +78,6 @@ class PolyLineEntityItem : public EntityItem { QString getTextures() const; void setTextures(const QString& textures); - virtual bool needsToCallUpdate() const override { return true; } - virtual ShapeType getShapeType() const override { return SHAPE_TYPE_NONE; } bool pointsChanged() const { return _pointsChanged; } From 9c84f0527527859251834e78f77f8bd1d61788fe Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 6 Apr 2018 17:32:57 -0700 Subject: [PATCH 4/4] rollback change to MaterialEntityItem, we'll fix later --- libraries/entities/src/MaterialEntityItem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/entities/src/MaterialEntityItem.h b/libraries/entities/src/MaterialEntityItem.h index 88ff7766c4..f77077a782 100644 --- a/libraries/entities/src/MaterialEntityItem.h +++ b/libraries/entities/src/MaterialEntityItem.h @@ -25,7 +25,7 @@ public: ALLOW_INSTANTIATION // This class can be instantiated void update(const quint64& now) override; - bool needsToCallUpdate() const override { return _retryApply; } + bool needsToCallUpdate() const override { return true; } // methods for getting/setting all properties of an entity virtual EntityItemProperties getProperties(EntityPropertyFlags desiredProperties = EntityPropertyFlags()) const override;