diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 6273b9f8df..a537ecd0f3 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -799,13 +799,26 @@ void RenderableModelEntityItem::locationChanged(bool tellPhysics) { _model->setRotation(getRotation()); _model->setTranslation(getPosition()); - auto myMetaItemCopy = _myMetaItem; - void* key = (void*)this; - AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [myMetaItemCopy]() { + std::weak_ptr weakSelf = + std::static_pointer_cast(getThisPointer()); + + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [weakSelf]() { + auto self = weakSelf.lock(); + if (!self) { + return; + } + + render::ItemID myMetaItem = self->getMetaRenderItem(); + + if (myMetaItem == render::Item::INVALID_ITEM_ID) { + return; + } + render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene(); render::PendingChanges pendingChanges; - pendingChanges.updateItem(myMetaItemCopy, [](RenderableModelEntityItemMeta& data){}); + + pendingChanges.updateItem(myMetaItem); scene->enqueuePendingChanges(pendingChanges); }); } diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.h b/libraries/entities-renderer/src/RenderableModelEntityItem.h index 5fd767c6ee..d2de45f538 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.h +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.h @@ -89,6 +89,8 @@ public: bool hasRenderAnimation() const { return !_renderAnimationProperties.getURL().isEmpty(); } const QString& getRenderAnimationURL() const { return _renderAnimationProperties.getURL(); } + render::ItemID getMetaRenderItem() { return _myMetaItem; } + private: QVariantMap parseTexturesToMap(QString textures); void remapTextures(); diff --git a/libraries/render/src/render/Scene.cpp b/libraries/render/src/render/Scene.cpp index e091b4842c..0b1d8fb55f 100644 --- a/libraries/render/src/render/Scene.cpp +++ b/libraries/render/src/render/Scene.cpp @@ -157,6 +157,11 @@ void Scene::updateItems(const ItemIDs& ids, UpdateFunctors& functors) { auto updateFunctor = functors.begin(); for (auto updateID : ids) { + if (updateID == Item::INVALID_ITEM_ID) { + updateFunctor++; + continue; + } + // Access the true item auto& item = _items[updateID]; auto oldCell = item.getCell();