diff --git a/libraries/entities-renderer/src/RenderableEntityItem.cpp b/libraries/entities-renderer/src/RenderableEntityItem.cpp index 9e32977de1..fb9aba636b 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableEntityItem.cpp @@ -141,6 +141,10 @@ std::shared_ptr make_renderer(const EntityItemPointer& entity) { } EntityRenderer::EntityRenderer(const EntityItemPointer& entity) : _entity(entity) { + connect(entity.get(), &EntityItem::requestRenderUpdate, this, [&] { + _needsRenderUpdate = true; + emit requestRenderUpdate(); + }); } EntityRenderer::~EntityRenderer() { } @@ -311,6 +315,9 @@ void EntityRenderer::setSubRenderItemIDs(const render::ItemIDs& ids) { // Returns true if the item needs to have updateInscene called because of internal rendering // changes (animation, fading, etc) bool EntityRenderer::needsRenderUpdate() const { + if (_needsRenderUpdate) { + return true; + } if (_prevIsTransparent != isTransparent()) { return true; } @@ -331,10 +338,6 @@ bool EntityRenderer::needsRenderUpdateFromEntity(const EntityItemPointer& entity return true; } - if (_visible != entity->getVisible()) { - return true; - } - if (_moving != entity->isMovingRelativeToParent()) { return true; } @@ -363,6 +366,7 @@ void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transa _moving = entity->isMovingRelativeToParent(); _visible = entity->getVisible(); + _needsRenderUpdate = false; }); } diff --git a/libraries/entities-renderer/src/RenderableEntityItem.h b/libraries/entities-renderer/src/RenderableEntityItem.h index 5deb69711d..8eb82e2c6e 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.h +++ b/libraries/entities-renderer/src/RenderableEntityItem.h @@ -125,6 +125,7 @@ protected: bool _prevIsTransparent { false }; bool _visible { false }; bool _moving { false }; + bool _needsRenderUpdate { false }; // Only touched on the rendering thread bool _renderUpdateQueued{ false }; diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index fc753713ba..722ad416e4 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -2715,9 +2715,17 @@ bool EntityItem::getVisible() const { } void EntityItem::setVisible(bool value) { + bool changed = false; withWriteLock([&] { - _visible = value; + if (_visible != value) { + changed = true; + _visible = value; + } }); + + if (changed) { + emit requestRenderUpdate(); + } } bool EntityItem::isChildOfMyAvatar() const { diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index d8fb3b3ab6..ecfb7b5dcd 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -469,6 +469,9 @@ public: static QString _marketplacePublicKey; static void retrieveMarketplacePublicKey(); +signals: + void requestRenderUpdate(); + protected: QHash _changeHandlers;